#![cfg_attr(docsrs, feature(doc_cfg, doc_cfg_hide))]
#![deny(missing_docs)]
#![deny(missing_debug_implementations)]
#![forbid(unsafe_code)]
#[macro_use]
mod macros;
mod decode;
mod encode;
pub mod error;
mod util;
mod xz;
use std::io;
pub mod compress {
pub use crate::encode::options::*;
}
pub mod decompress {
pub use crate::decode::options::*;
#[cfg(feature = "raw_decoder")]
#[cfg_attr(docsrs, doc(cfg(raw_decoder)))]
pub mod raw {
pub use crate::decode::lzma::{LzmaDecoder, LzmaParams, LzmaProperties};
pub use crate::decode::lzma2::Lzma2Decoder;
}
#[cfg(feature = "stream")]
#[cfg_attr(docsrs, doc(cfg(stream)))]
pub use crate::decode::stream::Stream;
}
pub fn lzma_decompress<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
) -> error::Result<()> {
lzma_decompress_with_options(input, output, &decompress::Options::default())
}
pub fn lzma_decompress_with_options<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
options: &decompress::Options,
) -> error::Result<()> {
let params = decode::lzma::LzmaParams::read_header(input, options)?;
let mut decoder = decode::lzma::LzmaDecoder::new(params, options.memlimit)?;
decoder.decompress(input, output)
}
pub fn lzma_compress<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
) -> io::Result<()> {
lzma_compress_with_options(input, output, &compress::Options::default())
}
pub fn lzma_compress_with_options<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
options: &compress::Options,
) -> io::Result<()> {
let encoder = encode::dumbencoder::Encoder::from_stream(output, options)?;
encoder.process(input)
}
pub fn lzma2_decompress<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
) -> error::Result<()> {
decode::lzma2::Lzma2Decoder::new().decompress(input, output)
}
pub fn lzma2_compress<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
) -> io::Result<()> {
encode::lzma2::encode_stream(input, output)
}
pub fn xz_decompress<R: io::BufRead, W: io::Write>(
input: &mut R,
output: &mut W,
) -> error::Result<()> {
decode::xz::decode_stream(input, output)
}
pub fn xz_compress<R: io::BufRead, W: io::Write>(input: &mut R, output: &mut W) -> io::Result<()> {
encode::xz::encode_stream(input, output)
}