pub trait Hasher {
type Output;
fn clean(&mut self) -> &mut Self;
fn finish(&self) -> crate::Result<Self::Output>;
fn include(&mut self, data: impl AsRef<[u8]>) -> &mut Self;
}
#[cfg(feature = "blake3")]
use crate::hash::H256;
#[cfg(feature = "blake3")]
impl Hasher for blake3::Hasher {
type Output = H256;
fn clean(&mut self) -> &mut Self {
self.reset()
}
fn finish(&self) -> crate::Result<Self::Output> {
let hash = self.finalize();
Ok(hash.into())
}
fn include(&mut self, data: impl AsRef<[u8]>) -> &mut Self {
self.update(data.as_ref())
}
}