fix: implement debug and default for meta plugin components

Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-08-27 21:55:29 -03:00
parent a909fdb2bd
commit db5b3153c0
2 changed files with 24 additions and 2 deletions

View File

@@ -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<String, serde_yaml::Value>,
}
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(