Expand description
LZMA/XZ encoding and decoding streams
This library is a binding to liblzma currently to provide LZMA and xz
encoding/decoding streams. I/O streams are provided in the read
, write
,
and bufread
modules (same types, different bounds). Raw in-memory
compression/decompression is provided via the stream
module and contains
many of the raw APIs in liblzma.
§Examples
use liblzma::read::{XzDecoder, XzEncoder};
use std::io::prelude::*;
// Round trip some bytes from a byte source, into a compressor, into a
// decompressor, and finally into a vector.
let data = "Hello, World!".as_bytes();
let compressor = XzEncoder::new(data, 9);
let mut decompressor = XzDecoder::new(compressor);
let mut contents = String::new();
decompressor.read_to_string(&mut contents).unwrap();
assert_eq!(contents, "Hello, World!");
§Static linking
You can enable static-linking using the static
feature, so that the XZ
library is not required at runtime:
liblzma = { version = "0.4", features = ["static"] }
§Multithreading
This crate optionally can support multithreading using the parallel
feature of this crate:
liblzma = { version = "0.4", features = ["parallel"] }
§Async I/O
Dropped tokio
support since 0.4.0.
If you need to use async I/O, use async-compression
crate with lzma
feature flag.
async-compression = { version = "0.4", features = ["lzma"] }
Modules§
- bufread
- I/O streams for wrapping
BufRead
types as encoders/decoders - read
- Reader-based compression/decompression streams
- stream
- Raw in-memory LZMA streams.
- write
- Writer-based compression/decompression streams
Functions§
- copy_
decode - Decompress all data from the given source as if using a read::XzDecoder.
- copy_
encode - Compress all data from the given source as if using a read::XzEncoder.
- decode_
all - Decompress from the given source as if using a read::XzDecoder.
- encode_
all - Compress from the given source as if using a read::XzEncoder.
- uncompressed_
size - Find the size in bytes of uncompressed data from xz file.