A Rust implementation of DEFLATE algorithm and related formats (ZLIB, GZIP)
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
data Fix bug reported in #16 Sep 24, 2018
examples Apply rustfmt-0.99.1 Sep 23, 2018
flate_bench Support flate2-v1.x.x Dec 25, 2017
src Apply clippy-v0.0.212 Dec 1, 2018
.gitignore First commit Oct 5, 2016
.travis.yml Update .travis.yml Jul 1, 2018
Cargo.toml Bump version to v0.1.19 Dec 1, 2018
LICENSE Add LICENSE file Oct 6, 2016
README.md Update README.md Sep 11, 2018

README.md

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