pub struct ZstdEncoder { /* private fields */ }Expand description
Zstandard encoder.
Supports multiple compression levels (0-22) with LZ77 matching, Huffman literal encoding, and FSE sequence encoding.
Supports optional progress reporting via ProgressHandle and
cooperative cancellation via CancellationToken using the
ZstdEncoder::with_progress / ZstdEncoder::with_cancel builders.
Implementations§
Source§impl ZstdEncoder
impl ZstdEncoder
Sourcepub fn with_progress(self, handle: ProgressHandle) -> Self
pub fn with_progress(self, handle: ProgressHandle) -> Self
Attach a progress sink.
The sink’s on_progress(bytes_processed, None) is called after each
block is written to the output. on_finish() is called after the
content checksum is written.
Sourcepub fn with_cancel(self, token: CancellationToken) -> Self
pub fn with_cancel(self, token: CancellationToken) -> Self
Attach a cancellation token.
The token is checked before each block is encoded.
If cancelled, returns oxiarc_core::error::OxiArcError::Cancelled.
Sourcepub fn set_checksum(&mut self, include: bool) -> &mut Self
pub fn set_checksum(&mut self, include: bool) -> &mut Self
Set whether to include content checksum.
Sourcepub fn set_content_size(&mut self, include: bool) -> &mut Self
pub fn set_content_size(&mut self, include: bool) -> &mut Self
Set whether to include content size in header.
Sourcepub fn set_strategy(&mut self, strategy: CompressionStrategy) -> &mut Self
pub fn set_strategy(&mut self, strategy: CompressionStrategy) -> &mut Self
Set compression strategy (only effective when level == 0).
Sourcepub fn set_level(&mut self, level: i32) -> &mut Self
pub fn set_level(&mut self, level: i32) -> &mut Self
Set compression level (0-22).
- Level 0: Raw/RLE blocks (fastest, no compression)
- Levels 1-3: Fast compression (greedy matching)
- Levels 4-9: Balanced compression (lazy matching)
- Levels 10-22: High compression (deep search)
Sourcepub fn set_dictionary(&mut self, dict: &[u8]) -> &mut Self
pub fn set_dictionary(&mut self, dict: &[u8]) -> &mut Self
Set a pre-trained dictionary for improved compression of small data.
Trait Implementations§
Source§impl Clone for ZstdEncoder
impl Clone for ZstdEncoder
Source§fn clone(&self) -> ZstdEncoder
fn clone(&self) -> ZstdEncoder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more