Skip to main content

Encoder

Struct Encoder 

Source
pub struct Encoder<F: AlpFloat> {
    pub cached_params: Option<BestParams>,
    pub cached_use_repeat: Option<bool>,
    pub cached_scheme: Option<CachedScheme>,
    pub cached_target_bw: CachedTargetBw,
    pub cached_use_delta: Option<bool>,
    /* private fields */
}
Expand description

Stateful encoder that caches optimal parameters and scratch buffers across adjacent chunks. 状态化编码器:在连续数据块编码时复用已探测的最优参数与内部工作缓冲区,消除重复采样开销与内存分配。

Fields§

§cached_params: Option<BestParams>§cached_use_repeat: Option<bool>§cached_scheme: Option<CachedScheme>§cached_target_bw: CachedTargetBw§cached_use_delta: Option<bool>

Implementations§

Source§

impl<F: AlpFloat> Encoder<F>

Source

pub const fn new() -> Self

Creates a new encoder (empty buffers, dynamically allocated on demand and reused). 创建新的编码器(空缓冲区,按需动态分配并长久复用)

Source

pub fn with_capacity(capacity: usize) -> Self

Creates an encoder with specified initial capacity (pre-allocated buffers for zero heap allocation). 创建具有指定初始容量的编码器(预分配缓冲区,实现全程零堆分配)

Source

pub fn reset(&mut self)

Resets cached optimal parameters and clears internal buffers. 重置已缓存的最优参数与内部缓冲区

Source

pub fn compress_into(&mut self, data: &[F], dst: &mut Vec<u8>)

Compresses float data slice into destination buffer (adaptive FOR/Delta, reusing parameters and memory). 压缩浮点数据切片并写入目标缓冲区(自适应 FOR 或 Delta 模式,复用采样参数与工作内存)

Source

pub fn compress_delta_into(&mut self, data: &[F], dst: &mut Vec<u8>)

Compresses float data slice using Delta differential mode into destination buffer. 强制使用 Delta 差分模式压缩浮点数据切片并写入目标缓冲区

Source

pub fn compress(&mut self, data: &[F]) -> Vec<u8>

Compresses float data slice and returns newly allocated byte vector. 压缩浮点数据切片并返回新分配的字节向量

Source

pub fn compress_delta(&mut self, data: &[F]) -> Vec<u8>

Compresses float data slice using Delta differential mode and returns newly allocated byte vector. 强制使用 Delta 差分模式压缩浮点数据切片并返回新分配的字节向量

Source

pub fn shrink_to_fit(&mut self)

Shrinks the capacity of the internal work buffer as much as possible. 释放内部工作缓冲区多余分配的容量

Source

pub fn capacity(&self) -> usize

Returns the current capacity of the internal work buffer. 获取内部工作缓冲区的当前容量

Trait Implementations§

Source§

impl<F: Clone + AlpFloat> Clone for Encoder<F>
where F::Int: Clone, F::RawBits: Clone,

Source§

fn clone(&self) -> Encoder<F>

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<F: Debug + AlpFloat> Debug for Encoder<F>
where F::Int: Debug, F::RawBits: Debug,

Source§

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

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

impl<F: AlpFloat> Default for Encoder<F>

Source§

fn default() -> Self

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

Auto Trait Implementations§

§

impl<F> Freeze for Encoder<F>
where Option<DictCandidate<F>>: Freeze, Vec<<F as AlpFloat>::Int>: Freeze, Vec<Exception<<F as AlpFloat>::RawBits>>: Freeze, Vec<F>: Freeze,

§

impl<F> RefUnwindSafe for Encoder<F>
where Option<DictCandidate<F>>: RefUnwindSafe, Vec<<F as AlpFloat>::Int>: RefUnwindSafe, Vec<Exception<<F as AlpFloat>::RawBits>>: RefUnwindSafe, Vec<F>: RefUnwindSafe,

§

impl<F> Send for Encoder<F>
where Option<DictCandidate<F>>: Send, Vec<<F as AlpFloat>::Int>: Send, Vec<Exception<<F as AlpFloat>::RawBits>>: Send, Vec<F>: Send,

§

impl<F> Sync for Encoder<F>
where Option<DictCandidate<F>>: Sync, Vec<<F as AlpFloat>::Int>: Sync, Vec<Exception<<F as AlpFloat>::RawBits>>: Sync, Vec<F>: Sync,

§

impl<F> Unpin for Encoder<F>
where Option<DictCandidate<F>>: Unpin, Vec<<F as AlpFloat>::Int>: Unpin, Vec<Exception<<F as AlpFloat>::RawBits>>: Unpin, Vec<F>: Unpin,

§

impl<F> UnsafeUnpin for Encoder<F>
where Option<DictCandidate<F>>: UnsafeUnpin, Vec<<F as AlpFloat>::Int>: UnsafeUnpin, Vec<Exception<<F as AlpFloat>::RawBits>>: UnsafeUnpin, Vec<F>: UnsafeUnpin,

§

impl<F> UnwindSafe for Encoder<F>
where Option<DictCandidate<F>>: UnwindSafe, Vec<<F as AlpFloat>::Int>: UnwindSafe, Vec<Exception<<F as AlpFloat>::RawBits>>: UnwindSafe, Vec<F>: 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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, S> SimdFrom<T, S> for T
where S: Simd,

Source§

fn simd_from(_simd: S, value: T) -> T

Source§

impl<F, T, S> SimdInto<T, S> for F
where T: SimdFrom<F, S>, S: Simd,

Source§

fn simd_into(self, simd: S) -> T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.