]> git.proxmox.com Git - rustc.git/blame - vendor/flate2/README.md
New upstream version 1.41.1+dfsg1
[rustc.git] / vendor / flate2 / README.md
CommitLineData
7cac9316
XL
1# flate2
2
ea8adc8c
XL
3[![Crates.io](https://img.shields.io/crates/v/flate2.svg?maxAge=2592000)](https://crates.io/crates/flate2)
4[![Documentation](https://docs.rs/flate2/badge.svg)](https://docs.rs/flate2)
7cac9316 5
60c5eb7d 6A streaming compression/decompression library DEFALTE-based streams in Rust.
7cac9316 7
60c5eb7d
XL
8This crate by default implemented as a wrapper around the `miniz_oxide` crate, a
9port of `miniz.c` to Rust. This crate can also optionally use the zlib library
10or `miniz.c` itself.
ff7c6d11 11
7cac9316
XL
12Supported formats:
13
14* deflate
15* zlib
16* gzip
17
18```toml
19# Cargo.toml
20[dependencies]
b7449926 21flate2 = "1.0"
7cac9316
XL
22```
23
60c5eb7d 24Using zlib instead of the Rust backend:
7cac9316
XL
25
26```toml
27[dependencies]
b7449926 28flate2 = { version = "1.0", features = ["zlib"], default-features = false }
7cac9316
XL
29```
30
60c5eb7d 31Using `miniz.c`:
ff7c6d11
XL
32
33```toml
34[dependencies]
60c5eb7d 35flate2 = { version = "1.0", features = ["miniz-sys"], default-features = false }
ff7c6d11
XL
36```
37
7cac9316
XL
38## Compression
39
40```rust
7cac9316
XL
41use std::io::prelude::*;
42use flate2::Compression;
43use flate2::write::ZlibEncoder;
44
45fn main() {
ff7c6d11 46 let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
b7449926
XL
47 e.write_all(b"foo");
48 e.write_all(b"bar");
7cac9316
XL
49 let compressed_bytes = e.finish();
50}
51```
52
53## Decompression
54
55```rust,no_run
7cac9316
XL
56use std::io::prelude::*;
57use flate2::read::GzDecoder;
58
59fn main() {
ff7c6d11 60 let mut d = GzDecoder::new("...".as_bytes());
7cac9316
XL
61 let mut s = String::new();
62 d.read_to_string(&mut s).unwrap();
63 println!("{}", s);
64}
65```
66
67# License
68
ff7c6d11
XL
69This project is licensed under either of
70
71 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
72 http://www.apache.org/licenses/LICENSE-2.0)
73 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
74 http://opensource.org/licenses/MIT)
75
76at your option.
77
78### Contribution
7cac9316 79
ff7c6d11
XL
80Unless you explicitly state otherwise, any contribution intentionally submitted
81for inclusion in this project by you, as defined in the Apache-2.0 license,
82shall be dual licensed as above, without any additional terms or conditions.