pub trait HashType: Copy + Clone + Debug + Clone + Hash + PartialEq<Self> + Eq + PartialOrd<Self> + Ord {
fn get_prefix(self) -> &'static [u8] ⓘ;
fn try_from_prefix(prefix: &[u8]) -> Result<Self, HoloHashError>;
fn hash_name(self) -> &'static str;
}
Expand description
Every HoloHash is generic over HashType. Additionally, every HashableContent has an associated HashType. The HashType is the glue that binds together HashableContent with its hash.
Required Methods
sourcefn get_prefix(self) -> &'static [u8] ⓘ
fn get_prefix(self) -> &'static [u8] ⓘ
Get the 3-byte prefix for the underlying primitive hash type
sourcefn try_from_prefix(prefix: &[u8]) -> Result<Self, HoloHashError>
fn try_from_prefix(prefix: &[u8]) -> Result<Self, HoloHashError>
Given a 3-byte prefix, return the corresponding HashType, or error if mismatched. Trivial for PrimitiveHashType, but useful for composite types