Macro nom::u32 [−][src]
macro_rules! u32 { ($i:expr, $e:expr) => { ... }; }
If the parameter is nom::Endianness::Big
, parse a big endian u32 integer,
otherwise a little endian u32 integer.
use nom::number::Endianness; named!(be<u32>, u32!(Endianness::Big)); assert_eq!(be(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x00010203))); assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::new(3)))); named!(le<u32>, u32!(Endianness::Little)); assert_eq!(le(b"\x00\x01\x02\x03abcd"), Ok((&b"abcd"[..], 0x03020100))); assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::new(3))));