ZSTD_decompressStream method

int ZSTD_decompressStream(
  1. Pointer<ZSTD_DStream> zds,
  2. Pointer<ZSTD_outBuffer> output,
  3. Pointer<ZSTD_inBuffer> input
)

! ZSTD_decompressStream() : Streaming decompression function. Call repetitively to consume full input updating it as necessary. Function will update both input and output pos fields exposing current state via these fields:

  • input.pos < input.size, some input remaining and caller should provide remaining input on the next call.
  • output.pos < output.size, decoder flushed internal output buffer.
  • output.pos == output.size, unflushed data potentially present in the internal buffers, check ZSTD_decompressStream() @return value, if > 0, invoke it again to flush remaining data to output. Note : with no additional input, amount of data flushed <= ZSTD_BLOCKSIZE_MAX.

@return : 0 when a frame is completely decoded and fully flushed, or an error code, which can be tested using ZSTD_isError(), or any other value > 0, which means there is some decoding or flushing to do to complete current frame.

Note: when an operation returns with an error code, the @zds state may be left in undefined state. It's UB to invoke ZSTD_decompressStream() on such a state. In order to re-use such a state, it must be first reset, which can be done explicitly (ZSTD_DCtx_reset()), or is implied for operations starting some new decompression job (ZSTD_initDStream, ZSTD_decompressDCtx(), ZSTD_decompress_usingDict())

Implementation

int ZSTD_decompressStream(
    ffi.Pointer<ZSTD_DStream> zds,
    ffi.Pointer<ZSTD_outBuffer> output,
    ffi.Pointer<ZSTD_inBuffer> input,
    ) {
  return _ZSTD_decompressStream(
    zds,
    output,
    input,
  );
}