Skip to main content

Crate gzippy

Crate gzippy 

Source
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

LevelBackendNotes
0Store (no compression)
1–3ISA-L SIMD (x86_64), libdeflate/zlib-ng (other)fastest
4–5libdeflate one-shotbalanced
6zlib-ng streaminggzip default
7–9zlib-ng streaminghigh ratio
10,12libdeflate ultranear-zopfli ratio
11Zopflibest 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: ParallelGzEncoder produces 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: PipelinedGzEncoder produces 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§

DecodePath
The decompression path selected for a given input.
GzippyError

Functions§

classify
Return the DecodePath gzippy would choose for data with threads.
compress
Compress data to gzip format at level using all available CPUs.
compress_deflate64
Compress data as a raw Deflate64 bitstream, returning Vec<u8>.
compress_deflate64_to_writer
Compress data as a raw Deflate64 bitstream, writing to writer.
compress_raw
Compress data to raw DEFLATE (RFC 1951) at level — no gzip header or trailer.
compress_to_writer
Compress data from reader into writer at level using all available CPUs.
compress_to_writer_with_threads
Compress data from reader into writer at level with explicit thread count.
compress_with_threads
Compress data to gzip format at level using exactly threads threads.
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 writer using all available CPUs.
decompress_to_writer_with_threads
Decompress a gzip stream into writer with explicit thread count.
decompress_with_threads
Decompress a gzip stream with explicit thread count.

Type Aliases§

GzippyResult