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