pub fn compress(src: &[u8], level: i32) -> Result<Vec<u8>, Error>Expand description
Compresses src into one zstd frame at level (1 to 22, negative for
faster; 0 means the default, 3), like libzstd’s ZSTD_compress: the
output is byte-identical to libzstd 1.6.0’s.
Every level and strategy is implemented, fast to btultra2, with
libzstd’s block splitters and its long distance matcher, which it
enables by itself at level 22 for inputs over 64 MiB (a 128 MiB window;
memory use is then libzstd’s too, about 700 MiB of tables).
let data = b"hello hello hello hello hello hello";
let compressed = zstd_native::compress(data, 1)?;
assert_eq!(zstd_native::decompress(&compressed)?, data);§Errors
None in practice: the output buffer is compress_bound bytes, always
enough.