1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
#![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)
}