nom::number

Function be_i8

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

Recognizes a signed 1 byte integer.

Streaming version: Will return Err(nom::Err::Incomplete(_)) if there is not enough data.

use nom::number::be_i8;

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

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