Struct zstd::bulk::Compressor [−][src]
pub struct Compressor<'a> { /* fields omitted */ }
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
pub fn with_prepared_dictionary<'b>(
dictionary: &'a EncoderDictionary<'b>
) -> Result<Self> where
'b: 'a,
pub fn with_prepared_dictionary<'b>(
dictionary: &'a EncoderDictionary<'b>
) -> Result<Self> where
'b: 'a,
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.
pub fn set_prepared_dictionary<'b>(
&mut self,
dictionary: &'a EncoderDictionary<'b>
) -> Result<()> where
'b: 'a,
pub fn set_prepared_dictionary<'b>(
&mut self,
dictionary: &'a EncoderDictionary<'b>
) -> Result<()> where
'b: 'a,
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