Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 46a204e

Browse files
committedAug 8, 2024··
Add config option to switch to unstable liblzma fork
1 parent ca2245c commit 46a204e

File tree

3 files changed

+36
-4
lines changed

3 files changed

+36
-4
lines changed
 

‎src/codec/xz2/decoder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
use std::{fmt, io};
22

3+
#[cfg(async_compression_unstable_liblzma_fork)]
4+
use liblzma::stream::{Action, Status, Stream};
5+
#[cfg(not(async_compression_unstable_liblzma_fork))]
36
use xz2::stream::{Action, Status, Stream};
47

58
use crate::{codec::Decode, util::PartialBuffer};

‎src/codec/xz2/encoder.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
use std::{fmt, io};
22

3+
#[cfg(not(async_compression_unstable_liblzma_fork))]
34
use xz2::stream::{Action, Check, LzmaOptions, Status, Stream};
5+
#[cfg(async_compression_unstable_liblzma_fork)]
6+
use liblzma::stream::{Action, Check, LzmaOptions, Status, Stream};
47

58
use crate::{
69
codec::{Encode, Xz2FileFormat},

‎tests/utils/algos.rs

+30-4
Original file line numberDiff line numberDiff line change
@@ -169,14 +169,22 @@ algos! {
169169
pub use crate::utils::impls::sync::to_vec;
170170

171171
pub fn compress(bytes: &[u8]) -> Vec<u8> {
172+
#[cfg(not(async_compression_unstable_liblzma_fork))]
172173
use xz2::bufread::XzEncoder;
173174

175+
#[cfg(async_compression_unstable_liblzma_fork)]
176+
use liblzma::bufread::XzEncoder;
177+
174178
to_vec(XzEncoder::new(bytes, 0))
175179
}
176180

177181
pub fn decompress(bytes: &[u8]) -> Vec<u8> {
182+
#[cfg(not(async_compression_unstable_liblzma_fork))]
178183
use xz2::bufread::XzDecoder;
179184

185+
#[cfg(async_compression_unstable_liblzma_fork)]
186+
use liblzma::bufread::XzDecoder;
187+
180188
to_vec(XzDecoder::new(bytes))
181189
}
182190
}
@@ -187,8 +195,17 @@ algos! {
187195
pub use crate::utils::impls::sync::to_vec;
188196

189197
pub fn compress(bytes: &[u8]) -> Vec<u8> {
190-
use xz2::bufread::XzEncoder;
191-
use xz2::stream::{LzmaOptions, Stream};
198+
#[cfg(not(async_compression_unstable_liblzma_fork))]
199+
use xz2::{
200+
bufread::XzEncoder,
201+
stream::{LzmaOptions, Stream},
202+
};
203+
204+
#[cfg(async_compression_unstable_liblzma_fork)]
205+
use liblzma::{
206+
bufread::XzEncoder,
207+
stream::{LzmaOptions, Stream},
208+
};
192209

193210
to_vec(XzEncoder::new_stream(
194211
bytes,
@@ -197,8 +214,17 @@ algos! {
197214
}
198215

199216
pub fn decompress(bytes: &[u8]) -> Vec<u8> {
200-
use xz2::bufread::XzDecoder;
201-
use xz2::stream::Stream;
217+
#[cfg(not(async_compression_unstable_liblzma_fork))]
218+
use xz2::{
219+
bufread::XzDecoder,
220+
stream::Stream,
221+
};
222+
223+
#[cfg(async_compression_unstable_liblzma_fork)]
224+
use liblzma::{
225+
bufread::XzDecoder,
226+
stream::Stream,
227+
};
202228

203229
to_vec(XzDecoder::new_stream(
204230
bytes,

0 commit comments

Comments
 (0)
Please sign in to comment.