gecko-dev/third_party/rust/flate2
Kartikaya Gupta 47c3dd535d Bug 1369156 - Re-vendor third-party rust libraries with latest cargo-vendor. r=froydnj
MozReview-Commit-ID: LQicTh0fmk0

--HG--
extra : rebase_source : 7a5ee9c3242fefa72e8d0372b8e9c03170c7df4b
2017-06-20 16:05:17 -04:00
..
src
tests
.cargo-checksum.json
.cargo-ok
.travis.yml
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md
appveyor.yml

README.md

flate2

Build Status Build status

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.

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 }

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()).unwrap();
    let mut s = String::new();
    d.read_to_string(&mut s).unwrap();
    println!("{}", s);
}

License

flate2-rs is primarily distributed under the terms of both the MIT license and the Apache License (Version 2.0), with portions covered by various BSD-like licenses.

See LICENSE-APACHE, and LICENSE-MIT for details.