img_core/deflate.rs#
Source: lib/img_core/deflate.rs
deflate -- DEFLATE (RFC 1951) / zlib (RFC 1950) compression with img_core's error codes
The encoder lives in jflib-compress since 0.2.2 (compress::deflate, compress::zlib); these are
the calls of before, with the same bytes. New code calls compress directly.
zlib_deflate(src, level) -> Vec zlib stream (level 0..9, < 0 = 6, > 9 = 9)
deflate_raw(src, level) -> Vec raw RFC 1951 data
deflate_raw_ex(st, src, level, head, tail) -> Vec head free bytes before the data
(gzip writes its header there), tail reserved
after it (not part of the Vec)
DeflateState::new() -> Box a reusable compressor state (~330 KB; one
thread at a time); the same bytes as fresh calls
zlib_deflate_st(st, src, level) / deflate_raw_st(st, src, level) -> Vec
zlib_deflate_to(st, src, level, dst) / deflate_raw_to(...) -> Ok(bytes) /
Err(ERR_OVERFLOW): into dst (no allocation with
a state); overflow when the stream + 8 bytes do
not fit (dst contents undefined then)
deflate_bound(len) -> len + len / 512 + 128 a cap with which *_to never overflow
Re-exports: compress::deflate::DeflateState
fn deflate_bound(len: usize) -> usizeoutput capacity with which the *_to functions never report ERR_OVERFLOW [deflate_bound]fn zlib_deflate_to(st: Option<&mut DeflateState>, src: &[u8], level: i32, dst: &mut [u8]) -> Result<usize, i32>zlib stream into dst [zlib_deflate_to]fn deflate_raw_to(st: Option<&mut DeflateState>, src: &[u8], level: i32, dst: &mut [u8]) -> Result<usize, i32>raw deflate data into dst [deflate_raw_to]fn zlib_deflate(src: &[u8], level: i32) -> Vec<u8>zlib stream [zlib_deflate]fn zlib_deflate_st(st: Option<&mut DeflateState>, src: &[u8], level: i32) -> Vec<u8>zlib stream with a reusable state (None = a temporary one) [zlib_deflate_st]fn deflate_raw(src: &[u8], level: i32) -> Vec<u8>raw deflate data [deflate_raw]fn deflate_raw_st(st: Option<&mut DeflateState>, src: &[u8], level: i32) -> Vec<u8>raw deflate data with a reusable state [deflate_raw_st without head / tail]fn deflate_raw_ex(st: Option<&mut DeflateState>, src: &[u8], level: i32, head: usize, tail: usize) -> Vec<u8>raw deflate data afterheadzero bytes (head, tail: 0..65536, larger values clamped); the Vec holds head + the compressed bytes, with room fortailmore [deflate_raw_st]