pub struct CompressionResult {
pub data: String,
pub algorithm: Algorithm,
pub original_bytes: usize,
pub compressed_bytes: usize,
pub original_tokens: Option<usize>,
pub compressed_tokens: Option<usize>,
}Expand description
Result of compression operation
Fields§
§data: StringCompressed data (wire format)
algorithm: AlgorithmAlgorithm used
original_bytes: usizeOriginal size in bytes
compressed_bytes: usizeCompressed size in bytes
original_tokens: Option<usize>Original token count (if available)
compressed_tokens: Option<usize>Compressed token count (if available)
Implementations§
Source§impl CompressionResult
impl CompressionResult
Sourcepub fn new(
data: String,
algorithm: Algorithm,
original_bytes: usize,
compressed_bytes: usize,
) -> Self
pub fn new( data: String, algorithm: Algorithm, original_bytes: usize, compressed_bytes: usize, ) -> Self
Create new compression result
Sourcepub fn with_tokens(self, original: usize, compressed: usize) -> Self
pub fn with_tokens(self, original: usize, compressed: usize) -> Self
Set token counts
Sourcepub fn byte_ratio(&self) -> f64
pub fn byte_ratio(&self) -> f64
Calculate byte compression ratio
Sourcepub fn token_savings_percent(&self) -> Option<f64>
pub fn token_savings_percent(&self) -> Option<f64>
Calculate token savings percentage
Sourcepub fn is_beneficial(&self) -> bool
pub fn is_beneficial(&self) -> bool
Check if compression was beneficial
Trait Implementations§
Source§impl Clone for CompressionResult
impl Clone for CompressionResult
Source§fn clone(&self) -> CompressionResult
fn clone(&self) -> CompressionResult
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 CompressionResult
impl RefUnwindSafe for CompressionResult
impl Send for CompressionResult
impl Sync for CompressionResult
impl Unpin for CompressionResult
impl UnwindSafe for CompressionResult
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