Struct diem_sdk::crypto::HashValue [−][src]
pub struct HashValue { /* fields omitted */ }
Expand description
Output value of our hash function. Intentionally opaque for safety and modularity.
Implementations
impl HashValue
[src]
impl HashValue
[src]pub const LENGTH_IN_BITS: usize
[src]
pub const LENGTH_IN_BITS: usize
[src]The length of the hash in bits.
pub fn from_slice<T>(bytes: T) -> Result<HashValue, HashValueParseError> where
T: AsRef<[u8]>,
[src]
pub fn from_slice<T>(bytes: T) -> Result<HashValue, HashValueParseError> where
T: AsRef<[u8]>,
[src]Create from a slice (e.g. retrieved from storage).
pub fn random_with_rng<R>(rng: &mut R) -> HashValue where
R: Rng,
[src]
pub fn random_with_rng<R>(rng: &mut R) -> HashValue where
R: Rng,
[src]Creates a random instance with given rng. Useful in unit tests.
pub fn sha3_256_of(buffer: &[u8]) -> HashValue
[src]
pub fn sha3_256_of(buffer: &[u8]) -> HashValue
[src]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;
[src]
pub fn iter_bits(&self) -> HashValueBitIterator<'_>ⓘNotable traits for HashValueBitIterator<'a>
impl<'a> Iterator for HashValueBitIterator<'a> type Item = bool;
[src]Returns a HashValueBitIterator
over all the bits that represent this HashValue
.
pub fn from_bit_iter(
iter: impl ExactSizeIterator<Item = bool>
) -> Result<HashValue, HashValueParseError>
[src]
pub fn from_bit_iter(
iter: impl ExactSizeIterator<Item = bool>
) -> Result<HashValue, HashValueParseError>
[src]Constructs a HashValue
from an iterator of bits.
pub fn common_prefix_bits_len(&self, other: HashValue) -> usize
[src]
pub fn common_prefix_bits_len(&self, other: HashValue) -> usize
[src]Returns the length of common prefix of self
and other
in bits.
Methods from Deref<Target = [u8; 32]>
pub fn as_slice(&self) -> &[T]ⓘ
[src]
🔬 This is a nightly-only experimental API. (array_methods
)
pub fn as_slice(&self) -> &[T]ⓘ
[src]array_methods
)Returns a slice containing the entire array. Equivalent to &s[..]
.
pub fn each_ref(&self) -> [&T; N]
[src]
🔬 This is a nightly-only experimental API. (array_methods
)
pub fn each_ref(&self) -> [&T; N]
[src]array_methods
)Borrows each element and returns an array of references with the same
size as self
.
Example
#![feature(array_methods)] let floats = [3.1, 2.7, -1.0]; let float_refs: [&f64; 3] = floats.each_ref(); assert_eq!(float_refs, [&3.1, &2.7, &-1.0]);
This method is particularly useful if combined with other methods, like
map
. This way, you can avoid moving the original
array if its elements are not Copy
.
#![feature(array_methods, array_map)] let strings = ["Ferris".to_string(), "♥".to_string(), "Rust".to_string()]; let is_ascii = strings.each_ref().map(|s| s.is_ascii()); assert_eq!(is_ascii, [true, false, true]); // We can still access the original array: it has not been moved. assert_eq!(strings.len(), 3);
Trait Implementations
impl<'de> Deserialize<'de> for HashValue
[src]
impl<'de> Deserialize<'de> for HashValue
[src]pub fn deserialize<D>(
deserializer: D
) -> Result<HashValue, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]
pub fn deserialize<D>(
deserializer: D
) -> Result<HashValue, <D as Deserializer<'de>>::Error> where
D: Deserializer<'de>,
[src]Deserialize this value from the given Serde deserializer. Read more
impl FromStr for HashValue
[src]
impl FromStr for HashValue
[src]type Err = HashValueParseError
type Err = HashValueParseError
The associated error which can be returned from parsing.
impl Ord for HashValue
[src]
impl Ord for HashValue
[src]impl PartialOrd<HashValue> for HashValue
[src]
impl PartialOrd<HashValue> for HashValue
[src]pub fn partial_cmp(&self, other: &HashValue) -> Option<Ordering>
[src]
pub fn partial_cmp(&self, other: &HashValue) -> Option<Ordering>
[src]This method returns an ordering between self
and other
values if one exists. Read more
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn lt(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than (for self
and other
) and is used by the <
operator. Read more
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]
#[must_use]fn le(&self, other: &Rhs) -> bool
1.0.0[src]This method tests less than or equal to (for self
and other
) and is used by the <=
operator. Read more
impl Serialize for HashValue
[src]
impl Serialize for HashValue
[src]pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]
pub fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error> where
S: Serializer,
[src]Serialize this value into the given Serde serializer. Read more
impl Copy for HashValue
[src]
impl Eq for HashValue
[src]
impl StructuralEq for HashValue
[src]
impl StructuralPartialEq for HashValue
[src]
Auto Trait Implementations
impl RefUnwindSafe for HashValue
impl Send for HashValue
impl Sync for HashValue
impl Unpin for HashValue
impl UnwindSafe for HashValue
Blanket Implementations
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]pub fn borrow_mut(&mut self) -> &mut T
[src]
pub fn borrow_mut(&mut self) -> &mut T
[src]Mutably borrows from an owned value. Read more
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]
impl<Q, K> Equivalent<K> for Q where
K: Borrow<Q> + ?Sized,
Q: Eq + ?Sized,
[src]pub fn equivalent(&self, key: &K) -> bool
[src]
pub fn equivalent(&self, key: &K) -> bool
[src]Compare self to key
and return true
if they are equal.
impl<T> Instrument for T
[src]
impl<T> Instrument for T
[src]fn instrument(self, span: Span) -> Instrumented<Self>
[src]
fn instrument(self, span: Span) -> Instrumented<Self>
[src]Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more
fn in_current_span(self) -> Instrumented<Self>
[src]
fn in_current_span(self) -> Instrumented<Self>
[src]impl<T> Same<T> for T
impl<T> Same<T> for T
type Output = T
type Output = T
Should always be Self
impl<T> TestOnlyHash for T where
T: Serialize + ?Sized,
[src]
impl<T> TestOnlyHash for T where
T: Serialize + ?Sized,
[src]pub fn test_only_hash(&self) -> HashValue
[src]
pub fn test_only_hash(&self) -> HashValue
[src]Generates a hash used only for tests.
impl<T> ToOwned for T where
T: Clone,
[src]
impl<T> ToOwned for T where
T: Clone,
[src]type Owned = T
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn to_owned(&self) -> T
[src]Creates owned data from borrowed data, usually by cloning. Read more
pub fn clone_into(&self, target: &mut T)
[src]
pub fn clone_into(&self, target: &mut T)
[src]🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
pub fn vzip(self) -> V
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,