pub struct BitReader<'a> { /* private fields */ }Expand description
Reads fields MSB-first from a borrowed byte slice.
Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
Sourcepub fn total_bits(&self) -> usize
pub fn total_bits(&self) -> usize
Total bits in the backing buffer.
Sourcepub fn bits_remaining(&self) -> usize
pub fn bits_remaining(&self) -> usize
Bits not yet consumed.
Sourcepub fn is_byte_aligned(&self) -> bool
pub fn is_byte_aligned(&self) -> bool
true if the cursor sits on a byte boundary.
Sourcepub fn read_bits(&mut self, n: u32) -> Result<u64, BitError>
pub fn read_bits(&mut self, n: u32) -> Result<u64, BitError>
Read n bits (0..=64) MSB-first into the low bits of a u64.
read_bits(0) returns 0 and consumes nothing.
§Errors
BitError::TooManyBits if n > 64; BitError::OutOfBounds if
fewer than n bits remain.
Sourcepub fn align_to_byte(&mut self)
pub fn align_to_byte(&mut self)
Advance to the next byte boundary (no-op if already aligned).
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for BitReader<'a>
impl<'a> RefUnwindSafe for BitReader<'a>
impl<'a> Send for BitReader<'a>
impl<'a> Sync for BitReader<'a>
impl<'a> Unpin for BitReader<'a>
impl<'a> UnsafeUnpin for BitReader<'a>
impl<'a> UnwindSafe for BitReader<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more