pub struct TierCompressor { /* private fields */ }Expand description
Symmetric compressor/decompressor for cache tier entries.
Instantiate once and reuse for many compress/decompress calls.
Implementations§
Source§impl TierCompressor
impl TierCompressor
Sourcepub fn new(level: u8) -> Self
pub fn new(level: u8) -> Self
Create a new TierCompressor at the given level (0–3; values above 3
are treated as level 3).
Sourcepub fn compress(&self, input: &[u8]) -> Result<Vec<u8>, CompressorError>
pub fn compress(&self, input: &[u8]) -> Result<Vec<u8>, CompressorError>
Compress input and return the compressed bytes.
The compressed bytes include a header that encodes the original length;
pass them directly to [decompress] to recover the original.
Sourcepub fn decompress(&self, input: &[u8]) -> Result<Vec<u8>, CompressorError>
pub fn decompress(&self, input: &[u8]) -> Result<Vec<u8>, CompressorError>
Decompress bytes previously produced by [compress].
Sourcepub fn compression_ratio(&self, input: &[u8]) -> Result<f64, CompressorError>
pub fn compression_ratio(&self, input: &[u8]) -> Result<f64, CompressorError>
Compress input and report the compression ratio (compressed / original).
Returns 1.0 for empty inputs.
Trait Implementations§
Source§impl Clone for TierCompressor
impl Clone for TierCompressor
Source§fn clone(&self) -> TierCompressor
fn clone(&self) -> TierCompressor
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 TierCompressor
impl RefUnwindSafe for TierCompressor
impl Send for TierCompressor
impl Sync for TierCompressor
impl Unpin for TierCompressor
impl UnsafeUnpin for TierCompressor
impl UnwindSafe for TierCompressor
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