fix: implement debug for hasher and fix md5 update method
Co-authored-by: aider (openai/andrew/openrouter/deepseek/deepseek-chat-v3.1) <aider@aider.chat>
This commit is contained in:
@@ -1,18 +1,32 @@
|
|||||||
use sha2::{Digest, Sha256, Sha512};
|
use sha2::{Digest, Sha256, Sha512};
|
||||||
use md5;
|
use md5;
|
||||||
use crate::meta_plugin::MetaPlugin;
|
use crate::meta_plugin::MetaPlugin;
|
||||||
|
use std::fmt;
|
||||||
|
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Clone)]
|
||||||
enum Hasher {
|
enum Hasher {
|
||||||
Md5(md5::Context),
|
Md5(md5::Context),
|
||||||
Sha256(Sha256),
|
Sha256(Sha256),
|
||||||
Sha512(Sha512),
|
Sha512(Sha512),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Implement Debug manually since md5::Context doesn't implement it
|
||||||
|
impl fmt::Debug for Hasher {
|
||||||
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
|
match self {
|
||||||
|
Hasher::Md5(_) => write!(f, "Hasher::Md5"),
|
||||||
|
Hasher::Sha256(_) => write!(f, "Hasher::Sha256"),
|
||||||
|
Hasher::Sha512(_) => write!(f, "Hasher::Sha512"),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl Hasher {
|
impl Hasher {
|
||||||
fn update(&mut self, data: &[u8]) {
|
fn update(&mut self, data: &[u8]) {
|
||||||
match self {
|
match self {
|
||||||
Hasher::Md5(hasher) => hasher.update(data),
|
Hasher::Md5(hasher) => {
|
||||||
|
hasher.write(data);
|
||||||
|
},
|
||||||
Hasher::Sha256(hasher) => hasher.update(data),
|
Hasher::Sha256(hasher) => hasher.update(data),
|
||||||
Hasher::Sha512(hasher) => hasher.update(data),
|
Hasher::Sha512(hasher) => hasher.update(data),
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user