pub struct BitReader<'a> { /* private fields */ }Expand description
An LSB-first bit reader over a VP8L bitstream (RFC 9649 §3.3).
Bits are pulled a byte at a time into a small accumulator and handed out least-significant-bit
first. Running past the end of the input is reported as Error::InvalidInput rather than
panicking, so a truncated stream fails cleanly.
Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
Sourcepub fn read_bits(&mut self, n: u32) -> Result<u32>
pub fn read_bits(&mut self, n: u32) -> Result<u32>
Reads n bits (0..=32) LSB-first, returning them right-aligned in a u32.
Reading 0 bits returns Ok(0) without consuming input (used by single-symbol prefix codes
that encode no bits).
§Errors
Returns Error::InvalidInput if fewer than n bits remain, or if n > 32.
Sourcepub fn read_bit(&mut self) -> Result<u32>
pub fn read_bit(&mut self) -> Result<u32>
Reads a single bit (a convenience wrapper over read_bits).
§Errors
Returns Error::InvalidInput if no bits remain.
Sourcepub fn bits_consumed(&self) -> usize
pub fn bits_consumed(&self) -> usize
Total number of bits consumed so far.
Sourcepub fn is_exhausted(&self) -> bool
pub fn is_exhausted(&self) -> bool
Whether every bit of the input has been consumed (the trailing partial byte, if any, is treated as zero padding and is not counted as remaining data).