Crates.io | zstd-reusectx |
lib.rs | zstd-reusectx |
version | 0.15.1 |
source | src |
created_at | 2024-02-23 13:53:52.565675 |
updated_at | 2024-03-13 17:14:29.50878 |
description | Binding for the zstd compression library, with the ability to reuse compression contexts. |
homepage | |
repository | https://github.com/lordofpipes/zstd-reusectx |
max_upload_size | |
id | 1150601 |
size | 123,238 |
This library is a rust binding for the zstd compression library.
cargo.toml
$ cargo add zstd
# Cargo.toml
[dependencies]
zstd = "0.13"
This library provides Read
and Write
wrappers to handle (de)compression,
along with convenience functions to made common tasks easier.
For instance, stream::copy_encode
and stream::copy_decode
are easy-to-use
wrappers around std::io::copy
. Check the stream example:
use std::io;
// This function use the convenient `copy_encode` method
fn compress(level: i32) {
zstd::stream::copy_encode(io::stdin(), io::stdout(), level).unwrap();
}
// This function does the same thing, directly using an `Encoder`:
fn compress_manually(level: i32) {
let mut encoder = zstd::stream::Encoder::new(io::stdout(), level).unwrap();
io::copy(&mut io::stdin(), &mut encoder).unwrap();
encoder.finish().unwrap();
}
fn decompress() {
zstd::stream::copy_decode(io::stdin(), io::stdout()).unwrap();
}
The async-compression
crate
provides an async-ready integration of various compression algorithms,
including zstd-rs
.
zstd
is included as a submodule. To get everything during your clone, use:
git clone https://github.com/gyscos/zstd-rs --recursive
Or, if you cloned it without the --recursive
flag,
call this from inside the repository:
git submodule update --init
Then, running cargo build
should take care
of building the C library and linking to it.
This library includes a pre-generated bindings.rs
file.
You can also generate new bindings at build-time, using the bindgen
feature:
cargo build --features bindgen
This implementation is largely inspired by bozaro's lz4-rs.