#lzma #compression #decompression #xz #liblzma

rust-lzma

Simple interface for LZMA compression and decompression

7 releases (4 breaking)

Uses old Rust 2015

0.5.1 Nov 10, 2019
0.5.0 Nov 10, 2019
0.4.0 Nov 14, 2018
0.3.0 Jul 27, 2018
0.1.1 Feb 8, 2016

#78 in Compression

Download history 325/week @ 2022-06-13 412/week @ 2022-06-20 481/week @ 2022-06-27 345/week @ 2022-07-04 414/week @ 2022-07-11 407/week @ 2022-07-18 381/week @ 2022-07-25 1072/week @ 2022-08-01 988/week @ 2022-08-08 457/week @ 2022-08-15 992/week @ 2022-08-22 703/week @ 2022-08-29 678/week @ 2022-09-05 674/week @ 2022-09-12 646/week @ 2022-09-19 885/week @ 2022-09-26

2,951 downloads per month
Used in 39 crates (22 directly)

MIT license

140KB
400 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();
}

No runtime deps