Expand description

Rust bindings to libdeflate, a DEFLATE-based buffer compression/decompression library that works with raw DEFLATE, zlib, and gzip data.

Warning: Libdeflate is targeted at specialized performance-sensitive use-cases where developers have a good understanding of their input/output data. Developers looking for a general-purpose DEFLATE library should use something like flate2, which can handle a much wider range of inputs (network streams, large files, etc.).


Decompressor::new can be used to construct a Decompressor, which can decompress:

Note: libdeflate requires that the input and output buffers are pre-allocated before decompressing. Because of this, you will at least need to know the upper bound on how large the compressed data will decompress to; otherwise, a decompress_* function call will return DecompressionError::InsufficientSpace


Compressor::new can be used to construct a Compressor, which can compress data into the following formats:

Because buffers must be allocated up-front, developers need to supply these functions with output buffers that are big enough to fit the compressed data. The maximum size of the compressed data can be found with the associated *_bound methods:


Compression level used by a Compressor instance.

An iterator over the CompressionLvls supported by the Compressor.

A libdeflate compressor that can compress arbitrary data into DEFLATE, zlib, or gzip formats.

Struct holding the state required to compute a rolling crc32 value.

A libdeflate decompressor that can inflate DEFLATE, zlib, or gzip data.


An error that may be returned when calling one of the Compressor’s compress_* methods.

Errors that can be returned when attempting to create a CompressionLvl from a numeric value.

An error that may be returned by one of the Decompressor’s decompress_* methods when a decompression cannot be performed.


Returns the CRC32 checksum of the bytes in data.