Struct Decompressor

struct Decompressor<'a> { ... }

Allows to decompress independently multiple blocks of data.

This reduces memory usage compared to calling decompress multiple times.

Implementations

impl Decompressor<'static>

fn new() -> Result<Self>

Creates a new zstd decompressor.

fn with_dictionary(dictionary: &[u8]) -> Result<Self>

Creates a new zstd decompressor, using the given dictionary.

impl<'a> Decompressor<'a>

fn with_prepared_dictionary<'b>(dictionary: &'a DecoderDictionary<'b>) -> Result<Self>
where
    'b: 'a

Creates a new decompressor using an existing DecoderDictionary.

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

fn set_dictionary(self: &mut Self, dictionary: &[u8]) -> Result<()>

Changes the dictionary used by this decompressor.

Will affect future compression jobs.

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

fn set_prepared_dictionary<'b>(self: &mut Self, dictionary: &'a DecoderDictionary<'b>) -> Result<()>
where
    'b: 'a

Changes the dictionary used by this decompressor.

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

fn decompress_to_buffer<C: zstd_safe::WriteBuf + ?Sized>(self: &mut Self, source: &[u8], destination: &mut C) -> Result<usize>

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

fn decompress(self: &mut Self, data: &[u8], capacity: usize) -> Result<Vec<u8>>

Decompress a block of data, and return the result in a Vec<u8>.

The decompressed data should be at most capacity bytes, or an error will be returned.

fn set_parameter(self: &mut Self, parameter: DParameter) -> Result<()>

Sets a decompression parameter for this decompressor.

fn window_log_max(self: &mut Self, log_distance: u32) -> Result<()>

Sets the maximum back-reference distance.

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

This will need to at least match the value set when compressing.

fn upper_bound(_data: &[u8]) -> Option<usize>

Get an upper bound on the decompressed size of data, if available

This can be used to pre-allocate enough capacity for decompress_to_buffer and is used by decompress to ensure that it does not over-allocate if you supply a large capacity.

Will return None if the upper bound cannot be determined or is larger than usize::MAX

Note that unless the experimental feature is enabled, this will always return None.

impl<'a> Default for Decompressor<'a>

fn default() -> Decompressor<'a>

impl<'a> Freeze for Decompressor<'a>

impl<'a> RefUnwindSafe for Decompressor<'a>

impl<'a> Send for Decompressor<'a>

impl<'a> Sync for Decompressor<'a>

impl<'a> Unpin for Decompressor<'a>

impl<'a> UnsafeUnpin for Decompressor<'a>

impl<'a> UnwindSafe for Decompressor<'a>

impl<T> Any for Decompressor<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for Decompressor<'a>

fn borrow(self: &Self) -> &T

impl<T> BorrowMut for Decompressor<'a>

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

impl<T> From for Decompressor<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for Decompressor<'a>

fn into(self: Self) -> U

Calls U::from(self).

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

impl<T, U> TryFrom for Decompressor<'a>

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

impl<T, U> TryInto for Decompressor<'a>

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