Skip to main content

Rans64Decoder

Struct Rans64Decoder 

Source
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>

Source

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.

Source

pub fn get(&mut self, table: &FrequencyTable) -> Result<u32, AnsError>

Decode a single symbol from the 64-bit rANS state.

Source

pub fn peek(&self, table: &FrequencyTable) -> u32

Peek at the next symbol without advancing the state.

Source

pub fn advance( &mut self, sym: u32, table: &FrequencyTable, ) -> Result<(), AnsError>

Advance the decoder state after a peek.

Source

pub fn state(&self) -> u64

Current rANS state (for bits-back interleaving).

Source

pub fn remaining_bytes(&self) -> usize

Number of unread bytes remaining in the buffer.

Trait Implementations§

Source§

impl<'a> Debug for Rans64Decoder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.