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

..03-May-2022-

.github/workflows/H03-May-2022-9488

examples/H03-May-2022-513375

src/H03-May-2022-6,0643,606

tests/H03-May-2022-422352

.cargo-checksum.jsonH A D03-May-202289 11

.cargo_vcs_info.jsonH A D17-Mar-202074 65

.gitattributesH A D08-Apr-2017299 2115

.gitignoreH A D02-Oct-201918 32

Cargo.lockH A D17-Mar-202015 KiB613547

Cargo.tomlH A D17-Mar-20202.3 KiB9174

Cargo.toml.orig-cargoH A D17-Mar-20201.6 KiB5648

LICENSE-APACHEH A D03-Sep-201410.6 KiB202169

LICENSE-MITH A D03-Sep-20141 KiB2622

README.mdH A D12-Feb-20202.3 KiB9569

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 DEFLATE-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 other [backends](#Backends) like 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
24## Compression
25
26```rust
27use std::io::prelude::*;
28use flate2::Compression;
29use flate2::write::ZlibEncoder;
30
31fn main() {
32    let mut e = ZlibEncoder::new(Vec::new(), Compression::default());
33    e.write_all(b"foo");
34    e.write_all(b"bar");
35    let compressed_bytes = e.finish();
36}
37```
38
39## Decompression
40
41```rust,no_run
42use std::io::prelude::*;
43use flate2::read::GzDecoder;
44
45fn main() {
46    let mut d = GzDecoder::new("...".as_bytes());
47    let mut s = String::new();
48    d.read_to_string(&mut s).unwrap();
49    println!("{}", s);
50}
51```
52
53## Backends
54
55Using zlib instead of the (default) Rust backend:
56
57```toml
58[dependencies]
59flate2 = { version = "1.0", features = ["zlib"], default-features = false }
60```
61
62The cloudflare optimized version of zlib is also available.
63While it's significantly faster it requires a x86-64 CPU with SSE 4.2 or ARM64 with NEON & CRC.
64It does not support 32-bit CPUs at all and is incompatible with mingw.
65For more information check the [crate documentation](https://crates.io/crates/cloudflare-zlib-sys).
66
67```toml
68[dependencies]
69flate2 = { version = "1.0", features = ["cloudflare_zlib"], default-features = false }
70```
71
72Using `miniz.c`:
73
74```toml
75[dependencies]
76flate2 = { version = "1.0", features = ["miniz-sys"], default-features = false }
77```
78
79# License
80
81This project is licensed under either of
82
83 * Apache License, Version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
84   http://www.apache.org/licenses/LICENSE-2.0)
85 * MIT license ([LICENSE-MIT](LICENSE-MIT) or
86   http://opensource.org/licenses/MIT)
87
88at your option.
89
90### Contribution
91
92Unless you explicitly state otherwise, any contribution intentionally submitted
93for inclusion in this project by you, as defined in the Apache-2.0 license,
94shall be dual licensed as above, without any additional terms or conditions.
95