pub struct CryptoHash(pub [u8; 32]);Tuple Fields§
§0: [u8; 32]Implementations§
Source§impl CryptoHash
impl CryptoHash
pub const LENGTH: usize = 32usize
pub const fn new() -> CryptoHash
Sourcepub fn hash_bytes(bytes: &[u8]) -> CryptoHash
pub fn hash_bytes(bytes: &[u8]) -> CryptoHash
Calculates hash of given bytes.
Sourcepub fn hash_borsh<T>(value: T) -> CryptoHashwhere
T: BorshSerialize,
pub fn hash_borsh<T>(value: T) -> CryptoHashwhere
T: BorshSerialize,
Calculates hash of borsh-serialised representation of an object.
Note that using this function with an array may lead to unexpected
results. For example, CryptoHash::hash_borsh(&[1u32, 2, 3]) hashes
a representation of a [u32; 3] array rather than a slice. It may be
cleaner to use Self::hash_borsh_iter instead.
Sourcepub fn hash_borsh_iter<I>(values: I) -> CryptoHashwhere
I: IntoIterator,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
<I as IntoIterator>::Item: BorshSerialize,
pub fn hash_borsh_iter<I>(values: I) -> CryptoHashwhere
I: IntoIterator,
<I as IntoIterator>::IntoIter: ExactSizeIterator,
<I as IntoIterator>::Item: BorshSerialize,
Calculates hash of a borsh-serialised representation of list of objects.
This behaves as if it first collected all the items in the iterator into a vector and then calculating hash of borsh-serialised representation of that vector.
Panics if the iterator lies about its length.
pub const fn as_bytes(&self) -> &[u8; 32]
Trait Implementations§
Source§impl<'arbitrary> Arbitrary<'arbitrary> for CryptoHash
impl<'arbitrary> Arbitrary<'arbitrary> for CryptoHash
Source§fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<CryptoHash, Error>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<CryptoHash, Error>
Generate an arbitrary value of
Self from the given unstructured data. Read moreSource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<CryptoHash, Error>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<CryptoHash, Error>
Generate an arbitrary value of
Self from the entirety of the given
unstructured data. Read moreSource§fn size_hint(depth: usize) -> (usize, Option<usize>)
fn size_hint(depth: usize) -> (usize, Option<usize>)
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§fn try_size_hint(
depth: usize,
) -> Result<(usize, Option<usize>), MaxRecursionReached>
fn try_size_hint( depth: usize, ) -> Result<(usize, Option<usize>), MaxRecursionReached>
Get a size hint for how many bytes out of an
Unstructured this type
needs to construct itself. Read moreSource§impl<__AsMutT> AsMut<__AsMutT> for CryptoHash
impl<__AsMutT> AsMut<__AsMutT> for CryptoHash
Source§fn as_mut(&mut self) -> &mut __AsMutT
fn as_mut(&mut self) -> &mut __AsMutT
Converts this type into a mutable reference of the (usually inferred) input type.
Source§impl<__AsRefT> AsRef<__AsRefT> for CryptoHash
impl<__AsRefT> AsRef<__AsRefT> for CryptoHash
Source§impl Borrow<CryptoHash> for Receipt
impl Borrow<CryptoHash> for Receipt
Source§fn borrow(&self) -> &CryptoHash
fn borrow(&self) -> &CryptoHash
Immutably borrows from an owned value. Read more
Source§impl Borrow<CryptoHash> for SignedTransaction
impl Borrow<CryptoHash> for SignedTransaction
Source§fn borrow(&self) -> &CryptoHash
fn borrow(&self) -> &CryptoHash
Immutably borrows from an owned value. Read more
Source§impl BorshDeserialize for CryptoHash
impl BorshDeserialize for CryptoHash
fn deserialize_reader<__R>(reader: &mut __R) -> Result<CryptoHash, Error>where
__R: Read,
Source§fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>
Deserializes this instance from a given slice of bytes.
Updates the buffer to point at the remaining bytes.
Source§fn try_from_slice(v: &[u8]) -> Result<Self, Error>
fn try_from_slice(v: &[u8]) -> Result<Self, Error>
Deserialize this instance from a slice of bytes.
fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>where
R: Read,
Source§impl BorshSerialize for CryptoHash
impl BorshSerialize for CryptoHash
Source§impl Clone for CryptoHash
impl Clone for CryptoHash
Source§fn clone(&self) -> CryptoHash
fn clone(&self) -> CryptoHash
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CryptoHash
impl Debug for CryptoHash
Source§impl Default for CryptoHash
impl Default for CryptoHash
Source§fn default() -> CryptoHash
fn default() -> CryptoHash
Returns the “default value” for a type. Read more
Source§impl<'de> Deserialize<'de> for CryptoHash
impl<'de> Deserialize<'de> for CryptoHash
Source§fn deserialize<D>(
deserializer: D,
) -> Result<CryptoHash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<CryptoHash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Display for CryptoHash
impl Display for CryptoHash
Source§impl From<CryptoHash> for ChunkHash
impl From<CryptoHash> for ChunkHash
Source§fn from(crypto_hash: CryptoHash) -> Self
fn from(crypto_hash: CryptoHash) -> Self
Converts to this type from the input type.
Source§impl FromStr for CryptoHash
impl FromStr for CryptoHash
Source§impl Hash for CryptoHash
impl Hash for CryptoHash
Source§impl Ord for CryptoHash
impl Ord for CryptoHash
Source§fn cmp(&self, other: &CryptoHash) -> Ordering
fn cmp(&self, other: &CryptoHash) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
Source§impl PartialEq for CryptoHash
impl PartialEq for CryptoHash
Source§impl PartialOrd for CryptoHash
impl PartialOrd for CryptoHash
Source§impl Serialize for CryptoHash
impl Serialize for CryptoHash
Source§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Source§impl TryFrom<&[u8]> for CryptoHash
impl TryFrom<&[u8]> for CryptoHash
impl Copy for CryptoHash
impl Eq for CryptoHash
impl StructuralPartialEq for CryptoHash
Auto Trait Implementations§
impl Freeze for CryptoHash
impl RefUnwindSafe for CryptoHash
impl Send for CryptoHash
impl Sync for CryptoHash
impl Unpin for CryptoHash
impl UnwindSafe for CryptoHash
Blanket Implementations§
Source§impl<T> ArchivePointee for T
impl<T> ArchivePointee for T
Source§type ArchivedMetadata = ()
type ArchivedMetadata = ()
The archived version of the pointer metadata for this type.
Source§fn pointer_metadata(
_: &<T as ArchivePointee>::ArchivedMetadata,
) -> <T as Pointee>::Metadata
fn pointer_metadata( _: &<T as ArchivePointee>::ArchivedMetadata, ) -> <T as Pointee>::Metadata
Converts some archived metadata to the pointer metadata for itself.
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CallHasher for T
impl<T> CallHasher for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<F, W, T, D> Deserialize<With<T, W>, D> for F
impl<F, W, T, D> Deserialize<With<T, W>, D> for F
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ToHex for T
impl<T> ToHex for T
Source§fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Lower case
letters are used (e.g. f9b4ca)Source§fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
fn encode_hex_upper<U>(&self) -> Uwhere
U: FromIterator<char>,
Encode the hex strict representing
self into the result. Upper case
letters are used (e.g. F9B4CA)