diff --git a/src/meta_plugin/command.rs b/src/meta_plugin/command.rs index ca7e219..f054a43 100644 --- a/src/meta_plugin/command.rs +++ b/src/meta_plugin/command.rs @@ -5,6 +5,7 @@ use which::which; use crate::meta_plugin::{MetaPlugin, MetaPluginResponse, MetaPluginType}; +#[derive(Debug)] pub struct MetaPluginCommand { pub program: String, pub args: Vec, diff --git a/src/meta_plugin/digest.rs b/src/meta_plugin/digest.rs index 5bff1e1..09e58b9 100644 --- a/src/meta_plugin/digest.rs +++ b/src/meta_plugin/digest.rs @@ -1,16 +1,26 @@ use sha2::{Digest, Sha256, Sha512}; use md5; use crate::meta_plugin::{MetaPlugin, MetaPluginType}; -use std::fmt; use std::io::Write; -#[derive(Clone, Debug)] +#[derive(Clone)] enum Hasher { Md5(md5::Context), Sha256(Sha256), Sha512(Sha512), } +// Manual Debug implementation to avoid md5::Context not implementing Debug +impl std::fmt::Debug for Hasher { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self { + Hasher::Md5(_) => write!(f, "Hasher::Md5"), + Hasher::Sha256(_) => write!(f, "Hasher::Sha256"), + Hasher::Sha512(_) => write!(f, "Hasher::Sha512"), + } + } +} + impl Hasher { fn update(&mut self, data: &[u8]) { match self { @@ -56,6 +66,17 @@ pub struct DigestMetaPlugin { options: std::collections::HashMap, } +impl Default for DigestMetaPlugin { + fn default() -> Self { + Self { + hasher: None, + is_finalized: false, + outputs: std::collections::HashMap::new(), + options: std::collections::HashMap::new(), + } + } +} + impl DigestMetaPlugin { pub fn new(