#lzma #xz #encoding

xz2

Rust bindings to liblzma providing Read/Write streams as well as low-level in-memory encoding/decoding.

5 releases

0.1.4 Dec 31, 2017
0.1.3 Apr 12, 2017
0.1.2 Apr 10, 2017
0.1.1 Jan 20, 2017
0.1.0 Mar 21, 2016

#3 in Compression

Download history 5415/week @ 2018-05-06 7298/week @ 2018-05-13 6595/week @ 2018-05-20 6389/week @ 2018-05-27 6737/week @ 2018-06-03 6724/week @ 2018-06-10 5491/week @ 2018-06-17 5896/week @ 2018-06-24 7465/week @ 2018-07-01 6936/week @ 2018-07-08 7751/week @ 2018-07-15 8544/week @ 2018-07-22 6059/week @ 2018-07-29

23,707 downloads per month

xz2

Build Status Build status

Documentation

Bindings to the liblzma implementation in Rust, also provides types to read/write xz streams.

# Cargo.toml
[dependencies]
xz2 = "0.1"

License

This project is licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in Serde by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.


lib.rs:

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 std::io::prelude::*;
use xz2::read::{XzEncoder, XzDecoder};

// 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!");

Async I/O

This crate optionally can support async I/O streams with the Tokio stack via the tokio feature of this crate:

xz2 = { version = "0.3", features = ["tokio"] }

All methods are internally capable of working with streams that may return ErrorKind::WouldBlock when they're not ready to perform the particular operation.

Note that care needs to be taken when using these objects, however. The Tokio runtime, in particular, requires that data is fully flushed before dropping streams. For compatibility with blocking streams all streams are flushed/written when they are dropped, and this is not always a suitable time to perform I/O. If I/O streams are flushed before drop, however, then these operations will be a noop.

MIT/Apache-2.0 license

Dependencies

Reverse deps