pub struct ZstdCompressor { /* private fields */ }Expand description
Zstandard compressor.
Supports custom FSE tables for sequence encoding via with_custom_tables()
and custom Huffman tables for literals via with_custom_huffman().
§Example
use haagenti_zstd::{ZstdCompressor, CustomFseTables};
use haagenti_core::Compressor;
// Using predefined tables (default)
let compressor = ZstdCompressor::new();
let compressed = compressor.compress(b"Hello, World!").unwrap();
// Using custom FSE tables
let custom_tables = CustomFseTables::new();
let compressor = ZstdCompressor::with_custom_tables(custom_tables);Implementations§
Source§impl ZstdCompressor
impl ZstdCompressor
Sourcepub fn with_level(level: CompressionLevel) -> Self
pub fn with_level(level: CompressionLevel) -> Self
Create with compression level.
Sourcepub fn with_custom_tables(custom_tables: CustomFseTables) -> Self
pub fn with_custom_tables(custom_tables: CustomFseTables) -> Self
Create with custom FSE tables.
Custom tables override the predefined FSE tables used for sequence encoding.
Tables can be built from symbol distributions using FseTable::from_predefined().
§Performance Note
When using custom tables, the bitstream will include the table description in the mode byte, adding some overhead. Use custom tables when:
- The data has symbol distributions that differ significantly from predefined
- Better compression ratio is worth the table overhead
Sourcepub fn with_custom_huffman(custom_huffman: CustomHuffmanTable) -> Self
pub fn with_custom_huffman(custom_huffman: CustomHuffmanTable) -> Self
Create with custom Huffman table for literals.
Custom Huffman tables allow using pre-trained encoders for literal compression. This can improve compression when the data has known byte distributions.
Sourcepub fn with_level_and_tables(
level: CompressionLevel,
custom_tables: CustomFseTables,
) -> Self
pub fn with_level_and_tables( level: CompressionLevel, custom_tables: CustomFseTables, ) -> Self
Create with both compression level and custom FSE tables.
Sourcepub fn with_all_options(
level: CompressionLevel,
custom_tables: Option<CustomFseTables>,
custom_huffman: Option<CustomHuffmanTable>,
) -> Self
pub fn with_all_options( level: CompressionLevel, custom_tables: Option<CustomFseTables>, custom_huffman: Option<CustomHuffmanTable>, ) -> Self
Create with all custom options.
Sourcepub fn custom_tables(&self) -> Option<&CustomFseTables>
pub fn custom_tables(&self) -> Option<&CustomFseTables>
Get the custom FSE tables, if any.
Sourcepub fn custom_huffman(&self) -> Option<&CustomHuffmanTable>
pub fn custom_huffman(&self) -> Option<&CustomHuffmanTable>
Get the custom Huffman table, if any.
Trait Implementations§
Source§impl Clone for ZstdCompressor
impl Clone for ZstdCompressor
Source§fn clone(&self) -> ZstdCompressor
fn clone(&self) -> ZstdCompressor
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more