1#[doc(inline)]
6pub use self::{hasher::*, types::prelude::*};
7
8pub mod hasher;
9
10pub mod types {
11 #[doc(inline)]
12 pub use self::prelude::*;
13
14 pub mod h160;
15 pub mod h256;
16
17 pub(crate) mod prelude {
18 #[doc(inline)]
19 pub use super::aliases::*;
20 #[doc(inline)]
21 pub use super::h160::*;
22 #[doc(inline)]
23 pub use super::h256::*;
24 }
25
26 pub(crate) mod aliases {
27 use generic_array::GenericArray;
28 use typenum::{B0, B1, UInt, UTerm};
29 pub type GenericHashOutput =
31 UInt<UInt<UInt<UInt<UInt<UInt<UTerm, B1>, B0>, B0>, B0>, B0>, B0>;
32 pub type GenericHash<T = u8, Output = GenericHashOutput> = GenericArray<T, Output>;
34 }
35}
36
37pub(crate) mod prelude {
38 #[doc(inline)]
39 pub use super::RawHash;
40 #[doc(inline)]
41 pub use super::types::prelude::*;
42}
43
44pub trait RawHash {
45 private!();
46}
47
48pub trait SizedHash: RawHash {
49 const N: usize;
50}
51
52macro_rules! impl_raw_hash {
53 ($($t:ty),* $(,)?) => {
54 $(
55 impl_raw_hash!(@impl $t);
56 )*
57 };
58 ($($t:ty: $n:literal),* $(,)?) => {
59 $(
60 impl_raw_hash!(@sized $t => $n);
61 )*
62 };
63 (@impl $type:ty) => {
64 impl RawHash for $type {
65 seal!();
66 }
67 };
68 (@sized $type:ty => $n:literal) => {
69 impl RawHash for $type {
70 seal!();
71 }
72
73 impl SizedHash for $type {
74 const N: usize = $n;
75 }
76 };
77}
78
79impl_raw_hash! {
80 GenericHash,
81 [u8],
82}
83
84impl_raw_hash! {
85 [u8; 20]: 20,
86 [u8; 32]: 32,
87 H160: 20,
88 H256: 32,
89}
90
91#[cfg(feature = "alloc")]
92impl_raw_hash! {
93 alloc::vec::Vec<u8>,
94}