nom::number

Function be_i32

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

Recognizes a big endian signed 4 bytes integer.

use nom::number::be_i32;

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

assert_eq!(parser.parse(&b"\x00\x01\x02\x03abcd"[..]), Ok((&b"abcd"[..], 0x00010203)));
assert_eq!(parser.parse(&b""[..]), Err(Err::Incomplete(Needed::new(4))));