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

..03-May-2022-

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

assets/H03-May-2022-

examples/H03-May-2022-282218

src/H03-May-2022-2,5651,645

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

.cargo_vcs_info.jsonH A D01-Jan-197074 65

.gitattributesH A D01-Jan-197022 21

.gitignoreH A D01-Jan-197040 54

.gitmodulesH A D01-Jan-1970110 43

.travis.ymlH A D01-Jan-1970370 2420

Cargo.lockH A D01-Jan-197014.2 KiB568502

Cargo.tomlH A D01-Jan-19701.8 KiB6859

Cargo.toml.orig-cargoH A D01-Jan-19701.2 KiB4538

LICENSEH A D01-Jan-19701.1 KiB95

Readme.mdH A D01-Jan-19703 KiB11276

appveyor.ymlH A D01-Jan-1970991 4133

rustfmt.tomlH A D01-Jan-197063 43

Readme.md

1# zstd
2
3[![Build on Linux](https://github.com/gyscos/zstd-rs/actions/workflows/linux.yml/badge.svg)](https://github.com/gyscos/zstd-rs/actions/workflows/linux.yml)
4[![Build on Windows](https://github.com/gyscos/zstd-rs/actions/workflows/windows.yml/badge.svg)](https://github.com/gyscos/zstd-rs/actions/workflows/windows.yml)
5[![Build on macOS](https://github.com/gyscos/zstd-rs/actions/workflows/macos.yml/badge.svg)](https://github.com/gyscos/zstd-rs/actions/workflows/macos.yml)
6[![crates.io](http://meritbadge.herokuapp.com/zstd)](https://crates.io/crates/zstd)
7[![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
8
9This library is a rust binding for the [zstd compression library][zstd].
10
11# [Documentation][doc]
12
13## 1 - Add to `cargo.toml`
14
15### Using [cargo-edit]
16
17```bash
18$ cargo add zstd
19```
20
21### Manually
22
23```toml
24# Cargo.toml
25
26[dependencies]
27zstd = "0.5"
28```
29
30## 2 - Usage
31
32This library provides `Read` and `Write` wrappers to handle (de)compression,
33along with convenience functions to made common tasks easier.
34
35For instance, `stream::copy_encode` and `stream::copy_decode` are easy-to-use
36wrappers around `std::io::copy`. Check the [stream] example:
37
38```rust
39extern crate zstd;
40
41use std::io;
42
43// This function use the convenient `copy_encode` method
44fn compress(level: i32) {
45    zstd::stream::copy_encode(io::stdin(), io::stdout(), level).unwrap();
46}
47
48// This function does the same thing, directly using an `Encoder`:
49fn compress_manually(level: i32) {
50    let mut encoder = zstd::stream::Encoder::new(io::stdout(), level).unwrap();
51    io::copy(&mut io::stdin(), &mut encoder).unwrap();
52    encoder.finish().unwrap();
53}
54
55fn decompress() {
56    zstd::stream::copy_decode(io::stdin(), io::stdout()).unwrap();
57}
58```
59
60# Asynchronous support
61
62You can use this library to wrap non-blocking writer/readers:
63add the `tokio` feature, and `stream::Encoder` and `stream::Decoder`
64will implement `AsyncWrite` and `AsyncRead`, respectively.
65
66# Compile it yourself
67
68`zstd` is included as a submodule. To get everything during your clone, use:
69
70```
71git clone https://github.com/gyscos/zstd-rs --recursive
72```
73
74Or, if you cloned it without the `--recursive` flag,
75call this from inside the repository:
76
77```
78git submodule update --init
79```
80
81Then, running `cargo build` should take care
82of building the C library and linking to it.
83
84# Build-time bindgen
85
86This library includes a pre-generated `bindings.rs` file.
87You can also generate new bindings at build-time, using the `bindgen` feature:
88
89```
90cargo build --features bindgen
91```
92
93# TODO
94
95* Benchmarks, optimizations, ...
96
97# Disclaimer
98
99This implementation is largely inspired by bozaro's [lz4-rs].
100
101# License
102
103* The zstd C library is under a dual BSD/GPLv2 license.
104* This zstd-rs binding library is under a [MIT](LICENSE) license.
105
106[zstd]: https://github.com/facebook/zstd
107[lz4-rs]: https://github.com/bozaro/lz4-rs
108[cargo-edit]: https://github.com/killercup/cargo-edit#cargo-add
109[doc]: https://docs.rs/zstd
110[stream]: examples/stream.rs
111[submodule]: https://git-scm.com/book/en/v2/Git-Tools-Submodules
112