Macro nom::u128[][src]

macro_rules! u128 {
    ($i:expr, $e:expr) => { ... };
}

if the parameter is nom::Endianness::Big, parse a big endian u128 integer, otherwise a little endian u128 integer

use nom::number::Endianness;

named!(be<u128>, u128!(Endianness::Big));

assert_eq!(be(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x00010203040506070809101112131415)));
assert_eq!(be(b"\x01"), Err(Err::Incomplete(Needed::Size(16))));

named!(le<u128>, u128!(Endianness::Little));

assert_eq!(le(b"\x00\x01\x02\x03\x04\x05\x06\x07\x08\x09\x10\x11\x12\x13\x14\x15abcd"), Ok((&b"abcd"[..], 0x15141312111009080706050403020100)));
assert_eq!(le(b"\x01"), Err(Err::Incomplete(Needed::Size(16))));