Expand description
gzippy — embed the world’s fastest gzip in your Rust program.
Every function routes through the same backend-selection logic as the gzippy CLI, so you automatically get ISA-L SIMD, libdeflate, parallel multi-block, Zopfli, and multi-member decompression without any extra configuration.
§Quick start
let data = b"hello, world!".repeat(1000);
let compressed = gzippy::compress(&data, 6).unwrap();
let decompressed = gzippy::decompress(&compressed).unwrap();
assert_eq!(decompressed, data);§Choosing a compression level
| Level | Backend | Notes |
|---|---|---|
| 0 | Store (no compression) | |
| 1–3 | ISA-L SIMD (x86_64), libdeflate/zlib-ng (other) | fastest |
| 4–5 | libdeflate one-shot | balanced |
| 6 | zlib-ng streaming | gzip default |
| 7–9 | zlib-ng streaming | high ratio |
| 10,12 | libdeflate ultra | near-zopfli ratio |
| 11 | Zopfli | best ratio, very slow |
§Threading and output format
threads = 1 always produces a standard single-member gzip stream
decompressible by any tool.
threads > 1 behaviour depends on level:
- L0–5:
ParallelGzEncoderproduces a gzippy “GZ” multi-block stream. This is not decompressible by standard tools (gunzip, pigz, etc.) — only by gzippy itself (CLI or this library). Use it when both ends of the pipe run gzippy. - L6–9:
PipelinedGzEncoderproduces a standard single-member stream that any tool can decompress.
§Decompression
The decompressor handles all gzip variants automatically:
- gzippy “GZ” multi-block streams (parallel bgzf path)
- Standard multi-member streams (e.g.
cat a.gz b.gz) - Single-member streams (standard gzip output)
Non-gzip input: if data does not begin with the gzip magic bytes
(0x1f 0x8b), every decompress function returns Ok(empty) rather than
an error — consistent with CLI sniffing behavior.
Re-exports§
pub use self::compress_raw as deflate_encode;pub use self::decompress_raw as deflate_decode;
Enums§
- Decode
Path - The decompression path selected for a given input.
- Gzippy
Error
Functions§
- classify
- Return the
DecodePathgzippy would choose fordatawiththreads. - compress
- Compress
datato gzip format atlevelusing all available CPUs. - compress_
deflate64 - Compress
dataas a raw Deflate64 bitstream, returningVec<u8>. - compress_
deflate64_ to_ writer - Compress
dataas a raw Deflate64 bitstream, writing towriter. - compress_
raw - Compress
datato raw DEFLATE (RFC 1951) atlevel— no gzip header or trailer. - compress_
to_ writer - Compress data from
readerintowriteratlevelusing all available CPUs. - compress_
to_ writer_ with_ threads - Compress data from
readerintowriteratlevelwith explicit thread count. - compress_
with_ threads - Compress
datato gzip format atlevelusing exactlythreadsthreads. - decompress
- Decompress a gzip stream using all available CPUs.
- decompress_
deflate64 - Decompress a raw Deflate64 stream (ZIP method 9 / Enhanced Deflate).
- decompress_
deflate64_ to_ writer - Decompress a raw Deflate64 stream into
writer. - decompress_
raw - Decompress a raw DEFLATE stream (RFC 1951) — no gzip header or trailer expected.
- decompress_
to_ writer - Decompress a gzip stream into
writerusing all available CPUs. - decompress_
to_ writer_ with_ threads - Decompress a gzip stream into
writerwith explicit thread count. - decompress_
with_ threads - Decompress a gzip stream with explicit thread count.