Skip to main content

encode_all

Function encode_all 

Source
pub fn encode_all<R: Read>(source: R, level: i32) -> Result<Vec<u8>>
Expand description

Compress all data from the given source as if using an Encoder.

Result will be in the zstd frame format.

A level of 0 uses zstd’s default (currently 3).

Because the source is read as a stream, its length is not known in advance, so the frame this produces does not record its decompressed size. Whoever decompresses it cannot size their buffer up front, which costs them about a factor of two - see decompressed_size(). Use crate::bulk::compress() for a slice you already hold, compress_file() for a file, or compress_sized() when you know the length some other way; all three record it.