xz
xz provides xz2/liblzma-compatible APIs backed by a pure Rust implementation
of xz. Its core was built from a c2rust translation of the upstream xz codebase,
then cleaned up to remove translation scaffolding and unnecessary C-shaped
overhead. Unlike xz2 or liblzma, xz lets applications eliminate the C
dependency completely while using a Rust-only xz implementation, and it is a
little faster in current benchmarks.
This crate is forked from liblzma and xz = "0.4.x" is fully compatible with liblzma = "0.4.6",
so you can migrate simply.
Migrate from liblzma
# Cargo.toml
[dependencies]
-liblzma = "0.4.6"
+xz = "0.4.6"
// *.rs
-use liblzma;
+use xz;
Version 0.2.x breaking changes
- XZ upgraded to 5.4
- Multithreading is disabled by default.
This feature is available by enabling the
parallelfeature - Support for compiling to WebAssembly
Version 0.3.x breaking changes
- XZ upgraded to 5.6
Version 0.4.x breaking changes
- XZ upgraded to 5.8
- Dropped
tokiosupport (If you need async I/O, useasync-compressioncrate withlzmafeature flag)
Crates and backend selection
This repository contains three pure Rust crates:
xz-coreis a direct port of the xz C library internals.xz-sysis a C ABI compatibility layer backed byxz-core. It is intended to be compatible withxz2-sysandliblzma-sys, and should be easy to link from C as a liblzma-compatible library.xzis the high-level Rust interface intended as a replacement forxz2andliblzma.
The high-level xz crate defaults to the pure Rust xz-core backend. You can
disable default features and choose exactly one backend explicitly:
xz-corecalls the pure Rust core directly.xz-syscalls the pure Rust core through the liblzma-compatible C ABI layer.liblzma-syscalls the external C liblzma implementation through theliblzma-syscrate. Use it when you need the C backend instead of the bundled Rust implementation.
To use the original C backend:
= { = "0.4", = false, = ["liblzma-sys"] }
License
This project is licensed under either of
- Apache License, Version 2.0, (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in xz by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.