Debian Codegraph @

Readme.md

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