1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
pub trait Hasher { type Output; fn new() -> Self; fn update(&mut self, data: &[u8]); fn finalize(self) -> Self::Output; fn compute(data: &[u8]) -> Self::Output where Self: Sized, { let mut hasher = Self::new(); hasher.update(data); hasher.finalize() } }