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:
@@ -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"),
|
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();
|
let mut compression_info = Vec::new();
|
||||||
|
|
||||||
// Sort compression types by their string representation
|
// Sort compression types by their string representation
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ pub enum CompressionType {
|
|||||||
/// let engine = /* some engine */;
|
/// let engine = /* some engine */;
|
||||||
/// let reader = engine.open("file.gz".into()).unwrap();
|
/// let reader = engine.open("file.gz".into()).unwrap();
|
||||||
/// ```
|
/// ```
|
||||||
pub trait CompressionEngine {
|
pub trait CompressionEngine: Send + Sync {
|
||||||
/// Opens a compressed file for reading.
|
/// Opens a compressed file for reading.
|
||||||
///
|
///
|
||||||
/// Creates a reader that transparently decompresses the file contents as they are read.
|
/// Creates a reader that transparently decompresses the file contents as they are read.
|
||||||
@@ -156,22 +156,32 @@ pub trait CompressionEngine {
|
|||||||
writer.flush()?;
|
writer.flush()?;
|
||||||
Ok(())
|
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! {
|
lazy_static! {
|
||||||
static ref COMPRESSION_ENGINES: EnumMap<CompressionType, Box<dyn CompressionEngine>> = {
|
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::LZ4 => Box::new(crate::compression_engine::lz4::CompressionEngineLZ4::new()),
|
||||||
CompressionType::GZip => {
|
CompressionType::GZip => Box::new(crate::compression_engine::program::CompressionEngineProgram::new(
|
||||||
#[cfg(feature = "gzip")]
|
|
||||||
Box::new(crate::compression_engine::gzip::CompressionEngineGZip::new()),
|
|
||||||
#[cfg(not(feature = "gzip"))]
|
|
||||||
Box::new(crate::compression_engine::program::CompressionEngineProgram::new(
|
|
||||||
"gzip",
|
"gzip",
|
||||||
vec!["-c"],
|
vec!["-c"],
|
||||||
vec!["-d", "-c"]
|
vec!["-d", "-c"]
|
||||||
))
|
)),
|
||||||
},
|
|
||||||
CompressionType::BZip2 => Box::new(crate::compression_engine::program::CompressionEngineProgram::new(
|
CompressionType::BZip2 => Box::new(crate::compression_engine::program::CompressionEngineProgram::new(
|
||||||
"bzip2",
|
"bzip2",
|
||||||
vec!["-c"],
|
vec!["-c"],
|
||||||
@@ -188,7 +198,14 @@ lazy_static! {
|
|||||||
vec!["-d", "-c"]
|
vec!["-d", "-c"]
|
||||||
)),
|
)),
|
||||||
CompressionType::None => Box::new(crate::compression_engine::none::CompressionEngineNone::new())
|
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
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -24,11 +24,6 @@ impl CompressionEngine for CompressionEngineNone {
|
|||||||
("<INTERNAL>".to_string(), "".to_string(), "".to_string())
|
("<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>> {
|
fn open(&self, file_path: PathBuf) -> Result<Box<dyn Read>> {
|
||||||
debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self);
|
debug!("COMPRESSION: Opening {:?} using {:?}", file_path, *self);
|
||||||
Ok(Box::new(File::open(file_path)?))
|
Ok(Box::new(File::open(file_path)?))
|
||||||
@@ -38,4 +33,8 @@ impl CompressionEngine for CompressionEngineNone {
|
|||||||
debug!("COMPRESSION: Writing to {:?} using {:?}", file_path, *self);
|
debug!("COMPRESSION: Writing to {:?} using {:?}", file_path, *self);
|
||||||
Ok(Box::new(File::create(file_path)?))
|
Ok(Box::new(File::create(file_path)?))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn clone_box(&self) -> Box<dyn CompressionEngine> {
|
||||||
|
Box::new(self.clone())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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())
|
Box::new(self.clone())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,10 +36,6 @@ pub mod services;
|
|||||||
pub mod db;
|
pub mod db;
|
||||||
pub mod meta_plugin;
|
pub mod meta_plugin;
|
||||||
pub mod modes;
|
pub mod modes;
|
||||||
pub mod plugins;
|
|
||||||
pub mod args;
|
|
||||||
pub mod parser;
|
|
||||||
|
|
||||||
pub mod filter_plugin;
|
pub mod filter_plugin;
|
||||||
|
|
||||||
// Re-export Args struct for library usage
|
// Re-export Args struct for library usage
|
||||||
|
|||||||
Reference in New Issue
Block a user