pub struct Rans64Decoder<'a> { /* private fields */ }Expand description
A symbol-at-a-time 64-bit rANS decoder.
Constructed from a byte stream produced by Rans64Encoder::finish or
encode64. Decode symbols with get, or use the
bits-back primitives peek +
advance.
Implementations§
Source§impl<'a> Rans64Decoder<'a>
impl<'a> Rans64Decoder<'a>
Sourcepub fn new(bytes: &'a [u8]) -> Result<Self, AnsError>
pub fn new(bytes: &'a [u8]) -> Result<Self, AnsError>
Initialize a 64-bit decoder from an encoded byte stream.
Returns an error if the stream is too short (< 8 bytes) or the
initial state is below RANS64_L.
Sourcepub fn get(&mut self, table: &FrequencyTable) -> Result<u32, AnsError>
pub fn get(&mut self, table: &FrequencyTable) -> Result<u32, AnsError>
Decode a single symbol from the 64-bit rANS state.
Sourcepub fn peek(&self, table: &FrequencyTable) -> u32
pub fn peek(&self, table: &FrequencyTable) -> u32
Peek at the next symbol without advancing the state.
Sourcepub fn advance(
&mut self,
sym: u32,
table: &FrequencyTable,
) -> Result<(), AnsError>
pub fn advance( &mut self, sym: u32, table: &FrequencyTable, ) -> Result<(), AnsError>
Advance the decoder state after a peek.
Sourcepub fn remaining_bytes(&self) -> usize
pub fn remaining_bytes(&self) -> usize
Number of unread bytes remaining in the buffer.
Trait Implementations§
Auto Trait Implementations§
impl<'a> Freeze for Rans64Decoder<'a>
impl<'a> RefUnwindSafe for Rans64Decoder<'a>
impl<'a> Send for Rans64Decoder<'a>
impl<'a> Sync for Rans64Decoder<'a>
impl<'a> Unpin for Rans64Decoder<'a>
impl<'a> UnsafeUnpin for Rans64Decoder<'a>
impl<'a> UnwindSafe for Rans64Decoder<'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