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.).
§Decompression
Decompressor::new
can be used to construct a Decompressor
,
which can decompress:
- DEFLATE data (
deflate_decompress
) - zlib data (
zlib_decompress
) - gzip data (
gzip_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
§Compression
Compressor::new
can be used to construct a Compressor
, which
can compress data into the following formats:
- DEFLATE (
deflate_compress
) - zlib (
zlib_compress
) - gzip (
gzip_compress
)
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:
Structs§
- Struct holding the state required to compute a rolling adler32 value.
- Compression level used by a
Compressor
instance. - An iterator over the
CompressionLvl
s supported by theCompressor
. - 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.
Enums§
- An error that may be returned when calling one of the
Compressor
’scompress_*
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
’sdecompress_*
methods when a decompression cannot be performed.
Functions§
- Returns the Adler32 checksum of the bytes in
data
. - Returns the CRC32 checksum of the bytes in
data
.