• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..15-Mar-2021-

examples/H03-May-2022-484349

src/H15-Mar-2021-6,0173,563

tests/H03-May-2022-422352

.cargo-checksum.jsonH A D15-Mar-20215.2 KiB11

Cargo.lockH A D15-Mar-202127.1 KiB601535

Cargo.tomlH A D15-Mar-20212.1 KiB8569

LICENSE-APACHEH A D15-Mar-202110.6 KiB202169

LICENSE-MITH A D15-Mar-20211 KiB2622

README.mdH A D15-Mar-20211.8 KiB8360

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
6A streaming compression/decompression library DEFALTE-based streams in Rust.
7
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.
11
12Supported formats:
13
14* deflate
15* zlib
16* gzip
17
18```toml
19# Cargo.toml
20[dependencies]
21flate2 = "1.0"
22```
23
24Using zlib instead of the Rust backend:
25
26```toml
27[dependencies]
28flate2 = { version = "1.0", features = ["zlib"], default-features = false }
29```
30
31Using `miniz.c`:
32
33```toml
34[dependencies]
35flate2 = { version = "1.0", features = ["miniz-sys"], default-features = false }
36```
37
38## Compression
39
40```rust
41use std::io::prelude::*;
42use flate2::Compression;
43use flate2::write::ZlibEncoder;
44
45fn 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
56use std::io::prelude::*;
57use flate2::read::GzDecoder;
58
59fn 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
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
79
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.
83