Struct zstd_safe::CCtx

source ·
pub struct CCtx<'a>(_, _);
Expand description

Compression context

It is recommended to allocate a single context per thread and re-use it for many compression operations.

Implementations

Tries to create a new context.

Returns None if zstd returns a NULL pointer - may happen if allocation fails.

Wrap ZSTD_createCCtx

Panics

If zstd returns a NULL pointer.

Wraps the ZSTD_compressCCtx() function

Wraps the ZSTD_compress2() function.

Wraps the ZSTD_compress_usingDict() function.

Wraps the ZSTD_compress_usingCDict() function.

Initializes the context with the given compression level.

This is equivalent to running:

  • reset()
  • set_parameter(CompressionLevel, compression_level)
👎Deprecated
Available on crate feature experimental only.

Wraps the ZSTD_initCStream_srcSize() function.

👎Deprecated
Available on crate feature experimental only.

Wraps the ZSTD_initCStream_usingDict() function.

👎Deprecated
Available on crate feature experimental only.

Wraps the ZSTD_initCStream_usingCDict() function.

Tries to load a 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 CDict first, then loads that.

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

Wraps the ZSTD_CCtx_refCDict() function.

Dictionary must outlive the context.

Return to “no-dictionary” mode.

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

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

Just like a dictionary, decompression will need to be given the same prefix.

This is best used if the “prefix” looks like the data to be compressed.

Performs a step of a streaming compression operation.

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

Returns

A hint for the “ideal” amount of input data to provide in the next call.

This hint is only for performance purposes.

Wraps the ZSTD_compressStream() function.

Performs a step of a streaming compression operation.

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

The end_op directive can be used to specify what to do after: nothing special, flush internal buffers, or end the frame.

Returns

An lower bound for the amount of data that still needs to be flushed out.

This is useful when flushing or ending the frame: you need to keep calling this function until it returns 0.

Wraps the ZSTD_compressStream2() function.

Flush any intermediate buffer.

To fully flush, you should keep calling this function until it returns Ok(0).

Wraps the ZSTD_flushStream() function.

Ends the stream.

You should keep calling this function until it returns Ok(0).

Wraps the ZSTD_endStream() function.

Returns the size currently used by this context.

This may change over time.

Resets the state of the context.

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

Wraps the ZSTD_CCtx_reset() function.

Sets a compression parameter.

Some of these parameters need to be set during de-compression as well.

Guarantee that the input size will be this value.

If given None, assumes the size is unknown.

Unless explicitly disabled, this will cause the size to be written in the compressed frame header.

If the actual data given to compress has a different size, an error will be returned.

Available on crate feature experimental only.

Creates a copy of this context.

This only works before any data has been compressed. An error will be returned otherwise.

Available on crate feature experimental only.

Wraps the ZSTD_getBlockSize() function.

Available on crate feature experimental only.

Wraps the ZSTD_compressBlock() function.

Returns the recommended input buffer size.

Using this size may result in minor performance boost.

Returns the recommended output buffer size.

Using this may result in minor performance boost.

Trait Implementations

Returns the “default value” for a type. Read more
Executes the destructor for this 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.