Struct q_compress::BitReader
source · [−]pub struct BitReader<'a> { /* private fields */ }
Expand description
BitReader
wraps bytes during decompression, enabling a decompressor
to read bit-level information and maintain its position in the bytes.
It does this by maintaining
- a byte index and
- a bit index from 0-8 within that byte.
The reader is consider is considered “aligned” if the current bit index is 0 or 8 (i.e. at the start or end of the current byte).
Implementations
sourceimpl<'a> BitReader<'a>
impl<'a> BitReader<'a>
sourcepub fn aligned_byte_idx(&self) -> QCompressResult<usize>
pub fn aligned_byte_idx(&self) -> QCompressResult<usize>
Returns the reader’s current byte index. Will return an error if the reader is at a misaligned position.
sourcepub fn bits_remaining(&self) -> usize
pub fn bits_remaining(&self) -> usize
Returns the number of bits between the reader’s current position and the end.
sourcepub fn read_aligned_bytes(&mut self, n: usize) -> QCompressResult<&[u8]>
pub fn read_aligned_bytes(&mut self, n: usize) -> QCompressResult<&[u8]>
Returns a slice into the next n
bytes. Will return an error if
there are not enough bytes remaining in the reader or the reader is
misaligned.
sourcepub fn read_one(&mut self) -> QCompressResult<bool>
pub fn read_one(&mut self) -> QCompressResult<bool>
Returns the next bit. Will return an error if we have reached the end of the reader.
sourcepub fn read(&mut self, n: usize) -> QCompressResult<Vec<bool>>
pub fn read(&mut self, n: usize) -> QCompressResult<Vec<bool>>
Returns the next n
bits. Will return an error if there are not
enough bits remaining.
sourcepub fn unchecked_read_one(&mut self) -> bool
pub fn unchecked_read_one(&mut self) -> bool
Returns the next bit. Will panic if we have reached the end of the
reader. This tends to be much faster than read_one()
.
Trait Implementations
Auto Trait Implementations
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> UnwindSafe for BitReader<'a>
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcepub fn borrow_mut(&mut self) -> &mut T
pub fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcepub fn to_owned(&self) -> T
pub fn to_owned(&self) -> T
Creates owned data from borrowed data, usually by cloning. Read more
sourcepub fn clone_into(&self, target: &mut T)
pub fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more