Struct diem_crypto::hash::HashValue [−][src]
pub struct HashValue { /* fields omitted */ }Expand description
Output value of our hash function. Intentionally opaque for safety and modularity.
Implementations
The length of the hash in bits.
Create from a slice (e.g. retrieved from storage).
Creates a random instance with given rng. Useful in unit tests.
Convenience function that computes a HashValue internally equal to
the sha3_256 of a byte buffer. It will handle hasher creation, data
feeding and finalization.
Note this will not result in the <T as CryptoHash>::hash() for any
reasonable struct T, as this computes a sha3 without any ornaments.
pub fn iter_bits(&self) -> HashValueBitIterator<'_>ⓘNotable traits for HashValueBitIterator<'a>impl<'a> Iterator for HashValueBitIterator<'a> type Item = bool;
pub fn iter_bits(&self) -> HashValueBitIterator<'_>ⓘNotable traits for HashValueBitIterator<'a>impl<'a> Iterator for HashValueBitIterator<'a> type Item = bool;
impl<'a> Iterator for HashValueBitIterator<'a> type Item = bool;Returns a HashValueBitIterator over all the bits that represent this HashValue.
pub fn from_bit_iter(
iter: impl ExactSizeIterator<Item = bool>
) -> Result<Self, HashValueParseError>
pub fn from_bit_iter(
iter: impl ExactSizeIterator<Item = bool>
) -> Result<Self, HashValueParseError>
Constructs a HashValue from an iterator of bits.
Returns the length of common prefix of self and other in bits.
Full hex representation of a given hash value with 0x prefix.
Parse a given hex string to a hash value.
Trait Implementations
type Parameters = <[u8; 32] as Arbitrary>::Parameters
type Parameters = <[u8; 32] as Arbitrary>::Parameters
The type of parameters that arbitrary_with accepts for configuration
of the generated Strategy. Parameters must implement Default. Read more
Deserialize this value from the given Serde deserializer. Read more
Will print shortened (4 bytes) hash
type Err = HashValueParseError
type Err = HashValueParseError
The associated error which can be returned from parsing.
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
Auto Trait Implementations
impl RefUnwindSafe for HashValue
impl UnwindSafe for HashValue
Blanket Implementations
Mutably borrows from an owned value. Read more
type Output = T
type Output = T
Should always be Self
Generates a hash used only for tests.