API Reference
flate2
DEFLATE, gzip, and zlib compression for Rust with multiple interchangeable backends.
Official Documentation ↗CompatibilityThis documentation covers version
v1.0. Check the official docs for the latest API surface.Installation
cargo
cargo add flate2Methods
No methods match this filter.
flate2 provides read and write wrappers for gzip and zlib streams over any IO type.
Key Features
- gzip, zlib, and raw deflate
- Read and write adapters
- Level configuration
Usage Notes
Pin a version and check the official docs for the API surface you depend on before upgrading.
Errors
The following points are quoted verbatim from the official documentation. 来源:https://docs.rs/flate2/latest/flate2/ · 取证方式:HTTP GET 官方 README/文档页(HTML 去标签) · 抓取时间:2026-11-07T13:49:42.274Z. Any error type, throw condition or recovery step not stated there is left unspecified; this page does not infer exception classes or return values.
- If a file contains non-gzip data after the gzip data, MultiGzDecoder will emit an error after decoding the gzip data. (https://docs.rs/flate2/latest/flate2/)
- Compress Error Error returned when a compression object is used incorrectly or otherwise generates an error. (https://docs.rs/flate2/latest/flate2/)
- Decompress Error Error returned when a decompression object finds that the input stream of bytes was not a valid input stream of bytes. (https://docs.rs/flate2/latest/flate2/)
FAQ
- Which backend should I pick?
- Default to the pure-Rust backend for portability; enable the zlib backend feature when you need its speed.
- How do I stream large files?
- Wrap the file reader or writer directly so compression happens in chunks without buffering the whole file.
- What is the difference between gzip and zlib?
- gzip carries a header and checksum and is used for files; zlib is a bare deflate stream often used inside protocols.
Report a problem with this API docOpens a pre-filled issue on GitHub.