Skip to content
Open
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
12 changes: 11 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ jobs:
- ""
- "--no-default-features --features deflate"
- "--no-default-features --features zstd"
- "--no-default-features --features zstd-rust"
- "--features zstd-rust"
steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
Expand All @@ -52,7 +54,7 @@ jobs:
default: true
- name: assert deps don't exist with --no-default-features
run: |
for DEP in libflate zstd; do
for DEP in libflate zstd structured-zstd; do
if cargo tree --no-default-features --invert $DEP; then
echo "Dependency $DEP should not exist with --no-default-features"
exit 1
Expand All @@ -70,3 +72,11 @@ jobs:
echo "Feature `zstd` should not create dep on `libflate`"
exit 1
fi
- name: assert `zstd-rust` feature doesn't create dep on the C zstd bindings
run: |
for DEP in zstd zstd-sys libflate; do
if cargo tree --no-default-features --features zstd-rust --invert $DEP; then
echo "Feature `zstd-rust` should not create dep on $DEP"
exit 1
fi
done
4 changes: 4 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ license = "Apache-2.0"
[workspace.dependencies]
libflate = "2.3.0"
zstd = "0.14.0"
structured-zstd = "0.0.59"

[package]
name = "include-flate"
Expand All @@ -34,4 +35,7 @@ include-flate-compress = { version = "0.3.4", path = "compress", default-feature
default = ["deflate", "zstd"]
deflate = ["include-flate-codegen/deflate", "include-flate-compress/deflate"]
zstd = ["include-flate-codegen/zstd", "include-flate-compress/zstd"]
# Zstandard through the pure-Rust `structured-zstd`, with no C toolchain,
# selected by `with zstd_rust`. Frames are interchangeable with `with zstd`.
zstd-rust = ["include-flate-codegen/zstd-rust", "include-flate-compress/zstd-rust"]
no-compression-warnings = ["include-flate-codegen/no-compression-warnings"]
1 change: 1 addition & 0 deletions codegen/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ proc-macro-error3 = "3.0.2"
default = ["deflate", "zstd"]
deflate = ["include-flate-compress/deflate"]
zstd = ["include-flate-compress/zstd"]
zstd-rust = ["include-flate-compress/zstd-rust"]
no-compression-warnings = []
13 changes: 13 additions & 0 deletions codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ pub fn deflate_utf8_file(ts: TokenStream) -> TokenStream {
/// flate!(pub static DATA: [u8] from "assets/009f.dat"); // default, DEFLATE
/// flate!(pub static DATA: [u8] from "assets/009f.dat" with zstd); // Use Zstd for this file spcifically
/// flate!(pub static DATA: [u8] from "assets/009f.dat" with deflate); // Explicitly use DEFLATE.
/// flate!(pub static DATA: [u8] from "assets/009f.dat" with zstd_rust); // Zstd without the C library
/// ```
struct FlateArgs {
path: syn::LitStr,
Expand Down Expand Up @@ -105,6 +106,17 @@ impl syn::parse::Parse for FlateArgs {
}
#[cfg(not(feature = "zstd"))]
return Err(Error::new(input.span(), "Please enable the `zstd` feature"));
} else if lookahead.peek(kw::zstd_rust) {
#[cfg(feature = "zstd-rust")]
{
input.parse::<kw::zstd_rust>()?;
Some(CompressionMethodTy(CompressionMethod::ZstdRust))
}
#[cfg(not(feature = "zstd-rust"))]
return Err(Error::new(
input.span(),
"Please enable the `zstd-rust` feature",
));
} else {
return Err(lookahead.error());
}
Expand All @@ -117,6 +129,7 @@ impl syn::parse::Parse for FlateArgs {
mod kw {
syn::custom_keyword!(deflate);
syn::custom_keyword!(zstd);
syn::custom_keyword!(zstd_rust);
}

#[derive(Debug, Default)]
Expand Down
4 changes: 4 additions & 0 deletions compress/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,12 @@ description = "Compression algorithm provider"
[dependencies]
libflate = { workspace = true, optional = true }
zstd = { workspace = true, optional = true }
structured-zstd = { workspace = true, optional = true }

[features]
default = ["deflate", "zstd"]
deflate = ["dep:libflate"]
zstd = ["dep:zstd"]
# Zstandard through the pure-Rust `structured-zstd`, as `CompressionMethod::ZstdRust`.
# Same frame format as `CompressionMethod::Zstd`.
zstd-rust = ["dep:structured-zstd"]
Loading