#flate #deflate #zlib #compression #gzip

deflate

A DEFLATE, zlib and gzip encoder written in rust

20 releases

0.7.20 Jun 30, 2019
0.7.19 Sep 30, 2018
0.7.18 Mar 25, 2018
0.7.17 Sep 22, 2017
0.6.0 Nov 24, 2016

#11 in Compression

Download history 9655/week @ 2019-04-17 10118/week @ 2019-04-24 9879/week @ 2019-05-01 8620/week @ 2019-05-08 7780/week @ 2019-05-15 8732/week @ 2019-05-22 8780/week @ 2019-05-29 10434/week @ 2019-06-05 11546/week @ 2019-06-12 10556/week @ 2019-06-19 12673/week @ 2019-06-26 12825/week @ 2019-07-03 11355/week @ 2019-07-10 11226/week @ 2019-07-17 12408/week @ 2019-07-24

40,732 downloads per month
Used in 17 crates (8 directly)

MIT/Apache

255KB
6.5K SLoC

deflate-rs

Build StatusCrates.ioDocs

An implementation of a DEFLATE encoder in pure rust. Not a direct port, but does take some inspiration from zlib, miniz and zopfli. The API is based on the one in the flate2 crate that contains bindings to zlib and miniz.

So far, deflate encoding with and without zlib and gzip metadata (zlib dictionaryies are not supported yet) has been is implemented. Speed-wise it's not quite up to miniz-levels yet (between 10% and twice as slow for most files, seems to be slow on very small files, close to miniz on larger ones).

Usage:

Simple compression function:

use deflate::deflate_bytes;

let data = b"Some data";
let compressed = deflate_bytes(&data);

Using a writer:

use std::io::Write;

use deflate::Compression;
use deflate::write::ZlibEncoder;

let data = b"This is some test data";
let mut encoder = ZlibEncoder::new(Vec::new(), Compression::Default);
encoder.write_all(data).unwrap();
let compressed_data = encoder.finish().unwrap();

Other deflate/zlib rust projects from various people

  • flate2 FLATE, Gzip, and Zlib bindings for Rust
  • Zopfli in Rust Rust port of zopfli
  • inflate DEFLATE decoder implemented in rust
  • miniz-oxide Port of miniz to rust.
  • miniz-rs Older rust translation of miniz.
  • libflate Another DEFLATE/Zlib/Gzip encoder and decoder written in Rust. (Only does some very light compression).

License

deflate is distributed under the terms of both the MIT and Apache 2.0 licences.

bitstream.rs is © @nwin and was released under both MIT and Apache 2.0

Some code in length_encode.rs has been ported from the miniz library, which is public domain.

The test data (src/pg11.txt) is borrowed from Project Gutenberg and is available under public domain, or the Project Gutenberg Licence

Dependencies