pub struct Compressor<'a> { /* private fields */ }
Expand description

Allows to compress independently multiple chunks of data.

Each job will be processed entirely in-memory without streaming, so this is most fitting for many small jobs. To compress larger volume that don’t easily fit in memory, a streaming compression may be more appropriate.

It is more efficient than a streaming compressor for 2 reasons:

  • It re-uses the zstd context between jobs to avoid re-allocations
  • It avoids copying data from a Read into a temporary buffer before compression.

Implementations

Creates a new zstd compressor

Creates a new zstd compressor, using the given dictionary.

Note that using a dictionary means that decompression will need to use the same dictionary.

Creates a new compressor using an existing EncoderDictionary.

The compression level will be the one specified when creating the dictionary.

Note that using a dictionary means that decompression will need to use the same dictionary.

Changes the compression level used by this compressor.

This will clear any dictionary previously registered.

If you want to keep the existing dictionary, you will need to pass it again to Self::set_dictionary instead of using this method.

Changes the dictionary and compression level used by this compressor.

Will affect future compression jobs.

Note that using a dictionary means that decompression will need to use the same dictionary.

Changes the dictionary used by this compressor.

The compression level used when preparing the dictionary will be used.

Note that using a dictionary means that decompression will need to use the same dictionary.

Compress a single block of data to the given destination buffer.

Returns the number of bytes written, or an error if something happened (for instance if the destination buffer was too small).

A level of 0 uses zstd’s default (currently 3).

Compresses a block of data and returns the compressed result.

A level of 0 uses zstd’s default (currently 3).

Gives mutable access to the internal context.

Sets a compression parameter for this compressor.

Controls whether zstd should include a content checksum at the end of each frame.

Enables or disables storing of the dict id.

Defaults to true. If false, the behaviour of decoding with a wrong dictionary is undefined.

Enables or disabled storing of the contentsize.

Note that this only has an effect if the size is given with set_pledged_src_size.

Enables or disables long-distance matching

Sets the maximum back-reference distance.

The actual maximum distance is going to be 2^log_distance.

Note that decompression will need to use at least the same setting.

Trait Implementations

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.