Skip to main content

compress_bound

Function compress_bound 

Source
pub const fn compress_bound(source_len: usize) -> usize
Expand description

Returns the upper bound on the compressed size for an input of source_len bytes.

When compression has this much space available, it will never fail because of insufficient output space.

ยงExample


assert_eq!(compress_bound(1024), 1161);
assert_eq!(compress_bound(4096), 4617);
assert_eq!(compress_bound(65536), 73737);

let mut buf = vec![0u8; compress_bound(input.len())];
let (compressed, rc) = compress_slice(&mut buf, input, DeflateConfig::default());