From 2a131e67a9a7e82348f8ee19799932962dd34f40 Mon Sep 17 00:00:00 2001 From: Chris Hennick <4961925+Pr0methean@users.noreply.github.com> Date: Sun, 2 Jun 2024 17:29:49 -0700 Subject: [PATCH] fix: Use deflate-flate2 flag to guard import --- examples/write_dir.rs | 6 +++--- src/read.rs | 6 +----- src/write.rs | 24 ++++-------------------- 3 files changed, 8 insertions(+), 28 deletions(-) diff --git a/examples/write_dir.rs b/examples/write_dir.rs index 5475f7bc..5fe41dc8 100644 --- a/examples/write_dir.rs +++ b/examples/write_dir.rs @@ -42,12 +42,12 @@ fn real_main() -> i32 { let method = match args.compression_method { CompressionMethod::Stored => zip::CompressionMethod::Stored, CompressionMethod::Deflated => { - #[cfg(not(feature = "deflate"))] + #[cfg(not(feature = "deflate-flate2"))] { - println!("The `deflate` feature is not enabled"); + println!("The `deflate-flate2` feature is not enabled"); return 1; } - #[cfg(feature = "deflate")] + #[cfg(feature = "deflate-flate2")] zip::CompressionMethod::Deflated } CompressionMethod::DeflatedZlib => { diff --git a/src/read.rs b/src/read.rs index 94ed2366..15c1319e 100644 --- a/src/read.rs +++ b/src/read.rs @@ -24,11 +24,7 @@ use std::ops::Deref; use std::path::{Path, PathBuf}; use std::sync::{Arc, OnceLock}; -#[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" -))] +#[cfg(feature = "deflate-flate2")] use flate2::read::DeflateDecoder; #[cfg(feature = "deflate64")] diff --git a/src/write.rs b/src/write.rs index b6fbf883..2b10f634 100644 --- a/src/write.rs +++ b/src/write.rs @@ -27,11 +27,7 @@ use std::mem; use std::str::{from_utf8, Utf8Error}; use std::sync::Arc; -#[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" -))] +#[cfg(feature = "deflate-flate2")] use flate2::{write::DeflateEncoder, Compression}; #[cfg(feature = "bzip2")] @@ -1569,11 +1565,7 @@ impl GenericZipWriter { } } - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng", - ))] + #[cfg(feature = "deflate-flate2")] { Ok(Box::new(move |bare| { GenericZipWriter::Deflater(DeflateEncoder::new( @@ -1633,11 +1625,7 @@ impl GenericZipWriter { fn switch_to(&mut self, make_new_self: SwitchWriterFunction) -> ZipResult<()> { let bare = match mem::replace(self, Closed) { Storer(w) => w, - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" - ))] + #[cfg(feature = "deflate-flate2")] GenericZipWriter::Deflater(w) => w.finish()?, #[cfg(feature = "deflate-zopfli")] GenericZipWriter::ZopfliDeflater(w) => w.finish()?, @@ -1665,11 +1653,7 @@ impl GenericZipWriter { fn ref_mut(&mut self) -> Option<&mut dyn Write> { match self { Storer(ref mut w) => Some(w as &mut dyn Write), - #[cfg(any( - feature = "deflate", - feature = "deflate-zlib", - feature = "deflate-zlib-ng" - ))] + #[cfg(feature = "deflate-flate2")] GenericZipWriter::Deflater(ref mut w) => Some(w as &mut dyn Write), #[cfg(feature = "deflate-zopfli")] GenericZipWriter::ZopfliDeflater(w) => Some(w as &mut dyn Write),