pub struct EncoderBuilder { /* private fields */ }Expand description
Builder for Encoder that collects LZ4 frame preferences before
constructing the streaming encoder.
Preferences correspond to the fields of upstream LZ4F_preferences_t
(see lz4frame.h). Defaults match the lz4-rs crate, not the upstream
lz4 CLI; for CLI-compatible defaults see src/bin/lz4.rs.
Implementations§
Source§impl EncoderBuilder
impl EncoderBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Returns a builder pre-populated with the same defaults used by the
lz4-rs crate (linked blocks, content + block checksums enabled,
fast-mode compression).
Sourcepub fn block_size(&mut self, block_size: BlockSize) -> &mut Self
pub fn block_size(&mut self, block_size: BlockSize) -> &mut Self
Selects the maximum block size (64 KiB, 256 KiB, 1 MiB, or 4 MiB). Larger blocks generally improve compression ratio at the cost of memory.
Sourcepub fn block_mode(&mut self, block_mode: BlockMode) -> &mut Self
pub fn block_mode(&mut self, block_mode: BlockMode) -> &mut Self
Sets whether blocks may reference data from previous blocks
(BlockMode::Linked) or must each compress independently
(BlockMode::Independent).
Sourcepub fn block_checksum(&mut self, block_checksum: BlockChecksum) -> &mut Self
pub fn block_checksum(&mut self, block_checksum: BlockChecksum) -> &mut Self
Enables or disables the per-block xxHash32 trailer that follows each compressed block.
Sourcepub fn checksum(&mut self, checksum: ContentChecksum) -> &mut Self
pub fn checksum(&mut self, checksum: ContentChecksum) -> &mut Self
Enables or disables the xxHash32 checksum of the full decompressed content that is appended to the frame footer.
Sourcepub fn level(&mut self, level: u32) -> &mut Self
pub fn level(&mut self, level: u32) -> &mut Self
Sets the compression level. 0 selects fast mode; levels 3..=12
route through HC. Levels above 12 are clamped by the underlying
implementation.
Sourcepub fn auto_flush(&mut self, auto_flush: bool) -> &mut Self
pub fn auto_flush(&mut self, auto_flush: bool) -> &mut Self
When true, every Encoder::write call is flushed to the inner
writer instead of being buffered, reducing internal memory usage at
some cost in compression ratio for small writes.
Sourcepub fn favor_dec_speed(&mut self, favor_dec_speed: bool) -> &mut Self
pub fn favor_dec_speed(&mut self, favor_dec_speed: bool) -> &mut Self
Favor decompression speed over compression ratio. Requires compression level >=10.
Sourcepub fn content_size(&mut self, content_size: u64) -> &mut Self
pub fn content_size(&mut self, content_size: u64) -> &mut Self
Records the total uncompressed content size in the frame header.
Use 0 (the default) when the size is unknown ahead of time.
Trait Implementations§
Source§impl Clone for EncoderBuilder
impl Clone for EncoderBuilder
Source§fn clone(&self) -> EncoderBuilder
fn clone(&self) -> EncoderBuilder
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more