Function zstd_sys::ZSTD_compressBegin[][src]

pub unsafe extern "C" fn ZSTD_compressBegin(
    cctx: *mut ZSTD_CCtx,
    compressionLevel: c_int
) -> usize

Buffer-less streaming compression (synchronous mode)

A ZSTD_CCtx object is required to track streaming operations. Use ZSTD_createCCtx() / ZSTD_freeCCtx() to manage resource. ZSTD_CCtx object can be re-used multiple times within successive compression operations.

Start by initializing a context. Use ZSTD_compressBegin(), or ZSTD_compressBegin_usingDict() for dictionary compression, or ZSTD_compressBegin_advanced(), for finer parameter control. It’s also possible to duplicate a reference context which has already been initialized, using ZSTD_copyCCtx()

Then, consume your input using ZSTD_compressContinue(). There are some important considerations to keep in mind when using this advanced function :

Finish a frame with ZSTD_compressEnd(), which will write the last block(s) and optional checksum. It’s possible to use srcSize==0, in which case, it will write a final empty block to end the frame. Without last block mark, frames are considered unfinished (hence corrupted) by compliant decoders.

ZSTD_CCtx object can be re-used (ZSTD_compressBegin()) to compress again.