Skip to main content

EncoderBuilder

Struct EncoderBuilder 

Source
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

Source

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).

Source

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.

Source

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).

Source

pub fn block_checksum(&mut self, block_checksum: BlockChecksum) -> &mut Self

Enables or disables the per-block xxHash32 trailer that follows each compressed block.

Source

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.

Source

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.

Source

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.

Source

pub fn favor_dec_speed(&mut self, favor_dec_speed: bool) -> &mut Self

Favor decompression speed over compression ratio. Requires compression level >=10.

Source

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.

Source

pub fn build<W: Write>(&self, w: W) -> Result<Encoder<W>>

Consumes the builder, allocates an LZ4 frame compression context, writes the frame header into w, and returns the resulting streaming encoder.

Trait Implementations§

Source§

impl Clone for EncoderBuilder

Source§

fn clone(&self) -> EncoderBuilder

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for EncoderBuilder

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for EncoderBuilder

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.