pub fn decompressed_size(data: &[u8]) -> Option<u64>Expand description
Reads the decompressed size out of the start of a frame, if it says.
Returns None if data does not begin with a zstd frame header, or if the
frame does not record its content size - which is normal for anything
produced by a streaming compressor that was not told the size in advance.
This is the size to reserve when decompressing into your own buffer:
let frame = zstd::encode_all(&b"some data"[..], 3)?;
let mut output = match zstd::decompressed_size(&frame) {
Some(size) => Vec::with_capacity(size as usize),
None => Vec::new(),
};
zstd::stream::copy_decode(&frame[..], &mut output)?;