p3_symmetric/
hasher.rs

1pub trait CryptographicHasher<Item: Clone, Out>: Clone {
2    fn hash_iter<I>(&self, input: I) -> Out
3    where
4        I: IntoIterator<Item = Item>;
5
6    fn hash_iter_slices<'a, I>(&self, input: I) -> Out
7    where
8        I: IntoIterator<Item = &'a [Item]>,
9        Item: 'a,
10    {
11        self.hash_iter(input.into_iter().flatten().cloned())
12    }
13
14    fn hash_slice(&self, input: &[Item]) -> Out {
15        self.hash_iter_slices(core::iter::once(input))
16    }
17
18    fn hash_item(&self, input: Item) -> Out {
19        self.hash_slice(&[input])
20    }
21}