Struct near_primitives_core::hash::CryptoHash
source · 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() -> Self
sourcepub fn hash_bytes(bytes: &[u8]) -> CryptoHash
pub fn hash_bytes(bytes: &[u8]) -> CryptoHash
Calculates hash of given bytes.
sourcepub fn hash_borsh<T: BorshSerialize>(value: T) -> CryptoHash
pub fn hash_borsh<T: BorshSerialize>(value: T) -> CryptoHash
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) -> CryptoHash
pub fn hash_borsh_iter<I>(values: I) -> CryptoHash
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<Self>
fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the given unstructured data. Read moresource§fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>
Generate an arbitrary value of
Self
from the entirety of the given
unstructured data. Read moresource§impl<__AsMutT: ?Sized> AsMut<__AsMutT> for CryptoHash
impl<__AsMutT: ?Sized> 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: ?Sized> AsRef<__AsRefT> for CryptoHash
impl<__AsRefT: ?Sized> AsRef<__AsRefT> for CryptoHash
source§impl BorshDeserialize for CryptoHash
impl BorshDeserialize for CryptoHash
fn deserialize_reader<__R: Read>(reader: &mut __R) -> Result<Self, Error>
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 copy 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§impl<'de> Deserialize<'de> for CryptoHash
impl<'de> Deserialize<'de> for CryptoHash
source§fn deserialize<D>(
deserializer: D,
) -> Result<Self, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Self, <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 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> 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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)