Struct holo_hash::HoloHash [−][src]
pub struct HoloHash<T: HashType> { /* fields omitted */ }
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
Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type
Raw constructor: Create a HoloHash from 39 bytes, using the prefix bytes to determine the hash_type. Panics if hash_type does not match.
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.
Change the type of this HoloHash, keeping the same bytes
Get the raw 39-byte Vec including the 3 byte prefix, base 32 bytes, and the 4 byte loc
Get 36-byte Vec which excludes the 3 byte prefix
Fetch just the core 32 bytes (without the 4 location bytes)
consume into the inner byte vector
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.
For convenience, 36 bytes can also be passed in, in which case the location bytes will used as provided, not computed.
Construct from 36 raw bytes, using the known PrimitiveHashType
Construct a HoloHash from a prehashed raw 32-byte slice. The location bytes will be calculated.
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!
Asynchronously hash a reference to the given content to produce a HoloHash
Trait Implementations
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>,
Deserialize this value from the given Serde deserializer. Read more
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
Performs the conversion.
This method returns an ordering between self
and other
values if one exists. Read more
This method tests less than (for self
and other
) and is used by the <
operator. Read more
This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
This method tests greater than (for self
and other
) and is used by the >
operator. Read more
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = HoloHashError
type Error = HoloHashError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = HoloHashError
type Error = HoloHashError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = SerializedBytesError
type Error = SerializedBytesError
The type returned in the event of a conversion error.
Performs the conversion.
type Error = HoloHashError
type Error = HoloHashError
The type returned in the event of a conversion error.
Performs the conversion.
Auto Trait Implementations
impl<T> RefUnwindSafe for HoloHash<T> where
T: RefUnwindSafe,
impl<T> UnwindSafe for HoloHash<T> where
T: UnwindSafe,
Blanket Implementations
Mutably borrows from an owned value. Read more
Compare self to key
and return true
if they are equal.