pub struct ReverseBitReader<'a> {
pub data: &'a [u8],
pub container: u64,
pub bits_consumed: u32,
pub ptr: usize,
pub limit_ptr: usize,
}Expand description
Reverse bitstream reader using C zstd’s bitsConsumed model.
Instead of tracking bits_available (decrement on consume, increment on refill),
this tracks bits_consumed (increment on consume, reset on reload). Peek uses
a double-shift: (container << consumed) >> (64 - n) = 2 ops vs the old model’s
3 ops (shift + mask + subtract).
Fields§
§data: &'a [u8]§container: u64§bits_consumed: u32§ptr: usize§limit_ptr: usizeImplementations§
Source§impl<'a> ReverseBitReader<'a>
impl<'a> ReverseBitReader<'a>
pub fn new(data: &'a [u8]) -> Result<Self, DecompressError>
pub fn refill(&mut self)
pub fn read_bits(&mut self, n: u8) -> Result<u32, DecompressError>
pub fn read_bits_unchecked(&mut self, n: u8) -> u32
pub fn consume_bits(&mut self, n: u8)
pub fn read_bits_fast(&mut self, n: u8) -> u32
pub fn read_bits_branchless(&mut self, n: u8) -> u32
pub fn refill_fast(&mut self)
pub fn peek_bits(&self, n: u8) -> u32
pub fn bits_remaining(&self) -> usize
pub fn is_empty(&self) -> bool
Auto Trait Implementations§
impl<'a> Freeze for ReverseBitReader<'a>
impl<'a> RefUnwindSafe for ReverseBitReader<'a>
impl<'a> Send for ReverseBitReader<'a>
impl<'a> Sync for ReverseBitReader<'a>
impl<'a> Unpin for ReverseBitReader<'a>
impl<'a> UnsafeUnpin for ReverseBitReader<'a>
impl<'a> UnwindSafe for ReverseBitReader<'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