scsys_crypto/hash/traits/
hasher.rs1pub trait Hasher {
8 type Output;
10 fn clean(&mut self) -> &mut Self;
12 fn finish(&self) -> crate::Result<Self::Output>;
14 fn include(&mut self, data: impl AsRef<[u8]>) -> &mut Self;
16}
17
18#[cfg(feature = "blake3")]
22use crate::hash::H256;
23
24#[cfg(feature = "blake3")]
25impl Hasher for blake3::Hasher {
26 type Output = H256;
27
28 fn clean(&mut self) -> &mut Self {
29 self.reset()
30 }
31
32 fn finish(&self) -> crate::Result<Self::Output> {
33 let hash = self.finalize();
35 Ok(hash.into())
37 }
38
39 fn include(&mut self, data: impl AsRef<[u8]>) -> &mut Self {
40 self.update(data.as_ref())
41 }
42}