Function take
fn take<Input, Output, Count, Error>(count: Count) -> impl Parser<(Input, usize), Output, Error>
where
Input: Stream<Token = u8> + StreamIsPartial + Clone,
Output: From<u8> + AddAssign + Shl<usize, Output = Output> + Shr<usize, Output = Output>,
Count: ToUsize,
Error: ParserError<(Input, usize)>
Parse taking count bits
Effective Signature
Assuming you are parsing a (&[u8], usize) bit [Stream]:
# use *;;
# use ContextError;
#
Example
# use *;
# use Bytes;
# use ContextError;
use take;
type Stream<'i> = &'i Bytes;
// Consumes 0 bits, returns 0
assert_eq!;
// Consumes 4 bits, returns their values and increase offset to 4
assert_eq!;
// Consumes 4 bits, offset is 4, returns their values and increase offset to 0 of next byte
assert_eq!;
// Tries to consume 12 bits but only 8 are available
assert!;