Struct DCtx

struct DCtx<'a>(_, _)

A Decompression Context.

The lifetime references the potential dictionary used for this context.

If no dictionary was used, it will most likely be 'static.

Same as DStream.

Implementations

impl<'a> DCtx<'a>

fn try_create() -> Option<Self>

Try to create a new decompression context.

Returns None if the operation failed (for example, not enough memory).

fn create() -> Self

Creates a new decoding context.

Panics

If the context creation fails.

fn decompress<C: WriteBuf + ?Sized>(self: &mut Self, dst: &mut C, src: &[u8]) -> SafeResult

Fully decompress the given frame.

This decompress an entire frame in-memory. If you can have enough memory to store both the input and output buffer, then it may be faster that streaming decompression.

Wraps the ZSTD_decompressDCtx() function.

fn decompress_using_dict<C: WriteBuf + ?Sized>(self: &mut Self, dst: &mut C, src: &[u8], dict: &[u8]) -> SafeResult

Fully decompress the given frame using a dictionary.

Dictionary must be identical to the one used during compression.

If you plan on using the same dictionary multiple times, it is faster to create a DDict first and use decompress_using_ddict.

Wraps ZSTD_decompress_usingDict

fn decompress_using_ddict<C: WriteBuf + ?Sized>(self: &mut Self, dst: &mut C, src: &[u8], ddict: &DDict<'_>) -> SafeResult

Fully decompress the given frame using a dictionary.

Dictionary must be identical to the one used during compression.

Wraps the ZSTD_decompress_usingDDict() function.

fn init(self: &mut Self) -> SafeResult

Initializes an existing DStream for decompression.

This is equivalent to calling:

  • reset(SessionOnly)
  • disable_dictionary()

Wraps the ZSTD_initCStream() function.

fn reset(self: &mut Self, reset: ResetDirective) -> SafeResult

Resets the state of the context.

Depending on the reset mode, it can reset the session, the parameters, or both.

Wraps the ZSTD_DCtx_reset() function.

fn load_dictionary(self: &mut Self, dict: &[u8]) -> SafeResult

Loads a dictionary.

This will let this context decompress frames that were compressed using this dictionary.

The dictionary content will be copied internally and does not need to be kept alive after calling this function.

If you need to use the same dictionary for multiple contexts, it may be more efficient to create a DDict first, then loads that.

The dictionary will apply to all future frames, until a new dictionary is set.

fn disable_dictionary(self: &mut Self) -> SafeResult

Return to "no-dictionary" mode.

This will disable any dictionary/prefix previously registered for future frames.

fn ref_ddict<'b>(self: &mut Self, ddict: &DDict<'b>) -> SafeResult
where
    'b: 'a

References a dictionary.

This will let this context decompress frames compressed with the same dictionary.

It will apply to all frames decompressed by this context (until a new dictionary is set).

Wraps the ZSTD_DCtx_refDDict() function.

fn ref_prefix<'b>(self: &mut Self, prefix: &'b [u8]) -> SafeResult
where
    'b: 'a

Use some prefix as single-use dictionary for the next frame.

Just like a dictionary, this only works if compression was done with the same prefix.

But unlike a dictionary, this only applies to the next frame.

Wraps the ZSTD_DCtx_refPrefix() function.

fn set_parameter(self: &mut Self, param: DParameter) -> SafeResult

Sets a decompression parameter.

fn decompress_stream<C: WriteBuf + ?Sized>(self: &mut Self, output: &mut OutBuffer<'_, C>, input: &mut InBuffer<'_>) -> SafeResult

Performs a step of a streaming decompression operation.

This will read some data from input and/or write some data to output.

Returns

  • Ok(0) if the current frame just finished decompressing successfully.
  • Ok(hint) with a hint for the "ideal" amount of input data to provide in the next call. Can be safely ignored.

Wraps the ZSTD_decompressStream() function.

fn in_size() -> usize

Wraps the ZSTD_DStreamInSize() function.

Returns a hint for the recommended size of the input buffer for decompression.

fn out_size() -> usize

Wraps the ZSTD_DStreamOutSize() function.

Returns a hint for the recommended size of the output buffer for decompression.

fn sizeof(self: &Self) -> usize

Wraps the ZSTD_sizeof_DCtx() function.

impl Default for DCtx<'_>

fn default() -> Self

impl Drop for DCtx<'_>

fn drop(self: &mut Self)

impl Send for DCtx<'_>

impl Sync for DCtx<'_>

impl<'a> Freeze for DCtx<'a>

impl<'a> RefUnwindSafe for DCtx<'a>

impl<'a> Unpin for DCtx<'a>

impl<'a> UnsafeUnpin for DCtx<'a>

impl<'a> UnwindSafe for DCtx<'a>

impl<T> Any for DCtx<'a>

fn type_id(self: &Self) -> TypeId

impl<T> Borrow for DCtx<'a>

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

impl<T> BorrowMut for DCtx<'a>

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

impl<T> From for DCtx<'a>

fn from(t: T) -> T

Returns the argument unchanged.

impl<T, U> Into for DCtx<'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 DCtx<'a>

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

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

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