pub struct Hash(/* private fields */);Expand description
@category General
Implementations§
Source§impl Hash
impl Hash
pub const fn from_bytes(bytes: [u8; 32]) -> Hash
pub const fn as_bytes(self) -> [u8; 32]
Sourcepub fn from_slice(bytes: &[u8]) -> Hash
pub fn from_slice(bytes: &[u8]) -> Hash
§Panics
Panics if bytes length is not exactly HASH_SIZE.
pub fn try_from_slice(bytes: &[u8]) -> Result<Hash, TryFromSliceError>
pub fn to_le_u64(self) -> [u64; 4]
pub fn iter_le_u64(&self) -> impl ExactSizeIterator
pub fn from_le_u64(arr: [u64; 4]) -> Hash
pub fn from_u64_word(word: u64) -> Hash
Source§impl Hash
impl Hash
pub fn constructor(hex_str: &str) -> Hash
pub fn js_to_string(&self) -> String
Trait Implementations§
Source§impl BlockHashExtensions for Hash
impl BlockHashExtensions for Hash
Source§impl BorshDeserialize for Hash
impl BorshDeserialize for Hash
fn deserialize_reader<__R>(reader: &mut __R) -> Result<Hash, 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 Hash
impl BorshSerialize for Hash
Source§impl CastFromJs for Hash
impl CastFromJs for Hash
Source§fn try_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Hash as RefFromWasmAbi>::Anchor, Error>
fn try_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Hash as RefFromWasmAbi>::Anchor, Error>
Obtain safe reference from
JsValueSource§fn try_long_ref_from_js_value<'a, R>(
js: &'a R,
) -> Result<<Hash as RefFromWasmAbi>::Anchor, Error>
fn try_long_ref_from_js_value<'a, R>( js: &'a R, ) -> Result<<Hash as RefFromWasmAbi>::Anchor, Error>
Obtain safe long reference from
JsValuefn try_ref_from_js_value_as_cast<'a, R>( js_value: &'a R, ) -> Result<Cast<'a, Self>, Error>
fn try_long_ref_from_js_value_as_cast<'a, R>( js: &'a R, ) -> Result<Cast<'a, Self>, Error>
Source§impl<'de> Deserialize<'de> for Hash
impl<'de> Deserialize<'de> for Hash
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Hash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Hash, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl FromWasmAbi for Hash
impl FromWasmAbi for Hash
Source§impl IntoWasmAbi for Hash
impl IntoWasmAbi for Hash
Source§impl LongRefFromWasmAbi for Hash
impl LongRefFromWasmAbi for Hash
Source§impl MemSizeEstimator for Hash
impl MemSizeEstimator for Hash
Source§fn estimate_size(&self, mem_mode: MemMode) -> usize
fn estimate_size(&self, mem_mode: MemMode) -> usize
Estimates the size of this object depending on the passed mem mode
Source§fn estimate_mem_bytes(&self) -> usize
fn estimate_mem_bytes(&self) -> usize
Estimates the (deep) size of this object in bytes (including heap owned inner data)
Source§fn estimate_mem_units(&self) -> usize
fn estimate_mem_units(&self) -> usize
Estimates the number of units this object holds in memory where the unit byte size is usually
a constant known to the caller as well (and hence we avoid computing it over and over)
Source§impl OptionFromWasmAbi for Hash
impl OptionFromWasmAbi for Hash
Source§impl OptionIntoWasmAbi for Hash
impl OptionIntoWasmAbi for Hash
Source§impl Ord for Hash
impl Ord for Hash
Source§impl PartialEq for Hash
We only override PartialEq because clippy wants us to.
This should always hold: PartialEq(x,y) => Hash(x) == Hash(y)
impl PartialEq for Hash
We only override PartialEq because clippy wants us to. This should always hold: PartialEq(x,y) => Hash(x) == Hash(y)
Source§impl PartialOrd for Hash
impl PartialOrd for Hash
Source§impl RefFromWasmAbi for Hash
impl RefFromWasmAbi for Hash
Source§type Anchor = RcRef<Hash>
type Anchor = RcRef<Hash>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§unsafe fn ref_from_abi(
js: <Hash as RefFromWasmAbi>::Abi,
) -> <Hash as RefFromWasmAbi>::Anchor
unsafe fn ref_from_abi( js: <Hash as RefFromWasmAbi>::Abi, ) -> <Hash as RefFromWasmAbi>::Anchor
Source§impl RefMutFromWasmAbi for Hash
impl RefMutFromWasmAbi for Hash
Source§impl Serialize for Hash
impl Serialize for Hash
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 TryCastFromJs for Hash
impl TryCastFromJs for Hash
type Error = Error
Source§fn try_cast_from<'a, R>(
value: &'a R,
) -> Result<Cast<'a, Hash>, <Hash as TryCastFromJs>::Error>
fn try_cast_from<'a, R>( value: &'a R, ) -> Result<Cast<'a, Hash>, <Hash as TryCastFromJs>::Error>
Try to cast a JsValue into a Rust object.
This should be user-defined function that
attempts to cast a JsValue into a Rust object
or interpret a source data and create a
temporary struct owned by by the
Cast.Source§fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
fn try_owned_from(value: impl AsRef<JsValue>) -> Result<Self, Self::Error>
Perform a user cast and consume the
Cast container.
This function will return a temporary user-created
object created during [try_cast_from] or a clone of the casted reference.fn try_captured_cast_from( js_value: impl AsRef<JsValue>, ) -> Result<Cast<'static, Self>, Self::Error>
Source§fn resolve<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Self, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Self, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
Try to cast a JsValue into a Rust object, in cast of failure
invoke a user-supplied closure that can try to create an instance
of the object based on the supplied JsValue.
Source§fn resolve_cast<'a, R>(
js: &'a R,
create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>,
) -> Result<Cast<'a, Self>, Self::Error>
fn resolve_cast<'a, R>( js: &'a R, create: impl FnOnce() -> Result<Cast<'a, Self>, Self::Error>, ) -> Result<Cast<'a, Self>, Self::Error>
Try to cast a JsValue into a Rust object, in cast of failure
invoke a user-supplied closure that can try to create an instance
of the object based on the supplied JsValue. Unlike the [
resolve]
function, this function expects create closure to return a Cast.
This is useful when routing the creation of the object to another
function that is capable of creating a compatible Cast wrapper.Source§impl TryFromJsValue for Hash
impl TryFromJsValue for Hash
Source§impl VectorFromWasmAbi for Hash
impl VectorFromWasmAbi for Hash
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: <Hash as VectorFromWasmAbi>::Abi) -> Box<[Hash]>
Source§impl VectorIntoWasmAbi for Hash
impl VectorIntoWasmAbi for Hash
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[Hash]>) -> <Hash as VectorIntoWasmAbi>::Abi
impl Copy for Hash
impl Eq for Hash
Auto Trait Implementations§
impl Freeze for Hash
impl RefUnwindSafe for Hash
impl Send for Hash
impl Sync for Hash
impl Unpin for Hash
impl UnwindSafe for Hash
Blanket Implementations§
§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§unsafe fn clone_to_uninit(&self, dest: *mut u8)
unsafe fn clone_to_uninit(&self, dest: *mut u8)
🔬This is a nightly-only experimental API. (
clone_to_uninit)Source§impl<'de, T> Deserialize<'de, 32> for T
impl<'de, T> Deserialize<'de, 32> for T
Source§fn deserialize<D>(deserializer: D) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<T, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialization function for types T
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
impl<T, U> OverflowingInto<U> for Twhere
U: OverflowingFrom<T>,
fn overflowing_into(self) -> (U, bool)
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.Source§impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
impl<T, U> RoundingInto<U> for Twhere
U: RoundingFrom<T>,
fn rounding_into(self, rm: RoundingMode) -> (U, Ordering)
Source§impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
impl<T, U> SaturatingInto<U> for Twhere
U: SaturatingFrom<T>,
fn saturating_into(self) -> U
Source§impl<const N: usize, T> Serialize<N> for T
impl<const N: usize, T> Serialize<N> for T
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
self using the provided Serializer.