pub struct BitReader<'a> { /* private fields */ }Implementations§
Source§impl<'a> BitReader<'a>
impl<'a> BitReader<'a>
pub fn new(data: &'a [u8]) -> Self
Sourcepub fn read_bits(&mut self, count: u8) -> Result<u64, DecodeError>
pub fn read_bits(&mut self, count: u8) -> Result<u64, DecodeError>
Read count bits LSB-first into a u64.
Sourcepub fn read_bool(&mut self) -> Result<bool, DecodeError>
pub fn read_bool(&mut self) -> Result<bool, DecodeError>
Read a single bit as bool.
Sourcepub fn flush_to_byte_boundary(&mut self)
pub fn flush_to_byte_boundary(&mut self)
Advance to the next byte boundary, discarding any remaining bits in the current byte. Infallible.
pub fn read_u8(&mut self) -> Result<u8, DecodeError>
pub fn read_u16(&mut self) -> Result<u16, DecodeError>
pub fn read_u32(&mut self) -> Result<u32, DecodeError>
pub fn read_u64(&mut self) -> Result<u64, DecodeError>
pub fn read_i8(&mut self) -> Result<i8, DecodeError>
pub fn read_i16(&mut self) -> Result<i16, DecodeError>
pub fn read_i32(&mut self) -> Result<i32, DecodeError>
pub fn read_i64(&mut self) -> Result<i64, DecodeError>
pub fn read_f32(&mut self) -> Result<f32, DecodeError>
pub fn read_f64(&mut self) -> Result<f64, DecodeError>
Sourcepub fn read_leb128(&mut self, max_bytes: u8) -> Result<u64, DecodeError>
pub fn read_leb128(&mut self, max_bytes: u8) -> Result<u64, DecodeError>
Read a LEB128-encoded u64, consuming at most max_bytes bytes.
Sourcepub fn read_zigzag(
&mut self,
_type_bits: u8,
max_bytes: u8,
) -> Result<i64, DecodeError>
pub fn read_zigzag( &mut self, _type_bits: u8, max_bytes: u8, ) -> Result<i64, DecodeError>
Read a ZigZag + LEB128 encoded signed integer.
Sourcepub fn read_string(&mut self) -> Result<String, DecodeError>
pub fn read_string(&mut self) -> Result<String, DecodeError>
Read a length-prefixed UTF-8 string.
Sourcepub fn read_bytes(&mut self) -> Result<Vec<u8>, DecodeError>
pub fn read_bytes(&mut self) -> Result<Vec<u8>, DecodeError>
Read a length-prefixed byte vector.
Sourcepub fn read_raw_bytes(&mut self, len: usize) -> Result<Vec<u8>, DecodeError>
pub fn read_raw_bytes(&mut self, len: usize) -> Result<Vec<u8>, DecodeError>
Read exactly len raw bytes with no length prefix.
Sourcepub fn enter_recursive(&mut self) -> Result<(), DecodeError>
pub fn enter_recursive(&mut self) -> Result<(), DecodeError>
Increment recursion depth; return error if limit exceeded.
Sourcepub fn leave_recursive(&mut self)
pub fn leave_recursive(&mut self)
Decrement recursion depth.
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