Skip to main content

Crate zstd

Crate zstd 

Source
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 Read and 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.

FeatureDefaultDescription
arraysyesUse fixed-size arrays ([u8; N]) as output buffers.
legacyyesDecode frames written by zstd versions older than 0.8.
zdict_builderyesTrain new dictionaries. Using a dictionary always works.
experimentalExpose zstd’s experimental API, which has no stability guarantees.
zstdmtMulti-threaded compression inside the C library.
thinBuild a smaller C library, at some cost in speed and error reporting.
debugEnable zstd’s debug logs.
no_asmDo not build the x86-64 assembly.
fat-lto, thin-ltoCross-language LTO. Only works if clang builds the C library.
bindgenGenerate the bindings at build time rather than using the pre-generated ones.
pkg-configLink against a system-installed libzstd instead of building the bundled source.
vendoredAlways build the bundled source, even when pkg-config is also enabled.
cmakeBuild 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.