#deflate #zlib #gzip

no-std libflate

A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)

30 releases (13 stable)

2.1.0 Apr 30, 2024
2.0.0 Jul 8, 2023
1.4.0 May 21, 2023
1.3.0 Feb 16, 2023
0.1.3 Nov 30, 2016

#7 in Compression

Download history 134059/week @ 2024-07-27 135380/week @ 2024-08-03 152212/week @ 2024-08-10 141226/week @ 2024-08-17 160620/week @ 2024-08-24 152933/week @ 2024-08-31 142061/week @ 2024-09-07 139557/week @ 2024-09-14 161282/week @ 2024-09-21 155005/week @ 2024-09-28 146236/week @ 2024-10-05 167806/week @ 2024-10-12 169763/week @ 2024-10-19 153234/week @ 2024-10-26 146774/week @ 2024-11-02 132735/week @ 2024-11-09

630,866 downloads per month
Used in 884 crates (181 directly)

MIT license

250KB
5K SLoC

libflate

libflate Documentation Actions Status Coverage Status License: MIT

A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP).

Documentation

See RustDoc Documentation.

The documentation includes some examples.

Installation

Add following lines to your Cargo.toml:

[dependencies]
libflate = "2"

An Example

Below is a command to decode GZIP stream that is read from the standard input:

extern crate libflate;

use std::io;
use libflate::gzip::Decoder;

fn main() {
    let mut input = io::stdin();
    let mut decoder = Decoder::new(&mut input).unwrap();
    io::copy(&mut decoder, &mut io::stdout()).unwrap();
}

An Informal Benchmark

A brief comparison with flate2 and inflate:

$ cd libflate/flate_bench/
$ curl -O https://dumps.wikimedia.org/enwiki/latest/enwiki-latest-all-titles-in-ns0.gz
$ gzip -d enwiki-latest-all-titles-in-ns0.gz
> ls -lh enwiki-latest-all-titles-in-ns0
-rw-rw-r-- 1 foo foo 265M May 18 05:19 enwiki-latest-all-titles-in-ns0

$ cargo run --release -- enwiki-latest-all-titles-in-ns0
# ENCODE (input_size=277303937)
- libflate: elapsed=8.137013s, size=83259010
-   flate2: elapsed=9.814607s, size=74692153

# DECODE (input_size=74217004)
- libflate: elapsed=1.354556s, size=277303937
-   flate2: elapsed=0.960907s, size=277303937
-  inflate: elapsed=1.926142s, size=277303937

References

Dependencies

~2.5MB
~34K SLoC