#deflate #gzip #zlib

libflate

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

20 releases (3 stable)

✓ Uses Rust 2018 edition

1.0.2 Jul 1, 2020
0.1.27 Aug 19, 2019
0.1.25 Jul 2, 2019
0.1.21 Mar 10, 2019
0.1.3 Nov 30, 2016

#6 in Compression

Download history 18838/week @ 2020-03-16 20472/week @ 2020-03-23 19244/week @ 2020-03-30 17737/week @ 2020-04-06 19940/week @ 2020-04-13 22163/week @ 2020-04-20 20274/week @ 2020-04-27 21523/week @ 2020-05-04 26518/week @ 2020-05-11 22991/week @ 2020-05-18 25333/week @ 2020-05-25 25202/week @ 2020-06-01 25321/week @ 2020-06-08 23527/week @ 2020-06-15 24422/week @ 2020-06-22 24362/week @ 2020-06-29

96,984 downloads per month
Used in 551 crates (83 directly)

MIT license

235KB
4.5K SLoC

libflate

libflate Documentation Build Status Code Coverage 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 = "0.1"

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

~155KB