pub struct HoloHash<T: HashType> { /* private fields */ }Expand description
A HoloHash contains a vector of 36 bytes representing a 32-byte blake2b hash plus 4 bytes representing a DHT location. It also contains a zero-sized type which specifies what it is a hash of.
There is custom de/serialization implemented in [ser.rs]
Implementations§
Source§impl HoloHash<AnyLinkable>
impl HoloHash<AnyLinkable>
Sourcepub fn into_primitive(self) -> AnyLinkableHashPrimitive
pub fn into_primitive(self) -> AnyLinkableHashPrimitive
Match on the primitive hash type represented by this composite hash type
Sourcepub fn into_any_dht_hash(self) -> Option<AnyDhtHash>
pub fn into_any_dht_hash(self) -> Option<AnyDhtHash>
Downcast to AnyDhtHash if this is not an external hash
Sourcepub fn into_action_hash(self) -> Option<ActionHash>
pub fn into_action_hash(self) -> Option<ActionHash>
If this hash represents an ActionHash, return it, else None
Sourcepub fn into_entry_hash(self) -> Option<EntryHash>
pub fn into_entry_hash(self) -> Option<EntryHash>
If this hash represents an EntryHash, return it, else None
Sourcepub fn into_agent_pub_key(self) -> Option<AgentPubKey>
pub fn into_agent_pub_key(self) -> Option<AgentPubKey>
If this hash represents an EntryHash which is actually an AgentPubKey, return it, else None.
Sourcepub fn into_external_hash(self) -> Option<ExternalHash>
pub fn into_external_hash(self) -> Option<ExternalHash>
If this hash represents an ExternalHash, return it, else None
Source§impl HoloHash<AnyDht>
impl HoloHash<AnyDht>
Sourcepub fn into_primitive(self) -> AnyDhtHashPrimitive
pub fn into_primitive(self) -> AnyDhtHashPrimitive
Match on the primitive hash type represented by this composite hash type
Sourcepub fn into_action_hash(self) -> Option<ActionHash>
pub fn into_action_hash(self) -> Option<ActionHash>
If this hash represents an ActionHash, return it, else None
Sourcepub fn into_entry_hash(self) -> Option<EntryHash>
pub fn into_entry_hash(self) -> Option<EntryHash>
If this hash represents an EntryHash, return it, else None
Sourcepub fn into_agent_pub_key(self) -> Option<AgentPubKey>
pub fn into_agent_pub_key(self) -> Option<AgentPubKey>
If this hash represents an EntryHash which is actually an AgentPubKey, return it, else None.
Source§impl<T: HashType> HoloHash<T>
impl<T: HashType> HoloHash<T>
Sourcepub fn try_from_raw_39(hash: Vec<u8>) -> HoloHashResult<Self>
pub fn try_from_raw_39(hash: Vec<u8>) -> HoloHashResult<Self>
Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type
Sourcepub fn from_raw_39(hash: Vec<u8>) -> Self
pub fn from_raw_39(hash: Vec<u8>) -> Self
Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type. Panics if hash_type does not match or hash is incorrect length.
Sourcepub fn try_from_raw_36_and_type(
bytes: Vec<u8>,
hash_type: T,
) -> HoloHashResult<Self>
pub fn try_from_raw_36_and_type( bytes: Vec<u8>, hash_type: T, ) -> HoloHashResult<Self>
Use a precomputed hash + location byte array in vec form, along with a type, to construct a hash.
Sourcepub fn from_raw_36_and_type(bytes: Vec<u8>, hash_type: T) -> Self
pub fn from_raw_36_and_type(bytes: Vec<u8>, hash_type: T) -> Self
Use a precomputed hash + location byte array in vec form, along with a type, to construct a hash. Panics hash is incorrect length.
Sourcepub fn get_raw_39(&self) -> &[u8] ⓘ
pub fn get_raw_39(&self) -> &[u8] ⓘ
Get the raw 39-byte Vec including the 3 byte prefix, base 32 bytes, and the 4 byte loc
Sourcepub fn get_raw_36(&self) -> &[u8] ⓘ
pub fn get_raw_36(&self) -> &[u8] ⓘ
Get 36-byte Vec which excludes the 3 byte prefix
Sourcepub fn get_raw_32(&self) -> &[u8] ⓘ
pub fn get_raw_32(&self) -> &[u8] ⓘ
Fetch just the core 32 bytes (without the 4 location bytes)
Sourcepub fn into_inner(self) -> Vec<u8> ⓘ
pub fn into_inner(self) -> Vec<u8> ⓘ
consume into the inner byte vector
Source§impl<P: PrimitiveHashType> HoloHash<P>
impl<P: PrimitiveHashType> HoloHash<P>
Sourcepub fn from_raw_36(hash: Vec<u8>) -> Self
pub fn from_raw_36(hash: Vec<u8>) -> Self
Construct from 36 raw bytes, using the known PrimitiveHashType
Trait Implementations§
Source§impl<'de, T: HashType> Deserialize<'de> for HoloHash<T>
impl<'de, T: HashType> Deserialize<'de> for HoloHash<T>
Source§fn deserialize<D>(deserializer: D) -> Result<HoloHash<T>, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<HoloHash<T>, D::Error>where
D: Deserializer<'de>,
Source§impl From<HoloHash<Action>> for AnyDhtHash
impl From<HoloHash<Action>> for AnyDhtHash
Source§fn from(hash: ActionHash) -> Self
fn from(hash: ActionHash) -> Self
Source§impl From<HoloHash<Action>> for AnyLinkableHash
impl From<HoloHash<Action>> for AnyLinkableHash
Source§fn from(hash: ActionHash) -> Self
fn from(hash: ActionHash) -> Self
Source§impl From<HoloHash<Agent>> for AnyDhtHash
impl From<HoloHash<Agent>> for AnyDhtHash
Source§fn from(hash: AgentPubKey) -> Self
fn from(hash: AgentPubKey) -> Self
Source§impl From<HoloHash<Agent>> for AnyLinkableHash
impl From<HoloHash<Agent>> for AnyLinkableHash
Source§fn from(hash: AgentPubKey) -> Self
fn from(hash: AgentPubKey) -> Self
Source§impl From<HoloHash<Agent>> for EntryHash
impl From<HoloHash<Agent>> for EntryHash
Source§fn from(hash: AgentPubKey) -> EntryHash
fn from(hash: AgentPubKey) -> EntryHash
Source§impl From<HoloHash<AnyDht>> for AnyLinkableHash
impl From<HoloHash<AnyDht>> for AnyLinkableHash
Source§fn from(hash: AnyDhtHash) -> Self
fn from(hash: AnyDhtHash) -> Self
Source§impl From<HoloHash<Entry>> for AgentPubKey
impl From<HoloHash<Entry>> for AgentPubKey
Source§fn from(hash: EntryHash) -> AgentPubKey
fn from(hash: EntryHash) -> AgentPubKey
Source§impl From<HoloHash<External>> for AnyLinkableHash
impl From<HoloHash<External>> for AnyLinkableHash
Source§fn from(hash: ExternalHash) -> Self
fn from(hash: ExternalHash) -> Self
Source§impl<T: HashType> IntoIterator for HoloHash<T>
impl<T: HashType> IntoIterator for HoloHash<T>
Source§impl<T: Ord + HashType> Ord for HoloHash<T>
impl<T: Ord + HashType> Ord for HoloHash<T>
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl<T: PartialOrd + HashType> PartialOrd for HoloHash<T>
impl<T: PartialOrd + HashType> PartialOrd for HoloHash<T>
Source§impl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
impl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(t: &HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: &HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
Source§impl TryFrom<HoloHash<AnyLinkable>> for ActionHash
impl TryFrom<HoloHash<AnyLinkable>> for ActionHash
Source§type Error = HashConversionError<AnyLinkable, Action>
type Error = HashConversionError<AnyLinkable, Action>
Source§impl TryFrom<HoloHash<AnyLinkable>> for AgentPubKey
impl TryFrom<HoloHash<AnyLinkable>> for AgentPubKey
Source§type Error = HashConversionError<AnyLinkable, Agent>
type Error = HashConversionError<AnyLinkable, Agent>
Source§impl TryFrom<HoloHash<AnyLinkable>> for AnyDhtHash
impl TryFrom<HoloHash<AnyLinkable>> for AnyDhtHash
Source§type Error = CompositeHashConversionError<AnyLinkable>
type Error = CompositeHashConversionError<AnyLinkable>
Source§impl TryFrom<HoloHash<AnyLinkable>> for EntryHash
impl TryFrom<HoloHash<AnyLinkable>> for EntryHash
Source§type Error = HashConversionError<AnyLinkable, Entry>
type Error = HashConversionError<AnyLinkable, Entry>
Source§impl TryFrom<HoloHash<AnyLinkable>> for ExternalHash
impl TryFrom<HoloHash<AnyLinkable>> for ExternalHash
Source§type Error = HashConversionError<AnyLinkable, External>
type Error = HashConversionError<AnyLinkable, External>
Source§impl<T: HashType> TryFrom<HoloHash<T>> for SerializedBytes
impl<T: HashType> TryFrom<HoloHash<T>> for SerializedBytes
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(t: HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
Source§impl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>
impl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>
Source§type Error = SerializedBytesError
type Error = SerializedBytesError
Source§fn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>
fn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>
impl<T: Eq + HashType> Eq for HoloHash<T>
impl<T: HashType> StructuralPartialEq for HoloHash<T>
Auto Trait Implementations§
impl<T> Freeze for HoloHash<T>where
T: Freeze,
impl<T> RefUnwindSafe for HoloHash<T>where
T: RefUnwindSafe,
impl<T> Send for HoloHash<T>where
T: Send,
impl<T> Sync for HoloHash<T>where
T: Sync,
impl<T> Unpin for HoloHash<T>where
T: Unpin,
impl<T> UnwindSafe for HoloHash<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.