[][src]Struct solana_libra_crypto::hash::HashValue

pub struct HashValue { /* fields omitted */ }

Output value of our hash function. Intentionally opaque for safety and modularity.

Methods

impl HashValue[src]

pub const LENGTH: usize[src]

The length of the hash in bytes.

pub const LENGTH_IN_BITS: usize[src]

The length of the hash in bits.

pub fn new(hash: [u8; 32]) -> Self[src]

Create a new HashValue from a byte array.

pub fn from_slice(src: &[u8]) -> Result<Self>[src]

Create from a slice (e.g. retrieved from storage).

pub fn to_vec(&self) -> Vec<u8>[src]

Dumps into a vector.

pub fn zero() -> Self[src]

Creates a zero-initialized instance.

pub fn is_zero(&self) -> bool[src]

Check if the hash value is zero.

pub fn random() -> Self[src]

Create a cryptographically random instance.

pub fn random_with_rng<R: Rng>(rng: &mut R) -> Self[src]

Creates a random instance with given rng. Useful in unit tests.

pub fn len() -> usize[src]

Get the size of the hash.

pub fn last_n_bytes(&self, bytes: usize) -> String[src]

Get the last n bytes as a String.

Important traits for HashValueBitIterator<'a>
pub fn iter_bits(&self) -> HashValueBitIterator[src]

Returns a HashValueBitIterator over all the bits that represent this HashValue.

pub fn common_prefix_bits_len(&self, other: HashValue) -> usize[src]

Returns the length of common prefix of self and other in bits.

Trait Implementations

impl Clone for HashValue[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Ord for HashValue[src]

fn max(self, other: Self) -> Self1.21.0[src]

Compares and returns the maximum of two values. Read more

fn min(self, other: Self) -> Self1.21.0[src]

Compares and returns the minimum of two values. Read more

fn clamp(self, min: Self, max: Self) -> Self[src]

🔬 This is a nightly-only experimental API. (clamp)

Restrict a value to a certain interval. Read more

impl AsRef<[u8; 32]> for HashValue[src]

impl Default for HashValue[src]

impl From<HashValue> for Bytes[src]

impl PartialOrd<HashValue> for HashValue[src]

impl PartialEq<HashValue> for HashValue[src]

impl Copy for HashValue[src]

impl Eq for HashValue[src]

impl Display for HashValue[src]

Will print shortened (4 bytes) hash

impl Debug for HashValue[src]

impl Index<usize> for HashValue[src]

type Output = u8

The returned type after indexing.

impl Hash for HashValue[src]

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

Feeds a slice of this type into the given [Hasher]. Read more

impl Binary for HashValue[src]

impl LowerHex for HashValue[src]

impl IntoProto for HashValue[src]

type ProtoType = Vec<u8>

The corresponding Protobuf type.

impl FromProto for HashValue[src]

type ProtoType = Vec<u8>

The corresponding Protobuf type.

impl Serialize for HashValue[src]

impl<'de> Deserialize<'de> for HashValue[src]

impl Arbitrary for HashValue[src]

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

type Strategy = Map<(<[u8; 32] as Arbitrary>::Strategy,), fn(_: ([u8; 32],)) -> Self>

The type of [Strategy] used to generate values of type Self. Read more

fn arbitrary() -> Self::Strategy[src]

Generates a [Strategy] for producing arbitrary values of type the implementing type (Self). Read more

Auto Trait Implementations

Blanket Implementations

impl<T> TestOnlyHash for T where
    T: Serialize + ?Sized
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

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

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> Clear for T where
    T: InitializableFromZeroed + ?Sized

impl<T> InitializableFromZeroed for T where
    T: Default

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