Crate libdeflater
source · [−]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
Compressor
instance.CompressionLvl
s supported by the
Compressor
.libdeflate
compressor that can compress arbitrary data into
DEFLATE, zlib, or gzip formats.libdeflate
decompressor that can inflate DEFLATE, zlib, or
gzip data.Enums
Compressor
’s compress_*
methods.CompressionLvl
from a numeric value.Decompressor
’s decompress_*
methods when a decompression cannot be performed.Functions
data
.