Struct hdk::prelude::HoloHash

source ·
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>

source

pub fn into_primitive(self) -> AnyLinkableHashPrimitive

Match on the primitive hash type represented by this composite hash type

source

pub fn into_any_dht_hash(self) -> Option<HoloHash<AnyDht>>

Downcast to AnyDhtHash if this is not an external hash

source

pub fn into_action_hash(self) -> Option<HoloHash<Action>>

If this hash represents an ActionHash, return it, else None

source

pub fn into_entry_hash(self) -> Option<HoloHash<Entry>>

If this hash represents an EntryHash, return it, else None

source

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

pub fn into_external_hash(self) -> Option<HoloHash<External>>

If this hash represents an ExternalHash, return it, else None

source§

impl HoloHash<AnyDht>

source

pub fn into_primitive(self) -> AnyDhtHashPrimitive

Match on the primitive hash type represented by this composite hash type

source

pub fn into_action_hash(self) -> Option<HoloHash<Action>>

If this hash represents an ActionHash, return it, else None

source

pub fn into_entry_hash(self) -> Option<HoloHash<Entry>>

If this hash represents an EntryHash, return it, else None

source

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,

source

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

source

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.

source

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.

source

pub fn hash_type(&self) -> &T

The HashType of this hash

source

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

source

pub fn get_raw_36(&self) -> &[u8]

Get 36-byte Vec which excludes the 3 byte prefix

source

pub fn get_raw_32(&self) -> &[u8]

Fetch just the core 32 bytes (without the 4 location bytes)

source

pub fn get_loc(&self) -> DhtLocation

Fetch the holo dht location for this hash

source

pub fn into_inner(self) -> Vec<u8>

consume into the inner byte vector

source

pub fn to_hex(&self) -> String

Get the hex representation of the hash bytes

source§

impl<P> HoloHash<P>

source

pub fn from_raw_36(hash: Vec<u8>) -> HoloHash<P>

Construct from 36 raw bytes, using the known PrimitiveHashType

Trait Implementations§

source§

impl<T> AsRef<[u8]> for HoloHash<T>
where T: HashType,

source§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl AsRef<HoloHash<Agent>> for VerifySignature

source§

fn as_ref(&self) -> &HoloHash<Agent>

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T> Clone for HoloHash<T>
where T: Clone + HashType,

source§

fn clone(&self) -> HoloHash<T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<T> Debug for HoloHash<T>
where T: HashType,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

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>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl<T> Display for HoloHash<T>
where T: HashType,

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
source§

impl From<HoloHash<Action>> for DeleteInput

source§

fn from(deletes_action_hash: HoloHash<Action>) -> DeleteInput

Sets ChainTopOrdering to default = Strict when created from a hash.

source§

impl From<HoloHash<Action>> for HoloHash<AnyDht>

source§

fn from(hash: HoloHash<Action>) -> HoloHash<AnyDht>

Converts to this type from the input type.
source§

impl From<HoloHash<Action>> for HoloHash<AnyLinkable>

source§

