combine::parser::byte::num

Function be_u16

source
pub fn be_u16<'a, Input>() -> impl Parser<Input, Output = u16, PartialState = ()>
where Input: Stream<Token = u8>,
Expand description

Reads a u16 out of the byte stream with the specified endianess

use combine::Parser;
use combine::parser::byte::num::le_u16;

assert_eq!(le_u16().parse(&b"\x01\0"[..]), Ok((1, &b""[..])));
assert!(le_u16().parse(&b"\0"[..]).is_err());