Trait holochain_types::prelude::HashType
source · pub trait HashType: Copy + Clone + Debug + Clone + Hash + PartialEq + Eq + PartialOrd + Ord {
// Required methods
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
Object Safety§
This trait is not object safe.