#sys #zlib #gzip #miniz

sys miniz-sys

Bindings to the miniz.c library

14 releases

0.1.11 Oct 16, 2018
0.1.10 Sep 19, 2017
0.1.9 Jan 20, 2017
0.1.7 Nov 7, 2015
0.1.0 Nov 27, 2014
Download history 22441/week @ 2018-12-20 21567/week @ 2018-12-27 29113/week @ 2019-01-03 30319/week @ 2019-01-10 30589/week @ 2019-01-17 29085/week @ 2019-01-24 29846/week @ 2019-01-31 34717/week @ 2019-02-07 32815/week @ 2019-02-14 35971/week @ 2019-02-21 35644/week @ 2019-02-28 36685/week @ 2019-03-07 37245/week @ 2019-03-14 34195/week @ 2019-03-21 35227/week @ 2019-03-28

110,860 downloads per month
Used in 418 crates (2 directly)

MIT/Apache

318KB
6K SLoC

C 6K SLoC // 0.1% comments Rust 82 SLoC

flate2

Build Status Crates.io Documentation

A streaming compression/decompression library for Rust. The underlying implementation by default uses miniz but can optionally be configured to use the system zlib, if available.

There is also an experimental rust backend that uses the miniz_oxide crate. This avoids the need to build C code, but hasn't gone through as much testing as the other backends.

Supported formats:

  • deflate
  • zlib
  • gzip
# Cargo.toml
[dependencies]
flate2 = "1.0"

Using zlib instead of miniz:

[dependencies]
flate2 = { version = "1.0", features = ["zlib"], default-features = false }

Using the rust back-end:

[dependencies]
flate2 = { version = "1.0", features = ["rust_backend"], default-features = false }

Compression

extern crate flate2;

use std::io::prelude::*;
use flate2::Compression;
use flate2::write::ZlibEncoder;

fn main() {
    let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
    e.write_all(b"foo");
    e.write_all(b"bar");
    let compressed_bytes = e.finish();
}

Decompression

extern crate flate2;

use std::io::prelude::*;
use flate2::read::GzDecoder;

fn main() {
    let mut d = GzDecoder::new("...".as_bytes());
    let mut s = String::new();
    d.read_to_string(&mut s).unwrap();
    println!("{}", s);
}

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in this project by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~303KB

  • libc 0.2
  • links miniz
  • build build.rs
  • build cc 1.0