pub struct CompressionDictionary { /* private fields */ }Expand description
A trained compression dictionary for Zstd.
The dictionary contains common patterns extracted from sample data, enabling much better compression for small, repetitive payloads.
Implementations§
Source§impl CompressionDictionary
impl CompressionDictionary
Sourcepub fn train(samples: &[Vec<u8>], dict_size: usize) -> Result<Self>
pub fn train(samples: &[Vec<u8>], dict_size: usize) -> Result<Self>
Train a new dictionary from sample data.
§Arguments
samples- Representative sample payloadsdict_size- Target dictionary size in bytes (default: 32KB)
§Returns
A trained dictionary, or an error if training fails.
§Example
ⓘ
let samples: Vec<Vec<u8>> = payloads.clone();
let dict = CompressionDictionary::train(&samples, 32 * 1024)?;Sourcepub fn from_bytes(data: Vec<u8>) -> Self
pub fn from_bytes(data: Vec<u8>) -> Self
Create a dictionary from raw bytes (for loading from storage).
Trait Implementations§
Source§impl Clone for CompressionDictionary
impl Clone for CompressionDictionary
Source§fn clone(&self) -> CompressionDictionary
fn clone(&self) -> CompressionDictionary
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for CompressionDictionary
impl RefUnwindSafe for CompressionDictionary
impl Send for CompressionDictionary
impl Sync for CompressionDictionary
impl Unpin for CompressionDictionary
impl UnsafeUnpin for CompressionDictionary
impl UnwindSafe for CompressionDictionary
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more