From cd6033ad3b2cdbd6a7a1d431f45b11cebcf0b22d Mon Sep 17 00:00:00 2001 From: Andrew Phillips Date: Tue, 19 Aug 2025 13:36:59 -0300 Subject: [PATCH] feat: add default_options method to all meta plugins Co-authored-by: aider (openai/andrew/openrouter/qwen/qwen3-coder) --- src/meta_plugin.rs | 6 ++++++ src/meta_plugin/binary.rs | 6 ++++++ src/meta_plugin/digest.rs | 12 ++++++++++++ src/meta_plugin/magic.rs | 6 ++++++ src/meta_plugin/program.rs | 4 ++++ src/meta_plugin/system.rs | 40 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 74 insertions(+) diff --git a/src/meta_plugin.rs b/src/meta_plugin.rs index 4bfb85f..e519a47 100644 --- a/src/meta_plugin.rs +++ b/src/meta_plugin.rs @@ -110,6 +110,12 @@ pub trait MetaPlugin { Vec::new() } + // Get the default options for this plugin + fn default_options(&self) -> std::collections::HashMap { + // Default implementation returns empty - plugins should override this + std::collections::HashMap::new() + } + // Save metadata to database using central output handler fn save_meta(&mut self, conn: &Connection, item_id: i64, internal_name: &str, value: String) -> Result<()> { output_metadata(conn, item_id, internal_name, value, self.outputs()) diff --git a/src/meta_plugin/binary.rs b/src/meta_plugin/binary.rs index a4baf1b..62d1537 100644 --- a/src/meta_plugin/binary.rs +++ b/src/meta_plugin/binary.rs @@ -103,4 +103,10 @@ impl MetaPlugin for BinaryMetaPlugin { fn default_outputs(&self) -> Vec { vec!["binary".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + let mut options = std::collections::HashMap::new(); + options.insert("max_buffer_size".to_string(), serde_yaml::Value::Number(4096.into())); + options + } } diff --git a/src/meta_plugin/digest.rs b/src/meta_plugin/digest.rs index 33690a4..addddb0 100644 --- a/src/meta_plugin/digest.rs +++ b/src/meta_plugin/digest.rs @@ -65,6 +65,10 @@ impl MetaPlugin for DigestSha256MetaPlugin { fn default_outputs(&self) -> Vec { vec!["digest_sha256".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } @@ -115,6 +119,10 @@ impl MetaPlugin for ReadTimeMetaPlugin { fn default_outputs(&self) -> Vec { vec!["read_time".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -167,4 +175,8 @@ impl MetaPlugin for ReadRateMetaPlugin { fn default_outputs(&self) -> Vec { vec!["read_rate".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } diff --git a/src/meta_plugin/magic.rs b/src/meta_plugin/magic.rs index 75e8c6e..7c37072 100644 --- a/src/meta_plugin/magic.rs +++ b/src/meta_plugin/magic.rs @@ -149,5 +149,11 @@ impl MetaPlugin for MagicFileMetaPlugin { fn default_outputs(&self) -> Vec { vec!["mime_type".to_string(), "mime_encoding".to_string(), "file_type".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + let mut options = std::collections::HashMap::new(); + options.insert("max_buffer_size".to_string(), serde_yaml::Value::Number(4096.into())); + options + } } diff --git a/src/meta_plugin/program.rs b/src/meta_plugin/program.rs index 5c47885..9df71b4 100644 --- a/src/meta_plugin/program.rs +++ b/src/meta_plugin/program.rs @@ -163,4 +163,8 @@ impl MetaPlugin for MetaPluginProgram { fn default_outputs(&self) -> Vec { vec![self.meta_name.clone()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } diff --git a/src/meta_plugin/system.rs b/src/meta_plugin/system.rs index 90242cb..e765524 100644 --- a/src/meta_plugin/system.rs +++ b/src/meta_plugin/system.rs @@ -66,6 +66,10 @@ impl MetaPlugin for CwdMetaPlugin { fn default_outputs(&self) -> Vec { vec!["cwd".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -121,6 +125,10 @@ impl MetaPlugin for UidMetaPlugin { fn default_outputs(&self) -> Vec { vec!["uid".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -179,6 +187,10 @@ impl MetaPlugin for UserMetaPlugin { fn default_outputs(&self) -> Vec { vec!["user".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -234,6 +246,10 @@ impl MetaPlugin for GidMetaPlugin { fn default_outputs(&self) -> Vec { vec!["gid".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -292,6 +308,10 @@ impl MetaPlugin for GroupMetaPlugin { fn default_outputs(&self) -> Vec { vec!["group".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -350,6 +370,10 @@ impl MetaPlugin for ShellMetaPlugin { fn default_outputs(&self) -> Vec { vec!["shell".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -408,6 +432,10 @@ impl MetaPlugin for ShellPidMetaPlugin { fn default_outputs(&self) -> Vec { vec!["shell_pid".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -463,6 +491,10 @@ impl MetaPlugin for KeepPidMetaPlugin { fn default_outputs(&self) -> Vec { vec!["keep_pid".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -521,6 +553,10 @@ impl MetaPlugin for HostnameMetaPlugin { fn default_outputs(&self) -> Vec { vec!["hostname".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } } #[derive(Debug, Clone, Default)] @@ -597,4 +633,8 @@ impl MetaPlugin for FullHostnameMetaPlugin { fn default_outputs(&self) -> Vec { vec!["full_hostname".to_string()] } + + fn default_options(&self) -> std::collections::HashMap { + std::collections::HashMap::new() + } }