pub struct HoloHash<T>where
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<HoloHash<AnyDht>>
pub fn into_any_dht_hash(self) -> Option<HoloHash<AnyDht>>
Downcast to AnyDhtHash if this is not an external hash
Sourcepub fn into_action_hash(self) -> Option<HoloHash<Action>>
pub fn into_action_hash(self) -> Option<HoloHash<Action>>
If this hash represents an ActionHash, return it, else None
Sourcepub fn into_entry_hash(self) -> Option<HoloHash<Entry>>
pub fn into_entry_hash(self) -> Option<HoloHash<Entry>>
If this hash represents an EntryHash, return it, else None
Sourcepub fn into_agent_pub_key(self) -> Option<HoloHash<Agent>>
pub fn into_agent_pub_key(self) -> Option<HoloHash<Agent>>
If this hash represents an EntryHash which is actually an AgentPubKey, return it, else None.
Sourcepub fn into_external_hash(self) -> Option<HoloHash<External>>
pub fn into_external_hash(self) -> Option<HoloHash<External>>
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<HoloHash<Action>>
pub fn into_action_hash(self) -> Option<HoloHash<Action>>
If this hash represents an ActionHash, return it, else None
Sourcepub fn into_entry_hash(self) -> Option<HoloHash<Entry>>
pub fn into_entry_hash(self) -> Option<HoloHash<Entry>>
If this hash represents an EntryHash, return it, else None
Sourcepub fn into_agent_pub_key(self) -> Option<HoloHash<Agent>>
pub fn into_agent_pub_key(self) -> Option<HoloHash<Agent>>
If this hash represents an EntryHash which is actually an AgentPubKey, return it, else None.
Source§impl<T> HoloHash<T>where
T: HashType,
impl<T> HoloHash<T>where
T: HashType,
Sourcepub fn from_raw_39(hash: Vec<u8>) -> Result<HoloHash<T>, HoloHashError>
pub fn from_raw_39(hash: Vec<u8>) -> Result<HoloHash<T>, HoloHashError>
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>) -> HoloHash<T>
pub fn from_raw_39_panicky(hash: Vec<u8>) -> HoloHash<T>
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) -> HoloHash<T>
pub fn from_raw_36_and_type(bytes: Vec<u8>, hash_type: T) -> HoloHash<T>
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<T> HoloHash<T>where
T: HashType,
impl<T> HoloHash<T>where
T: HashType,
Sourcepub fn from_raw_32_and_type(hash: Vec<u8>, hash_type: T) -> HoloHash<T>
pub fn from_raw_32_and_type(hash: Vec<u8>, hash_type: T) -> HoloHash<T>
Construct a HoloHash from a 32-byte hash. The 3 prefix bytes will be added based on the provided HashType, and the 4 location bytes will be computed.
Source§impl<P> HoloHash<P>where
P: PrimitiveHashType,
impl<P> HoloHash<P>where
P: PrimitiveHashType,
Sourcepub fn from_raw_36(hash: Vec<u8>) -> HoloHash<P>
pub fn from_raw_36(hash: Vec<u8>) -> HoloHash<P>
Construct from 36 raw bytes, using the known PrimitiveHashType
Sourcepub fn from_raw_32(hash: Vec<u8>) -> HoloHash<P>
pub fn from_raw_32(hash: Vec<u8>) -> HoloHash<P>
Construct a HoloHash from a prehashed raw 32-byte slice. The location bytes will be calculated.
Source§impl<T> HoloHash<T>where
T: HashTypeSync,
impl<T> HoloHash<T>where
T: HashTypeSync,
Sourcepub fn with_data_sync<C>(content: &C) -> HoloHash<T>where
C: HashableContent<HashType = T>,
pub fn with_data_sync<C>(content: &C) -> HoloHash<T>where
C: HashableContent<HashType = T>,
Synchronously hash a reference to the given content to produce a HoloHash If the content is larger than MAX_HASHABLE_CONTENT_LEN, this will panic!
Source§impl<T> HoloHash<T>where
T: HashTypeAsync,
impl<T> HoloHash<T>where
T: HashTypeAsync,
Sourcepub async fn with_data<C>(content: &C) -> HoloHash<T>where
C: HashableContent<HashType = T>,
pub async fn with_data<C>(content: &C) -> HoloHash<T>where
C: HashableContent<HashType = T>,
Asynchronously hash a reference to the given content to produce a HoloHash
Trait Implementations§
Source§impl AnyDhtHashTransformer for HoloHash<AnyDht>
impl AnyDhtHashTransformer for HoloHash<AnyDht>
Source§impl AnyLinkableHashTransformer for HoloHash<AnyLinkable>
impl AnyLinkableHashTransformer for HoloHash<AnyLinkable>
Source§fn try_from_string(input: &str) -> Result<HoloHash<AnyLinkable>, WasmError>
fn try_from_string(input: &str) -> Result<HoloHash<AnyLinkable>, WasmError>
Source§fn must_be_action_hash(&self) -> Result<HoloHash<Action>, WasmError>
fn must_be_action_hash(&self) -> Result<HoloHash<Action>, WasmError>
ActionHash
or errorSource§impl<'a> Arbitrary<'a> for HoloHash<AnyLinkable>
impl<'a> Arbitrary<'a> for HoloHash<AnyLinkable>
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<HoloHash<AnyLinkable>, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<HoloHash<AnyLinkable>, Error>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl<'a, P> Arbitrary<'a> for HoloHash<P>where
P: PrimitiveHashType,
impl<'a, P> Arbitrary<'a> for HoloHash<P>where
P: PrimitiveHashType,
Source§fn arbitrary(u: &mut Unstructured<'a>) -> Result<HoloHash<P>, Error>
fn arbitrary(u: &mut Unstructured<'a>) -> Result<HoloHash<P>, Error>
Self
from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
fn arbitrary_take_rest(u: Unstructured<'a>) -> Result<Self, Error>
Self
from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Unstructured
this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Unstructured
this type
needs to construct itself. Read moreSource§impl<'de, T> Deserialize<'de> for HoloHash<T>where
T: HashType,
impl<'de, T> Deserialize<'de> for HoloHash<T>where
T: HashType,
Source§fn deserialize<D>(
deserializer: D,
) -> Result<HoloHash<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<HoloHash<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Source§impl From<HoloHash<Action>> for DeleteInput
impl From<HoloHash<Action>> for DeleteInput
Source§fn from(deletes_action_hash: HoloHash<Action>) -> DeleteInput
fn from(deletes_action_hash: HoloHash<Action>) -> DeleteInput
Sets ChainTopOrdering
to default
= Strict
when created from a hash.
Source§impl<T> From<HoloHash<T>> for HoloHashB64<T>where
T: HashType,
impl<T> From<HoloHash<T>> for HoloHashB64<T>where
T: HashType,
Source§fn from(original: HoloHash<T>) -> HoloHashB64<T>
fn from(original: HoloHash<T>) -> HoloHashB64<T>
Source§impl From<HoloHashB64<Action>> for HoloHash<AnyLinkable>
impl From<HoloHashB64<Action>> for HoloHash<AnyLinkable>
Source§fn from(h: HoloHashB64<Action>) -> HoloHash<AnyLinkable>
fn from(h: HoloHashB64<Action>) -> HoloHash<AnyLinkable>
Source§impl From<HoloHashB64<Entry>> for HoloHash<AnyLinkable>
impl From<HoloHashB64<Entry>> for HoloHash<AnyLinkable>
Source§fn from(h: HoloHashB64<Entry>) -> HoloHash<AnyLinkable>
fn from(h: HoloHashB64<Entry>) -> HoloHash<AnyLinkable>
Source§impl<T> From<HoloHashB64<T>> for HoloHash<T>where
T: HashType,
impl<T> From<HoloHashB64<T>> for HoloHash<T>where
T: HashType,
Source§fn from(original: HoloHashB64<T>) -> HoloHash<T>
fn from(original: HoloHashB64<T>) -> HoloHash<T>
Source§impl Into<GetEntityInput> for HoloHash<Action>
impl Into<GetEntityInput> for HoloHash<Action>
Source§fn into(self) -> GetEntityInput
fn into(self) -> GetEntityInput
Source§impl<T> IntoIterator for HoloHash<T>where
T: HashType,
impl<T> IntoIterator for HoloHash<T>where
T: HashType,
Source§impl<T> Ord for HoloHash<T>
impl<T> 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 for HoloHash<T>where
T: PartialOrd + HashType,
impl<T> PartialOrd for HoloHash<T>where
T: PartialOrd + HashType,
Source§impl<T> Serialize for HoloHash<T>where
T: HashType,
impl<T> Serialize for HoloHash<T>where
T: HashType,
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Source§impl<T> TryFrom<&HoloHash<T>> for SerializedByteswhere
T: HashType,
impl<T> TryFrom<&HoloHash<T>> for SerializedByteswhere
T: HashType,
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 HoloHash<Action>
impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Action>
Source§type Error = HashConversionError<AnyLinkable, Action>
type Error = HashConversionError<AnyLinkable, Action>
Source§impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Agent>
impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Agent>
Source§type Error = HashConversionError<AnyLinkable, Agent>
type Error = HashConversionError<AnyLinkable, Agent>
Source§impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<AnyDht>
impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<AnyDht>
Source§type Error = CompositeHashConversionError<AnyLinkable>
type Error = CompositeHashConversionError<AnyLinkable>
Source§impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Entry>
impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Entry>
Source§type Error = HashConversionError<AnyLinkable, Entry>
type Error = HashConversionError<AnyLinkable, Entry>
Source§impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<External>
impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<External>
Source§type Error = HashConversionError<AnyLinkable, External>
type Error = HashConversionError<AnyLinkable, External>
Source§impl<T> TryFrom<HoloHash<T>> for SerializedByteswhere
T: HashType,
impl<T> TryFrom<HoloHash<T>> for SerializedByteswhere
T: HashType,
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> TryFrom<SerializedBytes> for HoloHash<T>where
T: HashType,
impl<T> TryFrom<SerializedBytes> for HoloHash<T>where
T: HashType,
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 for HoloHash<T>
impl<T> StructuralPartialEq for HoloHash<T>where
T: HashType,
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
Source§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<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<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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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 moreSource§impl<T> LayoutRaw for T
impl<T> LayoutRaw for T
Source§fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self
from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self
is actually part of its subset T
(and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset
but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self
to the equivalent element of its superset.