Skip to main content

Crate rusty_zlib

Crate rusty_zlib 

Source
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.
DeflateConfig
Configuration for compression.
Inflate
The state that is used to decompress an input.
InflateConfig
Configuration for decompresssion.

Enums§

DeflateError
Errors that can occur when compressing.
DeflateFlush
InflateError
Errors that can occur when decompressing.
InflateFlush
LevelTable
Which level table a deflate stream uses (house delta, rusty_zlib).
Method
ReturnCode
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_len bytes.
compress_slice
Compresses input into the provided output buffer.
decompress_slice
Decompresses input into the provided output buffer.
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".