[−]Struct solana_libra_nextgen_crypto::HashValue
Output value of our hash function. Intentionally opaque for safety and modularity.
Methods
impl HashValue
pub const LENGTH: usize
The length of the hash in bytes.
pub const LENGTH_IN_BITS: usize
The length of the hash in bits.
pub fn new(hash: [u8; 32]) -> HashValue
Create a new HashValue
from a byte array.
pub fn from_slice(src: &[u8]) -> Result<HashValue, Error>
Create from a slice (e.g. retrieved from storage).
pub fn to_vec(&self) -> Vec<u8>
Dumps into a vector.
pub fn zero() -> HashValue
Creates a zero-initialized instance.
pub fn is_zero(&self) -> bool
Check if the hash value is zero.
pub fn random() -> HashValue
Create a cryptographically random instance.
pub fn random_with_rng<R>(rng: &mut R) -> HashValue where
R: Rng,
R: Rng,
Creates a random instance with given rng. Useful in unit tests.
pub fn len() -> usize
Get the size of the hash.
pub fn last_n_bytes(&self, bytes: usize) -> String
Get the last n bytes as a String.
pub fn iter_bits(&self) -> HashValueBitIterator
Returns a HashValueBitIterator
over all the bits that represent this HashValue
.
pub fn common_prefix_bits_len(&self, other: HashValue) -> usize
Returns the length of common prefix of self
and other
in bits.
Trait Implementations
impl AsRef<[u8; 32]> for HashValue
impl Copy for HashValue
impl Binary for HashValue
impl Default for HashValue
impl Serialize for HashValue
fn serialize<__S>(
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
&self,
__serializer: __S
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error> where
__S: Serializer,
impl Clone for HashValue
fn clone(&self) -> HashValue
fn clone_from(&mut self, source: &Self)
1.0.0[src]
Performs copy-assignment from source
. Read more
impl Arbitrary for HashValue
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],)) -> HashValue>
The type of [Strategy
] used to generate values of type Self
. Read more
fn arbitrary_with(
_top: <HashValue as Arbitrary>::Parameters
) -> <HashValue as Arbitrary>::Strategy
_top: <HashValue as Arbitrary>::Parameters
) -> <HashValue as Arbitrary>::Strategy
fn arbitrary() -> Self::Strategy
[src]
Generates a [Strategy
] for producing arbitrary values of type the implementing type (Self
). Read more
impl Eq for HashValue
impl PartialEq<HashValue> for HashValue
impl Display for HashValue
Will print shortened (4 bytes) hash
impl<'de> Deserialize<'de> for HashValue
fn deserialize<__D>(
__deserializer: __D
) -> Result<HashValue, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
__deserializer: __D
) -> Result<HashValue, <__D as Deserializer<'de>>::Error> where
__D: Deserializer<'de>,
impl Hash for HashValue
fn hash<__H>(&self, state: &mut __H) where
__H: Hasher,
__H: Hasher,
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
Feeds a slice of this type into the given [Hasher
]. Read more
impl PartialOrd<HashValue> for HashValue
fn partial_cmp(&self, other: &HashValue) -> Option<Ordering>
fn lt(&self, other: &HashValue) -> bool
fn le(&self, other: &HashValue) -> bool
fn gt(&self, other: &HashValue) -> bool
fn ge(&self, other: &HashValue) -> bool
impl Debug for HashValue
impl Index<usize> for HashValue
impl Ord for HashValue
fn cmp(&self, other: &HashValue) -> Ordering
fn max(self, other: Self) -> Self
1.21.0[src]
Compares and returns the maximum of two values. Read more
fn min(self, other: Self) -> Self
1.21.0[src]
Compares and returns the minimum of two values. Read more
fn clamp(self, min: Self, max: Self) -> Self
[src]
clamp
)Restrict a value to a certain interval. Read more
impl LowerHex for HashValue
impl IntoProto for HashValue
type ProtoType = Vec<u8>
The corresponding Protobuf type.
fn into_proto(self) -> <HashValue as IntoProto>::ProtoType
impl FromProto for HashValue
Auto Trait Implementations
impl Sync for HashValue
impl Send for HashValue
impl Unpin for HashValue
impl RefUnwindSafe for HashValue
impl UnwindSafe for HashValue
Blanket Implementations
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,
impl<T> TestOnlyHash for T where
T: Serialize + ?Sized,
T: Serialize + ?Sized,
fn test_only_hash(&self) -> HashValue
impl<T> Same<T> for T
type Output = T
Should always be Self
impl<T> Clear for T where
T: InitializableFromZeroed + ?Sized,
T: InitializableFromZeroed + ?Sized,
fn clear(&mut self)
impl<T> InitializableFromZeroed for T where
T: Default,
T: Default,
unsafe fn initialize(place: *mut T)
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,