1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
//! Rust binding to the [zstd library][zstd].
//!
//! This crate provides:
//!
//! * An [encoder](stream/write/struct.Encoder.html) to compress data using zstd
//! and send the output to another write.
//! * A [decoder](stream/read/struct.Decoder.html) to read input data from a `Read`
//! and decompress it.
//! * Convenient functions for common tasks.
//!
//! # Example
//!
//! ```no_run
//! use std::io;
//!
//! // Uncompress input and print the result.
//! zstd::stream::copy_decode(io::stdin(), io::stdout()).unwrap();
//! ```
//!
//! # Cargo features
//!
//! Enabled by default: `legacy`, `arrays`, `zdict_builder`.
//!
//! | Feature | Default | Description |
//! | --- | --- | --- |
//! | `arrays` | yes | Use fixed-size arrays (`[u8; N]`) as output buffers. |
//! | `legacy` | yes | Decode frames written by zstd versions older than 0.8. |
//! | `zdict_builder` | yes | Train new dictionaries. *Using* a dictionary always works. |
//! | `experimental` | | Expose zstd's experimental API, which has no stability guarantees. |
//! | `zstdmt` | | Multi-threaded compression inside the C library. |
//! | `thin` | | Build a smaller C library, at some cost in speed and error reporting. |
//! | `debug` | | Enable zstd's debug logs. |
//! | `no_asm` | | Do not build the x86-64 assembly. |
//! | `fat-lto`, `thin-lto` | | Cross-language LTO. Only works if `clang` builds the C library. |
//! | `bindgen` | | Generate the bindings at build time rather than using the pre-generated ones. |
//! | `pkg-config` | | Link against a system-installed libzstd instead of building the bundled source. |
//! | `vendored` | | Always build the bundled source, even when `pkg-config` is also enabled. |
//! | `cmake` | | Build the C library with zstd's own CMake files instead of the `cc` crate. |
//!
//! See the [readme] for more about the build-related ones.
//!
//! [zstd]: https://github.com/facebook/zstd
//! [readme]: https://github.com/gyscos/zstd-rs#cargo-features
// Re-export the zstd-safe crate.
pub use zstd_safe;
use io;
/// Default compression level.
pub use CLEVEL_DEFAULT as DEFAULT_COMPRESSION_LEVEL;
/// The accepted range of compression levels.
/// How large a buffer a compressed block might need, at worst.
///
/// This is what to reserve before [`bulk::compress_to_buffer()`], which writes
/// into a destination you provide rather than allocating one.
///
/// Re-exported from `zstd_safe`, where it lives alongside the rest of the
/// direct bindings.
pub use compress_bound;
pub use crate;
/// Returns the error message as io::Error based on error_code.
// Some helper functions to write full-cycle tests.