Skip to main content

compress_file

Function compress_file 

Source
pub fn compress_file<P: AsRef<Path>>(path: P, level: i32) -> Result<Vec<u8>>
Expand description

Compress the contents of a file.

The file’s length comes from its metadata and is recorded in the frame, so whoever decompresses it can size their buffer up front. The contents are streamed through the compressor rather than read into memory first, so only the compressed result is held.

That result is still a Vec, so for a file large enough that you would rather not have one, use compress_file_into() instead.

let frame = zstd::compress_file("input.txt", 3)?;