1//! LZMA/XZ encoding and decoding streams
2//!
3//! This library is a binding to liblzma currently to provide LZMA and xz
4//! encoding/decoding streams. I/O streams are provided in the `read`, `write`,
5//! and `bufread` modules (same types, different bounds). Raw in-memory
6//! compression/decompression is provided via the `stream` module and contains
7//! many of the raw APIs in liblzma.
8//!
9//! # Examples
10//!
11//! ```
12//! use std::io::prelude::*;
13//! use xz2::read::{XzEncoder, XzDecoder};
14//!
15//! // Round trip some bytes from a byte source, into a compressor, into a
16//! // decompressor, and finally into a vector.
17//! let data = "Hello, World!".as_bytes();
18//! let compressor = XzEncoder::new(data, 9);
19//! let mut decompressor = XzDecoder::new(compressor);
20//!
21//! let mut contents = String::new();
22//! decompressor.read_to_string(&mut contents).unwrap();
23//! assert_eq!(contents, "Hello, World!");
24//! ```
25//!
26//! # Async I/O
27//!
28//! This crate optionally can support async I/O streams with the Tokio stack via
29//! the `tokio` feature of this crate:
30//!
31//! ```toml
32//! xz2 = { version = "0.1.6", features = ["tokio"] }
33//! ```
34//!
35//! All methods are internally capable of working with streams that may return
36//! `ErrorKind::WouldBlock` when they're not ready to perform the particular
37//! operation.
38//!
39//! Note that care needs to be taken when using these objects, however. The
40//! Tokio runtime, in particular, requires that data is fully flushed before
41//! dropping streams. For compatibility with blocking streams all streams are
42//! flushed/written when they are dropped, and this is not always a suitable
43//! time to perform I/O. If I/O streams are flushed before drop, however, then
44//! these operations will be a noop.
45
46#![deny(missing_docs)]
47#![doc(html_root_url = "https://docs.rs/xz2/0.1")]
48
49pub mod stream;
50
51pub mod bufread;
52pub mod read;
53pub mod write;
54