From c01aa44834697f8e05f57bba478eac31cfe5a1a8 Mon Sep 17 00:00:00 2001 From: Florian Kauer Date: Mon, 11 Dec 2023 17:19:25 +0100 Subject: [PATCH] Add parser for i64 Signed 64 is for example used for TCA_TAPRIO_ATTR_SCHED_CYCLE_TIME. Signed-off-by: Florian Kauer --- src/parsers.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/parsers.rs b/src/parsers.rs index cb6ade9..1e3665f 100644 --- a/src/parsers.rs +++ b/src/parsers.rs @@ -138,6 +138,13 @@ pub fn parse_i32(payload: &[u8]) -> Result { Ok(NativeEndian::read_i32(payload)) } +pub fn parse_i64(payload: &[u8]) -> Result { + if payload.len() != 8 { + return Err(format!("invalid i64: {payload:?}").into()); + } + Ok(NativeEndian::read_i64(payload)) +} + pub fn parse_u16_be(payload: &[u8]) -> Result { if payload.len() != size_of::() { return Err(DecodeError::InvalidNumber {