pub fn compress_with_dictionary(
src: &[u8],
dict: &[u8],
level: i32,
) -> Result<Vec<u8>, Error>Expand description
Compresses src into one zstd frame at level with the dictionary
dict (zstd-format or raw content, see EncoderDictionary; an empty
one is no dictionary). The output is byte-identical to libzstd 1.6.0’s
ZSTD_CCtx_loadDictionary then ZSTD_compress2 on a new context (the
zstd crate’s bulk::Compressor::with_dictionary(level, dict)). It
indexes the dictionary on every call: for many inputs, use a
Compressor (which indexes it once) or an EncoderDictionary.
let dict = b"the quick brown fox jumps over the lazy dog";
let compressed = zstd_native::compress_with_dictionary(b"the lazy dog jumps", dict, 3)?;
let mut d = zstd_native::Decompressor::with_dictionary(zstd_native::Dictionary::new(dict)?);
assert_eq!(d.decompress(&compressed)?, b"the lazy dog jumps");§Errors
Error::InvalidDictionary if a
zstd-format dictionary is corrupt, or as compress.