pub struct CompressionConfig {
pub algorithm: CompressionAlgorithm,
pub level: CompressionLevel,
pub dictionary: Option<Vec<u8>>,
pub window_size: Option<u32>,
pub parallel_processing: bool,
}Expand description
Compression configuration that encapsulates all parameters for compression operations
This configuration struct provides comprehensive control over compression behavior, allowing fine-tuning of compression parameters for optimal performance in different scenarios. The configuration is immutable and thread-safe.
§Configuration Parameters
- Algorithm: The compression algorithm to use
- Level: Compression level balancing speed vs. ratio
- Dictionary: Optional pre-trained dictionary for better compression
- Window Size: Sliding window size for compression algorithms
- Parallel Processing: Enable multi-threaded compression when supported
§Examples
§Performance Considerations
- Dictionary: Pre-trained dictionaries can significantly improve compression ratios for similar data patterns but require additional memory
- Window Size: Larger windows generally improve compression but use more memory
- Parallel Processing: Can improve throughput on multi-core systems but may increase memory usage and complexity
Fields§
§algorithm: CompressionAlgorithmThe compression algorithm to use for processing
level: CompressionLevelCompression level balancing speed vs. compression ratio
dictionary: Option<Vec<u8>>Optional pre-trained dictionary for improved compression of similar data
window_size: Option<u32>Optional sliding window size for compression algorithms (algorithm-specific)
parallel_processing: boolEnable parallel processing for supported algorithms
Implementations§
Source§impl CompressionConfig
impl CompressionConfig
Sourcepub fn new(algorithm: CompressionAlgorithm) -> Self
pub fn new(algorithm: CompressionAlgorithm) -> Self
Creates a new compression configuration
Sourcepub fn with_level(self, level: CompressionLevel) -> Self
pub fn with_level(self, level: CompressionLevel) -> Self
Sets compression level
Sourcepub fn with_dictionary(self, dictionary: Vec<u8>) -> Self
pub fn with_dictionary(self, dictionary: Vec<u8>) -> Self
Sets dictionary
Sourcepub fn with_window_size(self, size: u32) -> Self
pub fn with_window_size(self, size: u32) -> Self
Sets window size
Sourcepub fn with_parallel_processing(self, enabled: bool) -> Self
pub fn with_parallel_processing(self, enabled: bool) -> Self
Sets parallel processing
Sourcepub fn for_speed(algorithm: CompressionAlgorithm) -> Self
pub fn for_speed(algorithm: CompressionAlgorithm) -> Self
Creates a speed-optimized configuration
Sourcepub fn for_ratio(algorithm: CompressionAlgorithm) -> Self
pub fn for_ratio(algorithm: CompressionAlgorithm) -> Self
Creates a ratio-optimized configuration
Trait Implementations§
Source§impl Clone for CompressionConfig
impl Clone for CompressionConfig
Source§fn clone(&self) -> CompressionConfig
fn clone(&self) -> CompressionConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for CompressionConfig
impl Debug for CompressionConfig
Source§impl Default for CompressionConfig
impl Default for CompressionConfig
Source§impl FromParameters for CompressionConfig
Implementation of FromParameters for type-safe config extraction.
impl FromParameters for CompressionConfig
Implementation of FromParameters for type-safe config extraction.
This implementation converts StageConfiguration.parameters HashMap
into a typed CompressionConfig object.
§Expected Parameters
-
algorithm (required): Compression algorithm name
- Valid values: “brotli”, “gzip”, “zstd”, “lz4”
- Example:
"algorithm" => "brotli"
-
level (optional): Compression level (1-19 depending on algorithm)
- Default: 6 (balanced)
- Example:
"level" => "9"
-
parallel_processing (optional): Enable parallel compression
- Valid values: “true”, “false”
- Default: false
- Example:
"parallel_processing" => "true"
§Usage Example
use adaptive_pipeline_domain::services::{CompressionConfig, FromParameters};
use std::collections::HashMap;
let mut params = HashMap::new();
params.insert("algorithm".to_string(), "brotli".to_string());
params.insert("level".to_string(), "9".to_string());
let config = CompressionConfig::from_parameters(¶ms).unwrap();Source§fn from_parameters(
params: &HashMap<String, String>,
) -> Result<Self, PipelineError>
fn from_parameters( params: &HashMap<String, String>, ) -> Result<Self, PipelineError>
Auto Trait Implementations§
impl Freeze for CompressionConfig
impl RefUnwindSafe for CompressionConfig
impl Send for CompressionConfig
impl Sync for CompressionConfig
impl Unpin for CompressionConfig
impl UnwindSafe for CompressionConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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