[][src]Function zstd_safe::compress2

pub fn compress2(
    ctx: &mut CCtx,
    dst: &mut [u8],
    src: &[u8]
) -> Result<usize, usize>

ZSTD_compress2()

Behave the same as ZSTD_compressCCtx(), but compression parameters are set using the advanced API. ZSTD_compress2() always starts a new frame.

Should cctx hold data from a previously unfinished frame, everything about it is forgotten.

  • Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_set*()
  • The function is always blocking, returns when compression is completed.

Hint : compression runs faster if dstCapacity >= ZSTD_compressBound(srcSize).

Return : compressed size written into dst (<= dstCapacity), or an error code if it fails (which can be tested using ZSTD_isError()`).