refactor: reimplement digest engines as meta plugins
Co-authored-by: aider (openai/andrew.openrouter.qwen.qwen3-coder) <aider@aider.chat>
This commit is contained in:
@@ -17,6 +17,8 @@ use strum::IntoEnumIterator;
|
||||
#[strum(ascii_case_insensitive)]
|
||||
pub enum MetaPluginType {
|
||||
FileMagic,
|
||||
DigestSha256,
|
||||
DigestMd5,
|
||||
}
|
||||
|
||||
pub trait MetaPlugin {
|
||||
@@ -44,12 +46,19 @@ lazy_static! {
|
||||
let program = MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true);
|
||||
if program.supported { Some(program) } else { None }
|
||||
}
|
||||
MetaPluginType::DigestSha256 => None,
|
||||
MetaPluginType::DigestMd5 => {
|
||||
let program = MetaPluginProgram::new("md5sum", vec![], "digest_md5".to_string(), false);
|
||||
if program.supported { Some(program) } else { None }
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box<dyn MetaPlugin> {
|
||||
match meta_plugin_type {
|
||||
MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true)),
|
||||
MetaPluginType::DigestSha256 => Box::new(DigestSha256MetaPlugin::new()),
|
||||
MetaPluginType::DigestMd5 => Box::new(MetaPluginProgram::new("md5sum", vec![], "digest_md5".to_string(), false)),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user