noncrypto_digests/
common.rs1pub trait HashWrapper {
2 type Hasher;
3
4 fn from_hasher(hasher: Self::Hasher) -> Self;
5
6 fn get_hasher(&self) -> &Self::Hasher;
7
8 fn get_hasher_mut(&mut self) -> &mut Self::Hasher;
9}
10
11macro_rules! impl_hash_wrapper {
12 ($hash_wrapper:ident, $hasher:ty, $output_size:ident) => {
13 impl HashWrapper for $hash_wrapper {
14 type Hasher = $hasher;
15
16 fn from_hasher(hasher: Self::Hasher) -> Self {
17 Self(hasher)
18 }
19
20 fn get_hasher(&self) -> &Self::Hasher {
21 &self.0
22 }
23
24 fn get_hasher_mut(&mut self) -> &mut Self::Hasher {
25 &mut self.0
26 }
27 }
28
29 impl OutputSizeUser for $hash_wrapper {
30 type OutputSize = $output_size;
31 }
32
33 impl HashMarker for $hash_wrapper {}
34 };
35}
36
37pub(crate) use impl_hash_wrapper;