pub struct Hash(/* private fields */);
Expand description

A hash; the 32-byte output of a hashing algorithm.

This struct is used most often in solana-sdk and related crates to contain a SHA-256 hash, but may instead contain a blake3 hash, as created by the blake3 module (and used in Message::hash).

Implementations§

§

impl Hash

pub fn new(hash_slice: &[u8]) -> Hash

pub const fn new_from_array(hash_array: [u8; 32]) -> Hash

pub fn new_unique() -> Hash

unique Hash for tests and benchmarks.

pub fn to_bytes(self) -> [u8; 32]

Trait Implementations§

§

impl AsRef<[u8]> for Hash

§

fn as_ref(&self) -> &[u8]

Converts this type into a shared reference of the (usually inferred) input type.
§

impl BorshDeserialize for Hash

§

fn deserialize_reader<__R>(reader: &mut __R) -> Result<Hash, Error>
where __R: Read,

§

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.
§

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,

§

impl BorshSchema for Hash

§

fn declaration() -> String

Get the name of the type without brackets.
§

fn add_definitions_recursively(definitions: &mut BTreeMap<String, Definition>)

Recursively, using DFS, add type definitions required for this type. Type definition partially explains how to serialize/deserialize a type.
§

impl BorshSerialize for Hash

§

fn serialize<__W>(&self, writer: &mut __W) -> Result<(), Error>
where __W: Write,

§

impl Clone for Hash

§

fn clone(&self) -> Hash

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl Debug for Hash

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl Default for Hash

§

fn default() -> Hash

Returns the “default value” for a type. Read more
§

impl<'de> Deserialize<'de> for Hash

§

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
§

impl Display for Hash

§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
§

impl From<[u8; 32]> for Hash

§

fn from(from: [u8; 32]) -> Hash

Converts to this type from the input type.
§

impl FromStr for Hash

§

type Err = ParseHashError

The associated error which can be returned from parsing.
§

fn from_str(s: &str) -> Result<Hash, <Hash as FromStr>::Err>

Parses a string s to return a value of this type. Read more
§

impl FromWasmAbi for Hash

§

type Abi = u32

The wasm ABI type that this converts from when coming back out from the ABI boundary.
§

unsafe fn from_abi(js: u32) -> Hash

Recover a Self from Self::Abi. Read more
§

impl Hash for Hash

§

fn hash<__H>(&self, state: &mut __H)
where __H: Hasher,

Feeds this value into the given Hasher. Read more
1.3.0 · source§

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

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

impl IntoWasmAbi for Hash

§

type Abi = u32

The wasm ABI type that this converts into when crossing the ABI boundary.
§

fn into_abi(self) -> u32

Convert self into Self::Abi so that it can be sent across the wasm ABI boundary.
§

impl LongRefFromWasmAbi for Hash

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = Ref<'static, Hash>

Same as RefFromWasmAbi::Anchor
§

unsafe fn long_ref_from_abi( js: <Hash as LongRefFromWasmAbi>::Abi ) -> <Hash as LongRefFromWasmAbi>::Anchor

Same as RefFromWasmAbi::ref_from_abi
§

impl OptionFromWasmAbi for Hash

§

fn is_none(abi: &<Hash as FromWasmAbi>::Abi) -> bool

Tests whether the argument is a “none” instance. If so it will be deserialized as None, and otherwise it will be passed to FromWasmAbi.
§

impl OptionIntoWasmAbi for Hash

§

fn none() -> <Hash as IntoWasmAbi>::Abi

Returns an ABI instance indicating “none”, which JS will interpret as the None branch of this option. Read more
§

impl Ord for Hash

§

fn cmp(&self, other: &Hash) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
§

impl PartialEq for Hash

§

fn eq(&self, other: &Hash) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
§

impl PartialOrd for Hash

§

fn partial_cmp(&self, other: &Hash) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
§

impl RefFromWasmAbi for Hash

§

type Abi = u32

The wasm ABI type references to Self are recovered from.
§

type Anchor = Ref<'static, 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.
§

unsafe fn ref_from_abi( js: <Hash as RefFromWasmAbi>::Abi ) -> <Hash as RefFromWasmAbi>::Anchor

Recover a Self::Anchor from Self::Abi. Read more
§

impl RefMutFromWasmAbi for Hash

§

type Abi = u32

Same as RefFromWasmAbi::Abi
§

type Anchor = RefMut<'static, Hash>

Same as RefFromWasmAbi::Anchor
§

unsafe fn ref_mut_from_abi( js: <Hash as RefMutFromWasmAbi>::Abi ) -> <Hash as RefMutFromWasmAbi>::Anchor

Same as RefFromWasmAbi::ref_from_abi
§

impl Sanitize for Hash

§

impl Serialize for Hash

§

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
§

impl TryFromJsValue for Hash

§

type Error = JsValue

The type returned in the event of a conversion error.
§

fn try_from_js_value( value: JsValue ) -> Result<Hash, <Hash as TryFromJsValue>::Error>

Performs the conversion.
§

impl VectorFromWasmAbi for Hash

§

type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi

§

unsafe fn vector_from_abi(js: <Hash as VectorFromWasmAbi>::Abi) -> Box<[Hash]>

§

impl VectorIntoWasmAbi for Hash

§

impl Zeroable for Hash

§

fn zeroed() -> Self

§

impl Copy for Hash

§

impl Eq for Hash

§

impl Pod for Hash

§

impl StructuralPartialEq 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§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> CheckedBitPattern for T
where T: AnyBitPattern,

§

type Bits = T

Self must have the same layout as the specified Bits except for the possible invalid bit patterns being checked during is_valid_bit_pattern.
§

fn is_valid_bit_pattern(_bits: &T) -> bool

If this function returns true, then it must be valid to reinterpret bits as &Self.
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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 more
source§

impl<T> ReturnWasmAbi for T
where T: IntoWasmAbi,

§

type Abi = <T as IntoWasmAbi>::Abi

Same as IntoWasmAbi::Abi
source§

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> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> AnyBitPattern for T
where T: Pod,

source§

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

§

impl<T> NoUninit for T
where T: Pod,