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
sourceimpl 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_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_action_hash(self) -> Option<ActionHash>
pub fn into_action_hash(self) -> Option<ActionHash>
If this hash represents a ActionHash, 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
sourceimpl 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_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_action_hash(self) -> Option<ActionHash>
pub fn into_action_hash(self) -> Option<ActionHash>
If this hash represents a ActionHash, return it, else None
sourceimpl<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 retype<TT: HashType>(self, hash_type: TT) -> HoloHash<TT>
pub fn retype<TT: HashType>(self, hash_type: TT) -> HoloHash<TT>
Change the type of this HoloHash, keeping the same bytes
sourcepub fn get_raw_39(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn get_raw_39(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [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]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn get_raw_36(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
Get 36-byte Vec which excludes the 3 byte prefix
sourcepub fn get_raw_32(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [u8]
pub fn get_raw_32(&self) -> &[u8]ⓘNotable traits for &[u8]impl<'_> Read for &[u8]impl<'_> Write for &mut [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
sourceimpl<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
sourceimpl<'de, T: HashType> Deserialize<'de> for HoloHash<T>
impl<'de, T: HashType> Deserialize<'de> for HoloHash<T>
sourcefn 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>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl From<HoloHash<Action>> for AnyDhtHash
impl From<HoloHash<Action>> for AnyDhtHash
sourcefn from(hash: ActionHash) -> Self
fn from(hash: ActionHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<Action>> for AnyLinkableHash
impl From<HoloHash<Action>> for AnyLinkableHash
sourcefn from(hash: ActionHash) -> Self
fn from(hash: ActionHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<Agent>> for AnyDhtHash
impl From<HoloHash<Agent>> for AnyDhtHash
sourcefn from(hash: AgentPubKey) -> Self
fn from(hash: AgentPubKey) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<Agent>> for AnyLinkableHash
impl From<HoloHash<Agent>> for AnyLinkableHash
sourcefn from(hash: AgentPubKey) -> Self
fn from(hash: AgentPubKey) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<Agent>> for EntryHash
impl From<HoloHash<Agent>> for EntryHash
sourcefn from(hash: AgentPubKey) -> EntryHash
fn from(hash: AgentPubKey) -> EntryHash
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyDht>> for ActionHash
impl From<HoloHash<AnyDht>> for ActionHash
sourcefn from(hash: AnyDhtHash) -> Self
fn from(hash: AnyDhtHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyDht>> for EntryHash
impl From<HoloHash<AnyDht>> for EntryHash
sourcefn from(hash: AnyDhtHash) -> Self
fn from(hash: AnyDhtHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyLinkable>> for AnyDhtHash
impl From<HoloHash<AnyLinkable>> for AnyDhtHash
sourcefn from(hash: AnyLinkableHash) -> Self
fn from(hash: AnyLinkableHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyLinkable>> for ActionHash
impl From<HoloHash<AnyLinkable>> for ActionHash
sourcefn from(hash: AnyLinkableHash) -> Self
fn from(hash: AnyLinkableHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyLinkable>> for EntryHash
impl From<HoloHash<AnyLinkable>> for EntryHash
sourcefn from(hash: AnyLinkableHash) -> Self
fn from(hash: AnyLinkableHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<AnyLinkable>> for ExternalHash
impl From<HoloHash<AnyLinkable>> for ExternalHash
sourcefn from(hash: AnyLinkableHash) -> Self
fn from(hash: AnyLinkableHash) -> Self
Converts to this type from the input type.
sourceimpl From<HoloHash<Entry>> for AnyDhtHash
impl From<HoloHash<Entry>> for AnyDhtHash
sourceimpl From<HoloHash<Entry>> for AnyLinkableHash
impl From<HoloHash<Entry>> for AnyLinkableHash
sourceimpl From<HoloHash<Entry>> for AgentPubKey
impl From<HoloHash<Entry>> for AgentPubKey
sourcefn from(hash: EntryHash) -> AgentPubKey
fn from(hash: EntryHash) -> AgentPubKey
Converts to this type from the input type.
sourceimpl From<HoloHash<External>> for AnyLinkableHash
impl From<HoloHash<External>> for AnyLinkableHash
sourcefn from(hash: ExternalHash) -> Self
fn from(hash: ExternalHash) -> Self
Converts to this type from the input type.
sourceimpl<T: HashType> IntoIterator for HoloHash<T>
impl<T: HashType> IntoIterator for HoloHash<T>
sourceimpl<T: Ord + HashType> Ord for HoloHash<T>
impl<T: Ord + HashType> Ord for HoloHash<T>
sourceimpl<T: PartialOrd + HashType> PartialOrd<HoloHash<T>> for HoloHash<T>
impl<T: PartialOrd + HashType> PartialOrd<HoloHash<T>> for HoloHash<T>
sourcefn partial_cmp(&self, other: &HoloHash<T>) -> Option<Ordering>
fn partial_cmp(&self, other: &HoloHash<T>) -> Option<Ordering>
This method returns an ordering between self
and other
values if one exists. Read more
1.0.0 · sourcefn lt(&self, other: &Rhs) -> bool
fn lt(&self, other: &Rhs) -> bool
This method tests less than (for self
and other
) and is used by the <
operator. Read more
1.0.0 · sourcefn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
sourceimpl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
impl<T: HashType> TryFrom<&HoloHash<T>> for SerializedBytes
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(t: &HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: &HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
Performs the conversion.
sourceimpl<T: HashType> TryFrom<HoloHash<T>> for SerializedBytes
impl<T: HashType> TryFrom<HoloHash<T>> for SerializedBytes
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(t: HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
fn try_from(t: HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>
Performs the conversion.
sourceimpl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>
impl<T: HashType> TryFrom<SerializedBytes> for HoloHash<T>
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
sourcefn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>
fn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>
Performs the conversion.
impl<T: Eq + HashType> Eq for HoloHash<T>
impl<T: HashType> StructuralEq for HoloHash<T>
impl<T: HashType> StructuralPartialEq for HoloHash<T>
Auto Trait Implementations
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.