pub struct BitReader<R: Read, E: Endianness> { /* private fields */ }Implementations§
Source§impl<R: Read, E: Endianness> BitReader<R, E>
impl<R: Read, E: Endianness> BitReader<R, E>
Sourcepub fn read<const BITS: u32, T: Integer>(&mut self) -> Result<T>
pub fn read<const BITS: u32, T: Integer>(&mut self) -> Result<T>
Reads up to BITS bits as a value of type T
Sourcepub fn read_var<T: Integer>(&mut self, bits: u32) -> Result<T>
pub fn read_var<T: Integer>(&mut self, bits: u32) -> Result<T>
Reads bits number of bits as a value of type T
Sourcepub fn byte_aligned(&self) -> bool
pub fn byte_aligned(&self) -> bool
Returns true if the stream is byte-aligned
Sourcepub fn byte_align(&mut self)
pub fn byte_align(&mut self)
Discards any remaining bits until the stream is byte-aligned
Sourcepub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()>
pub fn read_bytes(&mut self, buf: &mut [u8]) -> Result<()>
Reads exactly buf.len() bytes into the buffer
Sourcepub fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>>
pub fn read_to_vec(&mut self, bytes: usize) -> Result<Vec<u8>>
Reads bytes number of bytes into a vector
Sourcepub fn read_unary<const STOP_BIT: u8>(&mut self) -> Result<u32>
pub fn read_unary<const STOP_BIT: u8>(&mut self) -> Result<u32>
Reads bits until a stop bit is encountered
Source§impl<'a, E: Endianness> BitReader<Cursor<&'a [u8]>, E>
impl<'a, E: Endianness> BitReader<Cursor<&'a [u8]>, E>
Sourcepub fn from_slice(data: &'a [u8]) -> Self
pub fn from_slice(data: &'a [u8]) -> Self
Create a BitReader from a byte slice, automatically tracking length
Sourcepub fn remaining_slice(&mut self) -> &'a [u8] ⓘ
pub fn remaining_slice(&mut self) -> &'a [u8] ⓘ
Get the remaining data as a byte-aligned slice
Source§impl<R: Read + Seek, E: Endianness> BitReader<R, E>
impl<R: Read + Seek, E: Endianness> BitReader<R, E>
Sourcepub fn position_in_bits(&mut self) -> Result<u64>
pub fn position_in_bits(&mut self) -> Result<u64>
Gets the current position in bits from the start of the stream
Sourcepub fn seek_bits(&mut self, from: SeekFrom) -> Result<u64>
pub fn seek_bits(&mut self, from: SeekFrom) -> Result<u64>
Seeks to a position in the stream by bits
Sourcepub fn peek<const BITS: u32, T: Integer>(&mut self) -> Result<T>
pub fn peek<const BITS: u32, T: Integer>(&mut self) -> Result<T>
Peeks the next BITS bits without consuming them
Auto Trait Implementations§
impl<R, E> Freeze for BitReader<R, E>where
R: Freeze,
impl<R, E> RefUnwindSafe for BitReader<R, E>where
R: RefUnwindSafe,
E: RefUnwindSafe,
impl<R, E> Send for BitReader<R, E>
impl<R, E> Sync for BitReader<R, E>
impl<R, E> Unpin for BitReader<R, E>
impl<R, E> UnsafeUnpin for BitReader<R, E>where
R: UnsafeUnpin,
impl<R, E> UnwindSafe for BitReader<R, E>where
R: UnwindSafe,
E: UnwindSafe,
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