fn from(hash: HoloHash<Action>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl From<HoloHash<Agent>> for CapGrant

source§

fn from(agent_hash: HoloHash<Agent>) -> CapGrant

Converts to this type from the input type.
source§

impl From<HoloHash<Agent>> for HoloHash<AnyDht>

source§

fn from(hash: HoloHash<Agent>) -> HoloHash<AnyDht>

Converts to this type from the input type.
source§

impl From<HoloHash<Agent>> for HoloHash<AnyLinkable>

source§

fn from(hash: HoloHash<Agent>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl From<HoloHash<Agent>> for HoloHash<Entry>

source§

fn from(hash: HoloHash<Agent>) -> HoloHash<Entry>

Converts to this type from the input type.
source§

impl From<HoloHash<AnyDht>> for HoloHash<AnyLinkable>

source§

fn from(hash: HoloHash<AnyDht>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl From<HoloHash<Entry>> for HoloHash<Agent>

source§

fn from(hash: HoloHash<Entry>) -> HoloHash<Agent>

Converts to this type from the input type.
source§

impl From<HoloHash<Entry>> for HoloHash<AnyDht>

source§

fn from(hash: HoloHash<Entry>) -> HoloHash<AnyDht>

Converts to this type from the input type.
source§

impl From<HoloHash<Entry>> for HoloHash<AnyLinkable>

source§

fn from(hash: HoloHash<Entry>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl From<HoloHash<External>> for HoloHash<AnyLinkable>

source§

fn from(hash: HoloHash<External>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl<T> From<HoloHash<T>> for HoloHashB64<T>
where T: HashType,

source§

fn from(original: HoloHash<T>) -> HoloHashB64<T>

Converts to this type from the input type.
source§

impl From<HoloHashB64<Action>> for HoloHash<AnyDht>

source§

fn from(h: HoloHashB64<Action>) -> HoloHash<AnyDht>

Converts to this type from the input type.
source§

impl From<HoloHashB64<Action>> for HoloHash<AnyLinkable>

source§

fn from(h: HoloHashB64<Action>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl From<HoloHashB64<Entry>> for HoloHash<AnyDht>

source§

fn from(h: HoloHashB64<Entry>) -> HoloHash<AnyDht>

Converts to this type from the input type.
source§

impl From<HoloHashB64<Entry>> for HoloHash<AnyLinkable>

source§

fn from(h: HoloHashB64<Entry>) -> HoloHash<AnyLinkable>

Converts to this type from the input type.
source§

impl<T> From<HoloHashB64<T>> for HoloHash<T>
where T: HashType,

source§

fn from(original: HoloHashB64<T>) -> HoloHash<T>

Converts to this type from the input type.
source§

impl<T> HasHash<T> for HoloHash<T>
where T: HashType,

source§

fn as_hash(&self) -> &HoloHash<T>

Get the hash by reference
source§

fn into_hash(self) -> HoloHash<T>

Convert to the owned hash
source§

impl<T> Hash for HoloHash<T>
where T: Hash + HashType,

source§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<T> IntoIterator for HoloHash<T>
where T: HashType,

§

type Item = u8

The type of the elements being iterated over.
§

type IntoIter = IntoIter<<HoloHash<T> as IntoIterator>::Item>

Which kind of iterator are we turning this into?
source§

fn into_iter(self) -> <HoloHash<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
source§

impl<T> Ord for HoloHash<T>
where T: Ord + HashType,

source§

fn cmp(&self, other: &HoloHash<T>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<T> PartialEq for HoloHash<T>
where T: PartialEq + HashType,

source§

fn eq(&self, other: &HoloHash<T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<T> PartialOrd for HoloHash<T>
where T: PartialOrd + HashType,

source§

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 · source§

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 · source§

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
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

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,

Serialize this value into the given Serde serializer. Read more
source§

impl<T> TryFrom<&HoloHash<T>> for SerializedBytes
where T: HashType,

§

type Error = SerializedBytesError

The type returned in the event of a conversion error.
source§

fn try_from(t: &HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>

Performs the conversion.
source§

impl<P> TryFrom<&String> for HoloHash<P>

§

type Error = HoloHashError

The type returned in the event of a conversion error.
source§

fn try_from(s: &String) -> Result<HoloHash<P>, HoloHashError>

Performs the conversion.
source§

impl<P> TryFrom<&str> for HoloHash<P>

§

type Error = HoloHashError

The type returned in the event of a conversion error.
source§

fn try_from(s: &str) -> Result<HoloHash<P>, HoloHashError>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyDht>> for HoloHash<Action>

§

type Error = HashConversionError<AnyDht, Action>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyDht> ) -> Result<HoloHash<Action>, <HoloHash<Action> as TryFrom<HoloHash<AnyDht>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyDht>> for HoloHash<Agent>

§

type Error = HashConversionError<AnyDht, Agent>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyDht> ) -> Result<HoloHash<Agent>, <HoloHash<Agent> as TryFrom<HoloHash<AnyDht>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyDht>> for HoloHash<Entry>

§

type Error = HashConversionError<AnyDht, Entry>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyDht> ) -> Result<HoloHash<Entry>, <HoloHash<Entry> as TryFrom<HoloHash<AnyDht>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Action>

§

type Error = HashConversionError<AnyLinkable, Action>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyLinkable> ) -> Result<HoloHash<Action>, <HoloHash<Action> as TryFrom<HoloHash<AnyLinkable>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Agent>

§

type Error = HashConversionError<AnyLinkable, Agent>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyLinkable> ) -> Result<HoloHash<Agent>, <HoloHash<Agent> as TryFrom<HoloHash<AnyLinkable>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<AnyDht>

§

type Error = CompositeHashConversionError<AnyLinkable>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyLinkable> ) -> Result<HoloHash<AnyDht>, <HoloHash<AnyDht> as TryFrom<HoloHash<AnyLinkable>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<Entry>

§

type Error = HashConversionError<AnyLinkable, Entry>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyLinkable> ) -> Result<HoloHash<Entry>, <HoloHash<Entry> as TryFrom<HoloHash<AnyLinkable>>>::Error>

Performs the conversion.
source§

impl TryFrom<HoloHash<AnyLinkable>> for HoloHash<External>

§

type Error = HashConversionError<AnyLinkable, External>

The type returned in the event of a conversion error.
source§

fn try_from( hash: HoloHash<AnyLinkable> ) -> Result<HoloHash<External>, <HoloHash<External> as TryFrom<HoloHash<AnyLinkable>>>::Error>

Performs the conversion.
source§

impl<T> TryFrom<HoloHash<T>> for SerializedBytes
where T: HashType,

§

type Error = SerializedBytesError

The type returned in the event of a conversion error.
source§

fn try_from(t: HoloHash<T>) -> Result<SerializedBytes, SerializedBytesError>

Performs the conversion.
source§

impl<T> TryFrom<SerializedBytes> for HoloHash<T>
where T: HashType,

§

type Error = SerializedBytesError

The type returned in the event of a conversion error.
source§

fn try_from(sb: SerializedBytes) -> Result<HoloHash<T>, SerializedBytesError>

Performs the conversion.
source§

impl<P> TryFrom<String> for HoloHash<P>

§

type Error = HoloHashError

The type returned in the event of a conversion error.
source§

fn try_from(s: String) -> Result<HoloHash<P>, HoloHashError>

Performs the conversion.
source§

impl<T> Eq for HoloHash<T>
where T: Eq + HashType,

source§

impl<T> StructuralPartialEq for HoloHash<T>
where T: HashType,

Auto Trait Implementations§

§

impl<T> Freeze for HoloHash<T>
where T: Ord + PartialOrd + Eq + PartialEq + Hash + Debug + Clone + Copy + Freeze,

§

impl<T> RefUnwindSafe for HoloHash<T>

§

impl<T> Send for HoloHash<T>
where T: Ord + PartialOrd + Eq + PartialEq + Hash + Debug + Clone + Copy + Send,

§

impl<T> Sync for HoloHash<T>
where T: Ord + PartialOrd + Eq + PartialEq + Hash + Debug + Clone + Copy + Sync,

§

impl<T> Unpin for HoloHash<T>
where T: Ord + PartialOrd + Eq + PartialEq + Hash + Debug + Clone + Copy + Unpin,

§

impl<T> UnwindSafe for HoloHash<T>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> ArchivePointee for T

§

type ArchivedMetadata = ()

The archived version of the pointer metadata for this type.
source§

fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata ) -> <T as Pointee>::Metadata

Converts some archived metadata to the pointer metadata for itself.
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CallHasher for T
where T: Hash + ?Sized,

source§

default fn get_hash<H, B>(value: &H, build_hasher: &B) -> u64
where H: Hash + ?Sized, B: BuildHasher,

source§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<F, W, T, D> Deserialize<With<T, W>, D> for F
where W: DeserializeWith<F, T, D>, D: Fallible + ?Sized, F: ?Sized,

source§

fn deserialize( &self, deserializer: &mut D ) -> Result<With<T, W>, <D as Fallible>::Error>

Deserializes using the given deserializer
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> LayoutRaw for T

source§

fn layout_raw(_: <T as Pointee>::Metadata) -> Result<Layout, LayoutError>

Gets the layout of the type.
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Pointee for T

§

type Metadata = ()

The type for metadata in pointers and references to Self.
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> Upcastable for T
where T: Any + Send + Sync + 'static,

source§

fn upcast_any_ref(&self) -> &(dyn Any + 'static)

upcast ref
source§

fn upcast_any_mut(&mut self) -> &mut (dyn Any + 'static)

upcast mut ref
source§

fn upcast_any_box(self: Box<T>) -> Box<dyn Any>

upcast boxed dyn
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,