Macro nom::bytes
[−]
[src]
macro_rules! bytes { ($i:expr, $submac:ident!( $($args:tt)* )) => { ... }; ($i:expr, $f:expr) => { ... }; }
Counterpart to bits,
bytes!( parser ) => ( (&[u8], usize), &[u8] -> IResult<&[u8], T> ) -> IResult<(&[u8], usize), T>
,
transforms its bits stream input into a byte slice for the underlying parsers. If we start in the
middle of a byte throws away the bits until the end of the byte.
named!( parse<(u8, u8, &[u8])>, bits!( tuple!( take_bits!(u8, 4), take_bits!(u8, 8), bytes!(rest) ))); let input = &[0xde, 0xad, 0xbe, 0xaf]; assert_eq!(parse( input ), Done(&[][..], (0xd, 0xea, &[0xbe, 0xaf][..])));