From dca1d6c6a4986ec1f760e13f05044141f3aa0680 Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Thu, 11 Sep 2025 11:57:14 -0300 Subject: [PATCH] fix: resolve compilation errors by adding Sync+Send bounds and fixing syntax Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) --- src/common/status.rs | 2 +- src/compression_engine.rs | 41 ++++++++++++++++++++++--------- src/compression_engine/none.rs | 9 +++---- src/compression_engine/program.rs | 2 +- src/lib.rs | 4 --- 5 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/common/status.rs b/src/common/status.rs index f6e0a60..3e48b00 100644 --- a/src/common/status.rs +++ b/src/common/status.rs @@ -65,7 +65,7 @@ pub fn generate_status_info( database: db_path.into_os_string().into_string().expect("Unable to convert DB path to string"), }; - let default_type = crate::compression_engine::default_compression_type(); + let _default_type = crate::compression_engine::default_compression_type(); let mut compression_info = Vec::new(); // Sort compression types by their string representation diff --git a/src/compression_engine.rs b/src/compression_engine.rs index daa5d88..c932e41 100755 --- a/src/compression_engine.rs +++ b/src/compression_engine.rs @@ -61,7 +61,7 @@ pub enum CompressionType { /// let engine = /* some engine */; /// let reader = engine.open("file.gz".into()).unwrap(); /// ``` -pub trait CompressionEngine { +pub trait CompressionEngine: Send + Sync { /// Opens a compressed file for reading. /// /// Creates a reader that transparently decompresses the file contents as they are read. @@ -156,22 +156,32 @@ pub trait CompressionEngine { writer.flush()?; Ok(()) } + + /// Clones this compression engine into a new boxed instance. + /// + /// Required for dynamic trait object cloning. + /// + /// # Returns + /// + /// A new `Box` clone of this engine. + fn clone_box(&self) -> Box; +} + +impl Clone for Box { + fn clone(&self) -> Self { + self.as_ref().clone_box() + } } lazy_static! { static ref COMPRESSION_ENGINES: EnumMap> = { - enum_map! { + let mut em = enum_map! { CompressionType::LZ4 => Box::new(crate::compression_engine::lz4::CompressionEngineLZ4::new()), - CompressionType::GZip => { - #[cfg(feature = "gzip")] - Box::new(crate::compression_engine::gzip::CompressionEngineGZip::new()), - #[cfg(not(feature = "gzip"))] - Box::new(crate::compression_engine::program::CompressionEngineProgram::new( - "gzip", - vec!["-c"], - vec!["-d", "-c"] - )) - }, + CompressionType::GZip => Box::new(crate::compression_engine::program::CompressionEngineProgram::new( + "gzip", + vec!["-c"], + vec!["-d", "-c"] + )), CompressionType::BZip2 => Box::new(crate::compression_engine::program::CompressionEngineProgram::new( "bzip2", vec!["-c"], @@ -188,7 +198,14 @@ lazy_static! { vec!["-d", "-c"] )), CompressionType::None => Box::new(crate::compression_engine::none::CompressionEngineNone::new()) + }; + + #[cfg(feature = "gzip")] + { + em[CompressionType::GZip] = Box::new(crate::compression_engine::gzip::CompressionEngineGZip::new()); } + + em }; } diff --git a/src/compression_engine/none.rs b/src/compression_engine/none.rs index 2da4378..47dcdd4 100644 --- a/src/compression_engine/none.rs +++ b/src/compression_engine/none.rs @@ -24,11 +24,6 @@ impl CompressionEngine for CompressionEngineNone { ("".to_string(), "".to_string(), "".to_string()) } - fn size(&self, file_path: PathBuf) -> Result { - let item_file_metadata = file_path.metadata()?; - Ok(item_file_metadata.len() as usize) - } - fn open(&self, file_path: PathBuf) -> Result> { debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self); Ok(Box::new(File::open(file_path)?)) @@ -38,4 +33,8 @@ impl CompressionEngine for CompressionEngineNone { debug!("COMPRESSION: Writing to {:?} using {:?}", file_path, *self); Ok(Box::new(File::create(file_path)?)) } + + fn clone_box(&self) -> Box { + Box::new(self.clone()) + } } diff --git a/src/compression_engine/program.rs b/src/compression_engine/program.rs index 0c59666..4234e16 100644 --- a/src/compression_engine/program.rs +++ b/src/compression_engine/program.rs @@ -161,7 +161,7 @@ impl CompressionEngine for CompressionEngineProgram { })) } - fn clone_box(&self) -> Box { + fn clone_box(&self) -> Box { Box::new(self.clone()) } } diff --git a/src/lib.rs b/src/lib.rs index 97ddc9f..d136536 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -36,10 +36,6 @@ pub mod services; pub mod db; pub mod meta_plugin; pub mod modes; -pub mod plugins; -pub mod args; -pub mod parser; - pub mod filter_plugin; // Re-export Args struct for library usage