diff --git a/src/meta_plugin.rs b/src/meta_plugin.rs index 62fe622..1797212 100644 --- a/src/meta_plugin.rs +++ b/src/meta_plugin.rs @@ -30,6 +30,10 @@ pub trait MetaPlugin { fn update(&mut self, data: &[u8]); fn meta_name(&mut self) -> String; + + fn is_default(&self) -> bool { + false + } } use std::io::Write; @@ -37,7 +41,7 @@ use std::io::Write; lazy_static! { pub static ref META_PLUGIN_PROGRAMS: EnumMap> = enum_map! { MetaPluginType::FileMagic => { - let program = MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string()); + let program = MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true); if program.supported { Some(program) } else { None } } }; @@ -45,7 +49,7 @@ lazy_static! { pub fn get_meta_plugin(meta_plugin_type: MetaPluginType) -> Box { match meta_plugin_type { - MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string())), + MetaPluginType::FileMagic => Box::new(MetaPluginProgram::new("file", vec!["-bE", "-"], "file_magic".to_string(), true)), } } diff --git a/src/meta_plugin/program.rs b/src/meta_plugin/program.rs index ce41e7d..872b88b 100644 --- a/src/meta_plugin/program.rs +++ b/src/meta_plugin/program.rs @@ -16,10 +16,11 @@ pub struct MetaPluginProgram { pub args: Vec, pub supported: bool, pub meta_name: String, + pub is_default: bool, } impl MetaPluginProgram { - pub fn new(program: &str, args: Vec<&str>, meta_name: String) -> MetaPluginProgram { + pub fn new(program: &str, args: Vec<&str>, meta_name: String, is_default: bool) -> MetaPluginProgram { let program_path = get_program_path(program); let supported = program_path.is_ok(); @@ -28,6 +29,7 @@ impl MetaPluginProgram { args: args.iter().map(|s| s.to_string()).collect(), supported, meta_name, + is_default, } } } @@ -72,6 +74,10 @@ impl MetaPlugin for MetaPluginProgram { fn meta_name(&mut self) -> String { self.meta_name.clone() } + + fn is_default(&self) -> bool { + self.is_default + } } fn get_program_path(program: &str) -> Result {