Skip to main content

InterleavedTansEncoder

Struct InterleavedTansEncoder 

Source
pub struct InterleavedTansEncoder { /* private fields */ }
Expand description

Interleaved tANS encoder for Zstd sequences (LL, OF, ML).

Implementations§

Source§

impl InterleavedTansEncoder

Source

pub fn new( ll_table: &FseTable, of_table: &FseTable, ml_table: &FseTable, ) -> Self

Create encoder from three FSE tables.

Note: For predefined tables, prefer new_predefined() which uses cached encoders for better performance.

Source

pub fn new_predefined() -> Self

Create encoder using cached predefined tANS encoders.

This is the fast path for encoding with predefined FSE tables. Cloning cached encoders is much faster than building from scratch.

Source

pub fn from_encoders( ll_encoder: TansEncoder, of_encoder: TansEncoder, ml_encoder: TansEncoder, ) -> Self

Create encoder from pre-built tANS encoders.

This allows using custom FSE tables by building encoders separately.

Source

pub fn init_states(&mut self, ll: u8, of: u8, ml: u8)

Initialize all three encoders with their first symbols.

These should be the LAST symbols in the sequence (encoding is reversed).

Source

pub fn encode_sequence(&mut self, ll: u8, of: u8, ml: u8) -> [(u32, u8); 3]

Encode one sequence (LL, OF, ML) and return bits for each.

Returns [(ll_bits, ll_nbits), (of_bits, of_nbits), (ml_bits, ml_nbits)]

Note: tANS encoding order matters! We encode in reverse of decode order. Decoder reads FSE updates: LL, ML, OF So we encode: OF, ML, LL (reverse order for correct state transitions)

Source

pub fn get_states(&self) -> (u32, u32, u32)

Get final states for all three encoders.

These become the decoder’s initial states.

Source

pub fn accuracy_logs(&self) -> (u8, u8, u8)

Get accuracy logs for all three encoders.

Source

pub fn reset(&mut self)

Reset all encoders.

Trait Implementations§

Source§

impl Debug for InterleavedTansEncoder

Source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

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.