Skip to main content

RansDecoderStream

Struct RansDecoderStream 

Source
pub struct RansDecoderStream<S: EncoderVariantForS> { /* private fields */ }
Expand description

rANS decoder stream for a specific variant S.

Owns the encoded data and keeps a persistent decode cursor (unit position + rANS state) across sequential decode calls. This matches Microsoft’s RansDecoderStream, where the raw decoder is initialized once in Open() and reused by every Decode call.

Implementations§

Source§

impl<S: EncoderVariantForS> RansDecoderStream<S>

Source

pub fn new() -> Self

Create a decoder stream (closed).

Source

pub fn open_on(data: &[u8]) -> Self

Create a decoder stream opened on the given data.

Source

pub fn is_open(&self) -> bool

Whether the stream is open (has data).

Source

pub fn check_eof(&self) -> bool

Whether the current state can be at EOF.

EOF requires the source to be exhausted and the decoder state to be at LowerBound (or the stream to be unopened).

Source

pub fn open(&mut self, data: &[u8])

Open the stream on new data, resetting the cursor.

Source

pub fn close(&mut self)

Close the stream, releasing data.

Source

pub fn decode_eof(&mut self) -> Result<(), EntropyError>

Check that decoding reached the end of the message and close on success.

Source

pub fn decode( &mut self, decoder: &EntropyDecoder<S>, values: &mut [i32], indices: &[i32], ) -> Result<(), EntropyError>

Decode a batch of symbols from the stream, advancing the persistent cursor.

The first call initializes the raw decoder from the stream’s initial state; subsequent calls continue from the saved cursor.

Source

pub fn bytes_consumed(&self) -> usize

Number of bytes consumed so far (unit position × unit size).

Source

pub fn data(&self) -> &[u8]

The full stream data (borrowed).

Trait Implementations§

Source§

impl<S: Debug + EncoderVariantForS> Debug for RansDecoderStream<S>

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<S: EncoderVariantForS> Default for RansDecoderStream<S>

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<S> Freeze for RansDecoderStream<S>

§

impl<S> RefUnwindSafe for RansDecoderStream<S>
where S: RefUnwindSafe,

§

impl<S> Send for RansDecoderStream<S>
where S: Send,

§

impl<S> Sync for RansDecoderStream<S>
where S: Sync,

§

impl<S> Unpin for RansDecoderStream<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for RansDecoderStream<S>

§

impl<S> UnwindSafe for RansDecoderStream<S>
where S: UnwindSafe,

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.