fix: resolve compilation errors by adding Sync+Send bounds and fixing syntax

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-11 11:57:14 -03:00
parent 4dcbb7c942
commit dca1d6c6a4
5 changed files with 35 additions and 23 deletions

View File

@@ -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

View File

@@ -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<dyn CompressionEngine>` clone of this engine.
fn clone_box(&self) -> Box<dyn CompressionEngine>;
}
impl Clone for Box<dyn CompressionEngine> {
fn clone(&self) -> Self {
self.as_ref().clone_box()
}
}
lazy_static! {
static ref COMPRESSION_ENGINES: EnumMap<CompressionType, Box<dyn CompressionEngine>> = {
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
};
}

View File

@@ -24,11 +24,6 @@ impl CompressionEngine for CompressionEngineNone {
("<INTERNAL>".to_string(), "".to_string(), "".to_string())
}
fn size(&self, file_path: PathBuf) -> Result<usize> {
let item_file_metadata = file_path.metadata()?;
Ok(item_file_metadata.len() as usize)
}
fn open(&self, file_path: PathBuf) -> Result<Box<dyn Read>> {
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<dyn CompressionEngine> {
Box::new(self.clone())
}
}

View File

@@ -161,7 +161,7 @@ impl CompressionEngine for CompressionEngineProgram {
}))
}
fn clone_box(&self) -> Box<dyn CompressionEngine + Send + Sync> {
fn clone_box(&self) -> Box<dyn CompressionEngine> {
Box::new(self.clone())
}
}

View File

@@ -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