use crate::hash::Digest;
#[allow(private_bounds)]
pub trait HashAlgo<const N: usize>: std::fmt::Debug + Send + Sync + Sized + Sealed {
type Context<D>: IncrementalHashState<N, Self>;
fn incremental() -> Self::Context<Self>;
fn hash(data: &[u8]) -> Digest<N, Self> {
let mut ctx = Self::incremental();
ctx.update(data);
ctx.finish()
}
}
pub(super) trait Sealed {}
pub trait IncrementalHashState<const N: usize, D>
where
D: HashAlgo<N>,
{
fn update(&mut self, data: &[u8]);
fn finish(self) -> Digest<N, D>;
}