rustmax::nom::number

Function be_i24

Source
pub fn be_i24<I, E>() -> impl Parser<I, Output = i32, Error = E>
where E: ParseError<I>, I: Input<Item = u8>,
Expand description

Recognizes a big endian signed 3 bytes integer.

use nom::number::be_i24;

let mut parser = be_i24::<_, (_, ErrorKind)>();

assert_eq!(parser.parse(&b"\x00\x01\x02abcd"[..]), Ok((&b"abcd"[..], 0x000102)));
assert_eq!(parser.parse(&b""[..]), Err(Err::Incomplete(Needed::new(3))));