use crate::position::Level; /// A trait describing the operations that make a type suitable for use as /// a leaf or node value in a merkle tree. pub trait Hashable: Sized { fn empty_leaf() -> Self; fn combine(level: Level, a: &Self, b: &Self) -> Self; fn empty_root(level: Level) -> Self { Level::from(0) .iter_to(level) .fold(Self::empty_leaf(), |v, lvl| Self::combine(lvl, &v, &v)) } }