nom::number

Function be_i16

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

Recognizes a big endian signed 2 bytes integer.

use nom::number::be_i16;

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

assert_eq!(parser.parse(&b"\x00\x01abcd"[..]), Ok((&b"abcd"[..], 0x0001)));
assert_eq!(parser.parse(&b""[..]), Err(Err::Incomplete(Needed::new(2))));