[][src]Function zstd_safe::cctx_ref_prefix

pub fn cctx_ref_prefix<'a>(
    cctx: &mut CCtx<'a>,
    prefix: &'a [u8]
) -> Result<usize, usize>

ZSTD_CCtx_refPrefix()

Reference a prefix (single-usage dictionary) for next compressed frame.

A prefix is only used once. Tables are discarded at end of frame (ZSTD_e_end). Decompression will need same prefix to properly regenerate data.

Compressing with a prefix is similar in outcome as performing a diff and compressing it, but performs much faster, especially during decompression (compression speed is tunable with compression level).

result : 0, or an error code (which can be tested with ZSTD_isError()).

Special: Adding any prefix (including NULL) invalidates any previous prefix or dictionary

Note 1 : Prefix buffer is referenced. It must outlive compression. Its content must remain unmodified during compression.

Note 2 : If the intention is to diff some large src data blob with some prior version of itself, ensure that the window size is large enough to contain the entire source. See ZSTD_c_windowLog.

Note 3 : Referencing a prefix involves building tables, which are dependent on compression parameters. It's a CPU consuming operation, with non-negligible impact on latency. If there is a need to use the same prefix multiple times, consider loadDictionary instead.

Note 4 : By default, the prefix is interpreted as raw content (ZSTD_dm_rawContent). Use experimental ZSTD_CCtx_refPrefix_advanced() to alter dictionary interpretation. */