Skip to main content

Adaptive

Struct Adaptive 

Source
pub struct Adaptive { /* private fields */ }
Available on crate feature adaptive only.
Expand description

Network-, worker-, latency-, and content-aware compression policy.

Tracks per-bucket (Low, Medium, High) unit-byte encoding time (s/B) and wire ratio via damped EWMA, plus a shared hardware speed multiplier so a single observation calibrates relative level tables across architectures.

Implementations§

Source§

impl Adaptive

Source

pub const fn new() -> Self

Creates an instance initialized with empirically calibrated priors.

Source

pub fn choice(&self, net_speed: u64) -> Choice

Backward-compatible decision using a serial single-stream signal on the Medium bucket.

net_speed == 0 selects Level::Balanced.

Source

pub fn plan( &self, data_len: usize, bucket: ContentBucket, sig: &NetSignal, ) -> Choice

Plans compression level for data_len, bucket, and NetSignal without mutation.

Source

pub fn plan_buckets(&mut self, data_len: usize, sig: &NetSignal) -> [Choice; 3]

Pre-computes per-bucket choices ([Low, Medium, High]) for data_len and sig, advancing exploration state without inspecting payload bytes.

Source

pub fn encode_signal(&mut self, data: &[u8], sig: &NetSignal) -> Vec<u8> ⓘ

Compresses with full NetSignal control and updates the online model.

Source

pub fn encode_owned_signal(&mut self, data: Vec<u8>, sig: &NetSignal) -> Encoded

Owned zero-copy-raw path with explicit NetSignal.

Source

pub fn encode_into_signal( &mut self, data: &[u8], sig: &NetSignal, out: &mut Vec<u8>, ) -> Type

Reuses caller buffer out with explicit NetSignal.

Source

pub fn encode(&mut self, data: &[u8], net_speed: u64) -> Vec<u8> ⓘ

Serial-network shorthand calling Self::encode_signal with NetSignal::serial.

Source

pub fn encode_owned(&mut self, data: Vec<u8>, net_speed: u64) -> Encoded

Serial-network shorthand calling Self::encode_owned_signal.

Source

pub fn encode_into( &mut self, data: &[u8], net_speed: u64, out: &mut Vec<u8>, ) -> Type

Serial-network shorthand calling Self::encode_into_signal.

Source

pub fn observe_bucket( &mut self, level: Level, bucket: ContentBucket, raw_len: usize, wire_len: usize, elapsed_ns: u64, )

Records a completed compression observation for a specific ContentBucket.

Source

pub fn observe(&mut self, level: Level, speed: f64, ratio: f64)

Records an external (speed_bps, ratio) measurement onto the default Medium bucket.

Source

pub fn stats(&self) -> [Stat; 8]

Current estimates summed across buckets (reporting the dominant sampled bucket’s calibrated speed and ratio) ordered as Level::ALL.

Source

pub fn bucket_stats(&self, bucket: ContentBucket) -> [Stat; 8]

Current estimates for a specific ContentBucket.

Trait Implementations§

Source§

impl Clone for Adaptive

Source§

fn clone(&self) -> Self

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 Debug for Adaptive

Source§

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

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

impl Default for Adaptive

Source§

fn default() -> Self

Returns the “default value” for a type. 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> 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.