singlefile_formats/compression/
xz.rs1#![cfg_attr(docsrs, doc(cfg(feature = "xz")))]
2#![cfg(feature = "xz")]
3
4pub extern crate xz2 as original;
7
8use crate::compression::{CompressionFormat, CompressionFormatLevels};
9
10use std::io::{Read, Write};
11
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Default)]
15pub struct Xz;
16
17impl CompressionFormat for Xz {
18 type Encoder<W: Write> = xz2::write::XzEncoder::<W>;
19 type Decoder<R: Read> = xz2::read::XzDecoder::<R>;
20
21 fn encode_writer<W: Write>(&self, writer: W, compression: u32) -> Self::Encoder<W> {
22 Self::Encoder::new(writer, compression)
23 }
24
25 fn decode_reader<R: Read>(&self, reader: R) -> Self::Decoder<R> {
26 Self::Decoder::new(reader)
27 }
28}
29
30impl CompressionFormatLevels for Xz {
31 const COMPRESSION_LEVEL_NONE: u32 = 0;
32 const COMPRESSION_LEVEL_FAST: u32 = 1;
33 const COMPRESSION_LEVEL_BEST: u32 = 9;
34 const COMPRESSION_LEVEL_DEFAULT: u32 = 6;
35}