Function zstd_sys::ZSTD_compress_generic[][src]

pub unsafe extern "C" fn ZSTD_compress_generic(
    cctx: *mut ZSTD_CCtx,
    output: *mut ZSTD_outBuffer,
    input: *mut ZSTD_inBuffer,
    endOp: ZSTD_EndDirective
) -> usize

ZSTD_compress_generic() : Behave about the same as ZSTD_compressStream. To note :

  • Compression parameters are pushed into CCtx before starting compression, using ZSTD_CCtx_setParameter()
  • Compression parameters cannot be changed once compression is started.
  • outpot->pos must be <= dstCapacity, input->pos must be <= srcSize
  • outpot->pos and input->pos will be updated. They are guaranteed to remain below their respective limit.
  • In single-thread mode (default), function is blocking : it completed its job before returning to caller.
  • In multi-thread mode, function is non-blocking : it just acquires a copy of input, and distribute job to internal worker threads, and then immediately returns, just indicating that there is some data remaining to be flushed. The function nonetheless guarantees forward progress : it will return only after it reads or write at least 1+ byte.
  • Exception : in multi-threading mode, if the first call requests a ZSTD_e_end directive, it is blocking : it will complete compression before giving back control to caller.
  • @return provides a minimum amount of data remaining to be flushed from internal buffers or an error code, which can be tested using ZSTD_isError(). if @return != 0, flush is not fully completed, there is still some data left within internal buffers. This is useful for ZSTD_e_flush, since in this case more flushes are necessary to empty all buffers. For ZSTD_e_end, @return == 0 when internal buffers are fully flushed and frame is completed.
  • after a ZSTD_e_end directive, if internal buffer is not fully flushed (@return != 0), only ZSTD_e_end or ZSTD_e_flush operations are allowed. Before starting a new compression job, or changing compression parameters, it is required to fully flush internal buffers.