pub struct BitReader<'a, const MSB: bool> { /* private fields */ }Expand description
A bit cursor that reads from a byte slice.
Implementations§
Source§impl<'a, const MSB: bool> BitReader<'a, MSB>
impl<'a, const MSB: bool> BitReader<'a, MSB>
Sourcepub const fn new(bytes: &'a [u8]) -> Self
pub const fn new(bytes: &'a [u8]) -> Self
A cursor at the first bit of bytes.
MSB is true to read the top of each byte first.
Sourcepub const fn at(bytes: &'a [u8], at_bit: usize) -> Self
pub const fn at(bytes: &'a [u8], at_bit: usize) -> Self
A cursor at bit at_bit of bytes. A position past the end reads as Short.
Sourcepub fn read(&mut self, bits: u32) -> Result<u64, ParseError>
pub fn read(&mut self, bits: u32) -> Result<u64, ParseError>
Read the next bits bits as an integer.
§Errors
ParseError::Short if the slice ends inside the field. at is the field’s first byte.
Sourcepub fn bit(&mut self) -> Result<bool, ParseError>
pub fn bit(&mut self) -> Result<bool, ParseError>
Sourcepub fn skip(&mut self, bits: usize) -> Result<(), ParseError>
pub fn skip(&mut self, bits: usize) -> Result<(), ParseError>
Skip bits bits.
§Errors
ParseError::Short if the slice ends inside them. at is the first skipped byte.
Sourcepub const fn bytes_consumed(&self) -> usize
pub const fn bytes_consumed(&self) -> usize
Bytes touched so far, counting a partly read byte.
Trait Implementations§
Auto Trait Implementations§
impl<'a, const MSB: bool> Freeze for BitReader<'a, MSB>
impl<'a, const MSB: bool> RefUnwindSafe for BitReader<'a, MSB>
impl<'a, const MSB: bool> Send for BitReader<'a, MSB>
impl<'a, const MSB: bool> Sync for BitReader<'a, MSB>
impl<'a, const MSB: bool> Unpin for BitReader<'a, MSB>
impl<'a, const MSB: bool> UnsafeUnpin for BitReader<'a, MSB>
impl<'a, const MSB: bool> UnwindSafe for BitReader<'a, MSB>
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