#lzma #xz #decompression #liblzma #data-file #file-extension

sys rust-lzma

Simple interface for LZMA compression and decompression

8 releases (5 breaking)

Uses old Rust 2015

0.6.0 Apr 9, 2023
0.5.1 Nov 10, 2019
0.4.0 Nov 14, 2018
0.3.0 Jul 27, 2018
0.1.1 Feb 8, 2016

#246 in Compression

Download history 1118/week @ 2024-07-22 1150/week @ 2024-07-29 1109/week @ 2024-08-05 1101/week @ 2024-08-12 944/week @ 2024-08-19 1501/week @ 2024-08-26 1105/week @ 2024-09-02 1403/week @ 2024-09-09 1374/week @ 2024-09-16 1719/week @ 2024-09-23 1659/week @ 2024-09-30 1752/week @ 2024-10-07 1379/week @ 2024-10-14 2032/week @ 2024-10-21 1946/week @ 2024-10-28 1599/week @ 2024-11-04

7,004 downloads per month
Used in 39 crates (32 directly)

MIT license

140KB
422 lines

rust-lzma Build Status Crates.io

Documentation

This crate provides a simple interface to liblzma. LZMA is more commonly known as XZ or 7zip, (as in, files with the .xz or .7z file extension). LZMA compression is fast and aggressive, compressing better than bzip2. liblzma implements the XZ variant, so it can read and write .xz files/streams.

Two interfaces are provided. LzmaReader/LzmaWriter are generic Readers and Writers that can be composed with other Read/Write interfaces. For example, wrap them around a File and you can write data to a file while compressing it on the fly, or stream in an xz file from disk.

compress/decompress are easy to use functions for simple use cases.

See the documentation for details on usage.

Example

Cargo.toml:

[dependencies]
rust-lzma = "0.5"

main.rs:

extern crate lzma;

use lzma::LzmaWriter;
use std::io::prelude::*;
use std::fs::File;

fn main() {
	let f = File::create("foo.xz").unwrap();
	let mut f = LzmaWriter::new_compressor(f, 6).unwrap();

	write!(f, "It's a small world!").unwrap();
	f.finish().unwrap();
}

Dependencies