Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,14 @@ libzstd = { package = "zstd", version = "0.13.1", optional = true, default-featu
memchr = "2"
pin-project-lite = "0.2"
tokio = { version = "1.24.2", optional = true, default-features = false }
xz2 = { version = "0.1.6", optional = true }
zstd-safe = { version = "7", optional = true, default-features = false }
deflate64 = { version = "0.1.5", optional = true }

[target.'cfg(not(async_compression_unstable_liblzma_fork))'.dependencies]
xz2 = { version = "0.1.6", optional = true }
[target.'cfg(async_compression_unstable_liblzma_fork)'.dependencies]
xz2 = { package = "liblzma", version = "0.3.2", optional = true }

[dev-dependencies]
bytes = "1"
futures = "0.3.5"
Expand Down Expand Up @@ -103,3 +107,6 @@ required-features = ["zlib", "tokio"]
[[example]]
name = "zstd_gzip"
required-features = ["zstd", "gzip", "tokio"]

[lints.rust]
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(async_compression_unstable_liblzma_fork)'] }
3 changes: 3 additions & 0 deletions src/codec/xz2/decoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::{fmt, io};

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::stream::{Action, Status, Stream};
#[cfg(not(async_compression_unstable_liblzma_fork))]
use xz2::stream::{Action, Status, Stream};

use crate::{codec::Decode, util::PartialBuffer};
Expand Down
3 changes: 3 additions & 0 deletions src/codec/xz2/encoder.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
use std::{fmt, io};

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::stream::{Action, Check, LzmaOptions, Status, Stream};
#[cfg(not(async_compression_unstable_liblzma_fork))]
use xz2::stream::{Action, Check, LzmaOptions, Status, Stream};

use crate::{
Expand Down
34 changes: 30 additions & 4 deletions tests/utils/algos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,14 +169,22 @@ algos! {
pub use crate::utils::impls::sync::to_vec;

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

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::bufread::XzEncoder;

to_vec(XzEncoder::new(bytes, 0))
}

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

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::bufread::XzDecoder;

to_vec(XzDecoder::new(bytes))
}
}
Expand All @@ -187,8 +195,17 @@ algos! {
pub use crate::utils::impls::sync::to_vec;

pub fn compress(bytes: &[u8]) -> Vec<u8> {
use xz2::bufread::XzEncoder;
use xz2::stream::{LzmaOptions, Stream};
#[cfg(not(async_compression_unstable_liblzma_fork))]
use xz2::{
bufread::XzEncoder,
stream::{LzmaOptions, Stream},
};

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::{
bufread::XzEncoder,
stream::{LzmaOptions, Stream},
};

to_vec(XzEncoder::new_stream(
bytes,
Expand All @@ -197,8 +214,17 @@ algos! {
}

pub fn decompress(bytes: &[u8]) -> Vec<u8> {
use xz2::bufread::XzDecoder;
use xz2::stream::Stream;
#[cfg(not(async_compression_unstable_liblzma_fork))]
use xz2::{
bufread::XzDecoder,
stream::Stream,
};

#[cfg(async_compression_unstable_liblzma_fork)]
use liblzma::{
bufread::XzDecoder,
stream::Stream,
};

to_vec(XzDecoder::new_stream(
bytes,
Expand Down