Expand description
A reimplementation of the Zopfli compression library in Rust.
Zopfli is a state of the art DEFLATE compressor that heavily prioritizes compression over speed. It usually compresses much better than other DEFLATE compressors, generating standard DEFLATE streams that can be decompressed with any DEFLATE decompressor, at the cost of being significantly slower.
§Features
This crate exposes the following features. You can enable or disable them in your Cargo.toml
as needed.
gzip
(enabled by default): enables support for compression in the gzip format.zlib
(enabled by default): enables support for compression in the Zlib format.std
(enabled by default): enables linking against the Rust standard library. When not enabled, the crate is built with the#![no_std]
attribute and can be used in any environment wherealloc
(i.e., a memory allocator) is available. In addition, the crate exposes minimalist versions of thestd
I/O traits it needs to function, allowing users to implement them. Disablingstd
requires enablingnightly
due to dependencies on unstable language features.nightly
: enables performance optimizations that are specific to the nightly Rust toolchain. Currently, this feature improves rustdoc generation and enables the namesake feature oncrc32fast
, but this may change in the future. This feature also used to enablesimd-adler32
’s namesake feature, but it no longer does as the latestsimd-adler32
release does not build with the latest nightlies (as of 2024-05-18) when that feature is enabled.
Structs§
- Deflate
Encoder - A DEFLATE encoder powered by the Zopfli algorithm that compresses data written
to it to the specified sink. Most users will find using
compress
easier and more performant. - Error
Non- std
- The error type for I/O operations of the
Write
trait. - Gzip
Encoder gzip
- A Gzip encoder powered by the Zopfli algorithm, that compresses data using
a
DeflateEncoder
. Most users will find usingcompress
easier and more performant. - Options
- Options for the Zopfli compression algorithm.
- Zlib
Encoder zlib
- A Zlib encoder powered by the Zopfli algorithm, that compresses data using
a
DeflateEncoder
. Most users will find usingcompress
easier and more performant.
Enums§
- Block
Type - The type of data blocks to generate for a DEFLATE stream.
- Error
Kind Non- std
- A list specifying general categories of I/O error.
- Format
std
- The output file format to use to store data compressed with Zopfli.
Traits§
- Write
Non- std
- A trait for objects which are byte-oriented sinks, modeled after its
std::io::Write
counterpart.
Functions§
- compress
std
- Compresses data from a source with the Zopfli algorithm, using the specified options, and writes the result to a sink in the defined output format.
- prewarm_
object_ pools std
- Populates object pools for expensive objects that Zopfli uses. Call this on a background thread when you know ahead of time that compression will be needed.