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 from_raw_39(hash: Vec<u8>) -> HoloHashResult<Self>
pub fn 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_panicky(hash: Vec<u8>) -> Self
pub fn from_raw_39_panicky(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.
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. Used in this crate only, for testing.
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 get_loc(&self) -> DhtLocation
pub fn get_loc(&self) -> DhtLocation
Fetch the holo dht location for this hash
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: PartialEq + HashType> PartialEq for HoloHash<T>
impl<T: PartialEq + HashType> PartialEq for HoloHash<T>
source§impl<T: PartialOrd + HashType> PartialOrd for HoloHash<T>
impl<T: PartialOrd + HashType> PartialOrd for HoloHash<T>
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
self
and other
) and is used by the <=
operator. Read moresource§impl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
impl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
§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
§type Error = HashConversionError<AnyLinkable, Action>
type Error = HashConversionError<AnyLinkable, Action>
source§impl TryFrom<HoloHash<AnyLinkable>> for AgentPubKey
impl TryFrom<HoloHash<AnyLinkable>> for AgentPubKey
§type Error = HashConversionError<AnyLinkable, Agent>
type Error = HashConversionError<AnyLinkable, Agent>
source§impl TryFrom<HoloHash<AnyLinkable>> for AnyDhtHash
impl TryFrom<HoloHash<AnyLinkable>> for AnyDhtHash
§type Error = CompositeHashConversionError<AnyLinkable>
type Error = CompositeHashConversionError<AnyLinkable>
source§impl TryFrom<HoloHash<AnyLinkable>> for EntryHash
impl TryFrom<HoloHash<AnyLinkable>> for EntryHash
§type Error = HashConversionError<AnyLinkable, Entry>
type Error = HashConversionError<AnyLinkable, Entry>
source§impl TryFrom<HoloHash<AnyLinkable>> for ExternalHash
impl TryFrom<HoloHash<AnyLinkable>> for ExternalHash
§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
§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>
§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> ArchivePointee for T
impl<T> ArchivePointee for T
§type ArchivedMetadata = ()
type ArchivedMetadata = ()
source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata
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> CallHasher for T
impl<T> CallHasher for T
source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
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.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.source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoEither for T
impl<T> IntoEither for T
source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moresource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more