gecko-dev/third_party/rust/flate2
Nathan Froyd b93bf873ba Bug 1502964 - part 2 - update winapi to froydnj/winapi-rs#aarch64; r=ted.mielczarek 2018-11-02 10:56:08 -04:00
..
examples Bug 1439329 - Bump crate dependencies for zip 0.3. r=jgraham 2018-02-19 12:33:08 +01:00
src Bug 1439329 - Bump crate dependencies for zip 0.3. r=jgraham 2018-02-19 12:33:08 +01:00
tests Bug 1439329 - Bump crate dependencies for zip 0.3. r=jgraham 2018-02-19 12:33:08 +01:00
.cargo-checksum.json Bug 1502964 - part 2 - update winapi to froydnj/winapi-rs#aarch64; r=ted.mielczarek 2018-11-02 10:56:08 -04:00
Cargo.toml Bug 1439329 - Bump crate dependencies for zip 0.3. r=jgraham 2018-02-19 12:33:08 +01:00
LICENSE-APACHE
LICENSE-MIT
README.md Bug 1439329 - Bump crate dependencies for zip 0.3. r=jgraham 2018-02-19 12:33:08 +01:00
appveyor.yml Bug 1414254 - Vendor Rust dependencies r=jgraham 2017-11-03 13:39:05 +00:00

README.md

flate2

Build Status 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 = "0.2"

Using zlib instead of miniz:

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

Using the rust back-end:

[dependencies]
flate2 = { version = "0.2", 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(b"foo");
    e.write(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.