Crate lzma [] [src]

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 LzmaReader and LzmaWriter documentation for further details on that interface. compress and decompress are documented here.

Examples

let test_string = "Like tears in rain".to_string();
let mut compressed = lzma::compress(&test_string.into_bytes(), 6).unwrap();
let decompressed = lzma::decompress(&mut compressed).unwrap();
let decompressed_str = String::from_utf8(decompressed).unwrap();

assert_eq!("Like tears in rain", decompressed_str);

Reexports

pub use reader::LzmaReader;
pub use writer::LzmaWriter;
pub use error::LzmaError;

Modules

error
lzma_stream_wrapper

Wraps the underlying FFI struct lzma_stream to provide various safety guarantees, like the Send trait.

lzma_sys
reader

This module implements LzmaReader.

writer

This module implements LzmaWriter.

Enums

Direction

Constants

EXTREME_PRESET

Functions

compress

Compress buf and return the result.

decompress

Decompress buf and return the result.