Function nom::number::streaming::hex_u32[][src]

pub fn hex_u32<'a, E: ParseError<&'a [u8]>>(
    input: &'a [u8]
) -> IResult<&'a [u8], u32, E>

Recognizes a hex-encoded integer

streaming version: will return Err(nom::Err::Incomplete(_)) if there is not enough data

use nom::number::streaming::hex_u32;

let parser = |s| {
  hex_u32(s)
};

assert_eq!(parser(b"01AE;"), Ok((&b";"[..], 0x01AE)));
assert_eq!(parser(b"abc"), Err(Err::Incomplete(Needed::Size(1))));
assert_eq!(parser(b"ggg"), Err(Err::Error((&b"ggg"[..], ErrorKind::IsA))));