bitty/bytes
Byte-level parsers for reading, skipping, peeking, and matching raw
bytes. These parsers work at any bit position — when unaligned, bytes
are extracted bit-by-bit. When byte-aligned, zero-copy slicing is used.
After bit-level parsing with bitty/bits, call bitty.align() before
resuming byte-aligned operations.
Values
pub fn peek(bytes count: Int) -> bitty.Parser(BitArray)
Look ahead at the next count bytes without consuming them.
pub fn rest() -> bitty.Parser(BitArray)
Consume all remaining input as a BitArray.
Works at any bit position — the result may be non-byte-aligned.
pub fn skip(bytes count: Int) -> bitty.Parser(Nil)
Advance the parser position by count bytes, discarding the data.
pub fn tag(expected: BitArray) -> bitty.Parser(Nil)
Match an exact byte sequence at the current position and consume it. Fails if the bytes don’t match. Useful for magic numbers and fixed headers.
pub fn take(bytes count: Int) -> bitty.Parser(BitArray)
Parse exactly count bytes as a BitArray.
When byte-aligned, returns a zero-copy slice.