Expand description
A pure-rust implementation of zlib.
This is a low-level implementation crate for use in libraries like flate2 and rustls. For a more high-level interface, use flate2.
For a zlib -compatible rust api of this crate, see libz-rs-sys. For instructions on integrating zlib-rs into a C library, see libz-rs-sys-cdylib.
§Example
use rusty_zlib::ReturnCode;
use rusty_zlib::{DeflateConfig, compress_bound, compress_slice};
use rusty_zlib::{InflateConfig, decompress_slice};
let input = b"Hello World";
// --- compress ---
let mut compressed_buf = vec![0u8; compress_bound(input.len())];
let (compressed, rc) =
compress_slice(&mut compressed_buf, input, DeflateConfig::default());
assert_eq!(rc, ReturnCode::Ok);
// --- decompress ---
let mut decompressed_buf = vec![0u8; input.len()];
let (decompressed, rc) =
decompress_slice(&mut decompressed_buf, compressed, InflateConfig::default());
assert_eq!(rc, ReturnCode::Ok);
assert_eq!(decompressed, input);Modules§
- adler32
- The adler32 checksum algorithm.
- compat
- Output-compatible alternative encoders.
- crc32
- The crc32 checksum algorithm.
Structs§
- Deflate
- The state that is used to compress an input.
- Deflate
Config - Configuration for compression.
- Inflate
- The state that is used to decompress an input.
- Inflate
Config - Configuration for decompresssion.
Enums§
- Deflate
Error - Errors that can occur when compressing.
- Deflate
Flush - Inflate
Error - Errors that can occur when decompressing.
- Inflate
Flush - Level
Table - Which level table a deflate stream uses (house delta, rusty_zlib).
- Method
- Return
Code - Status
- Possible status results of compressing some data or successfully decompressing a block of data.
- Strategy
Functions§
- compress_
bound - Returns the upper bound on the compressed size for an input of
source_lenbytes. - compress_
slice - Compresses
inputinto the providedoutputbuffer. - decompress_
slice - Decompresses
inputinto the providedoutputbuffer. - default_
level_ table - The level table that newly initialised deflate streams use.
- set_
default_ level_ table - Set the level table that newly initialised deflate streams use, process-wide.
- simd_
path - The widest accelerated path this build reaches on this CPU:
"avx2","sse4.2","neon","simd128"or"scalar".