Module flate2
Deflate, gzip, and zlib compression.
flate2 provides compression and decompression for the DEFLATE algorithm,
along with support for zlib and gzip formats.
The crate offers both streaming and one-shot APIs for compression,
making it suitable for a wide range of use cases.
By default, flate2 uses the miniz_oxide backend,
a pure Rust implementation that requires no C compiler
and uses only safe Rust code.
For maximum performance, the zlib-rs backend is available,
which typically outperforms C implementations.
The crate provides separate types for reading and writing compressed data:
Encoder and Decoder for raw DEFLATE,
GzEncoder and GzDecoder for gzip format,
and ZlibEncoder and ZlibDecoder for zlib format.
Examples
Compressing data with gzip:
use Compression;
use GzEncoder;
use Write;
let mut encoder = new;
encoder.write_all.unwrap;
let compressed = encoder.finish.unwrap;
Decompressing gzip data:
use GzDecoder;
use Read;
Compression with the deflate algorithm:
use Compression;
use DeflateEncoder;
use Write;
let original = b"The quick brown fox jumps over the lazy dog";
let mut encoder = new;
encoder.write_all.unwrap;
let compressed = encoder.finish.unwrap;
Modules
Structs
- Compression When compressing data, the compression level can be specified by a value in this struct.