Expand description
Rust binding to the zstd library.
This crate provides:
- An encoder to compress data using zstd and send the output to another write.
- A decoder to read input data from a
Readand decompress it. - Convenient functions for common tasks.
§Example
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.
Re-exports§
pub use crate::stream::compress_file;pub use crate::stream::compress_file_into;pub use crate::stream::compress_sized;pub use crate::stream::compress_sized_into;pub use crate::stream::decode_all;pub use crate::stream::decompressed_size;pub use crate::stream::encode_all;pub use crate::stream::Decoder;pub use crate::stream::Encoder;pub use zstd_safe;
Modules§
- bulk
- Compress and decompress data in bulk.
- dict
- Train a dictionary from various sources.
- stream
- Compress and decompress Zstd streams.
Constants§
- DEFAULT_
COMPRESSION_ LEVEL - Default compression level.
Functions§
- compress_
bound - How large a buffer a compressed block might need, at worst.
- compression_
level_ range - The accepted range of compression levels.