Struct sp_core::H256

source ·
pub struct H256(pub [u8; 32]);
Expand description

Fixed-size uninterpreted hash type with 32 bytes (256 bits) size.

Tuple Fields§

§0: [u8; 32]

Implementations§

Returns a new fixed hash where all bits are set to the given byte.

Returns a new zero-initialized fixed hash.

Returns the size of this hash in bytes.

Extracts a byte slice containing the entire fixed hash.

Extracts a mutable byte slice containing the entire fixed hash.

Extracts a reference to the byte array containing the entire fixed hash.

Extracts a reference to the byte array containing the entire fixed hash.

Returns the inner bytes array.

Returns a constant raw pointer to the value.

Returns a mutable raw pointer to the value.

Assign the bytes from the byte slice src to self.

Note

The given bytes are interpreted in big endian order.

Panics

If the length of src and the number of bytes in self do not match.

Create a new fixed-hash from the given slice src.

Note

The given bytes are interpreted in big endian order.

Panics

If the length of src and the number of bytes in Self do not match.

Returns true if all bits set in b are also set in self.

Returns true if no bits are set.

Utilities using the byteorder crate.

Returns the lowest 8 bytes interpreted as big-endian.

Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

Returns the lowest 8 bytes interpreted as little-endian.

Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

Returns the lowest 8 bytes interpreted as native-endian.

Note

For hash type with less than 8 bytes the missing bytes are interpreted as being zero.

Creates a new hash type from the given u64 value.

Note
  • The given u64 value is interpreted as big endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.

Creates a new hash type from the given u64 value.

Note
  • The given u64 value is interpreted as little endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.

Creates a new hash type from the given u64 value.

Note
  • The given u64 value is interpreted as native endian.
  • Ignores the most significant bits of the given value if the hash type has less than 8 bytes.

Utilities using the rand crate.

Assign self to a cryptographically random value using the given random number generator.

Assign self to a cryptographically random value.

Create a new hash with cryptographically random content using the given random number generator.

Create a new hash with cryptographically random content.

Trait Implementations§

Converts this type into a mutable reference of the (usually inferred) input type.
Converts this type into a shared reference of the (usually inferred) input type.
The resulting type after applying the & operator.
Performs the & operation. Read more
The resulting type after applying the & operator.
Performs the & operation. Read more
Performs the &= operation. Read more
Performs the &= operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
The resulting type after applying the | operator.
Performs the | operation. Read more
Performs the |= operation. Read more
Performs the |= operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
The resulting type after applying the ^ operator.
Performs the ^ operation. Read more
Performs the ^= operation. Read more
Performs the ^= operation. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Attempt to deserialise the value from input.
Attempt to skip the encoded value from input. Read more
Returns the fixed encoded size of the type. Read more
Returns the “default value” for a type. Read more
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Convert self to a slice and then invoke the given closure with it.
If possible give a hint of expected size of the encoding. Read more
Convert self to a slice and append it to the destination.
Convert self to an owned vector.
Calculates the encoded size. Read more

Constructs a hash type from the given reference to the bytes array of fixed length.

Note

The given bytes are interpreted in big endian order.

Constructs a hash type from the given reference to the mutable bytes array of fixed length.

Note

The given bytes are interpreted in big endian order.

Constructs a hash type from the given bytes array of fixed length.

Note

The given bytes are interpreted in big endian order.

Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.
Converts to this type from the input type.

Creates a hash type instance from the given string.

Note

The given input string is interpreted in big endian.

Errors
  • When encountering invalid non hex-digits
  • Upon empty string input or invalid input length in general
The associated error which can be returned from parsing.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
The returned type after indexing.
Performs the indexing (container[index]) operation. Read more
Performs the mutable indexing (container[index]) operation. Read more
Formats the value using the given formatter.
Measure the heap usage of all descendant heap-allocated structures, but not the space taken up by the value itself. If T::size_of is a constant, consider implementing constant_size as well. Read more
Used to optimize MallocSizeOf implementation for collections like Vec and HashMap to avoid iterating over them unnecessarily. The Self: Sized bound is for object safety. Read more
Upper bound, in bytes, of the maximum encoded size of this item.
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
The strategy that should be used to pass the type.
The inner type that is wrapped by Self.
Returns the reference to the inner type.
Consumes self and returns the inner type.
Construct Self from the given inner.
Serialize this value into the given Serde serializer. Read more
The type identifying for which type info is provided. Read more
Returns the static type identifier for Self.
Convert from an instance of T to Self. This is not guaranteed to be whatever counts as a valid instance of T and it’s up to the caller to ensure that it makes sense. Read more
Convert from an instance of T to Self. This is not guaranteed to be whatever counts as a valid instance of T and it’s up to the caller to ensure that it makes sense. Read more
Convert from an instance of T to Self. This is not guaranteed to be whatever counts as a valid instance of T and it’s up to the caller to ensure that it makes sense. Read more
Formats the value using the given formatter.

Auto Trait Implementations§

Blanket Implementations§

Gets the TypeId of self. Read more
Views self as an immutable bit-slice region with the O ordering.
Attempts to view self as an immutable bit-slice region with the O ordering. Read more
Views self as a mutable bit-slice region with the O ordering.
Attempts to view self as a mutable bit-slice region with the O ordering. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts self into T using Into<T>. Read more
Decode Self and consume all of the given input data. Read more
Decode Self and consume all of the given input data. Read more
Decode Self with the given maximum recursion depth and advance input by the number of bytes consumed. Read more
Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more
Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more
Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more
Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more
Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more
Compare self to key and return true if they are equal.
Causes self to use its Binary implementation when Debug-formatted. Read more
Causes self to use its Display implementation when Debug-formatted. Read more
Causes self to use its LowerExp implementation when Debug-formatted. Read more
Causes self to use its LowerHex implementation when Debug-formatted. Read more
Causes self to use its Octal implementation when Debug-formatted. Read more
Causes self to use its Pointer implementation when Debug-formatted. Read more
Causes self to use its UpperExp implementation when Debug-formatted. Read more
Causes self to use its UpperHex implementation when Debug-formatted. Read more
Formats each item in a sequence. Read more

Returns the argument unchanged.

As Self can be an unsized type, it needs to be represented by a sized type at the host. This SelfInstance is the sized type. Read more
Create SelfInstance from the given
Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

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

Convert self into a ffi value.

Get a reference to the inner from the outer.

Get a mutable reference to the inner from the outer.

Return an encoding of Self prepended by given slice.
Method to launch a heapsize measurement with a fresh state. Read more
Pipes by value. This is generally the method you want to use. Read more
Borrows self and passes that borrow into the pipe function. Read more
Mutably borrows self and passes that borrow into the pipe function. Read more
Borrows self, then passes self.borrow() into the pipe function. Read more
Mutably borrows self, then passes self.borrow_mut() into the pipe function. Read more
Borrows self, then passes self.as_ref() into the pipe function.
Mutably borrows self, then passes self.as_mut() into the pipe function. Read more
Borrows self, then passes self.deref() into the pipe function.
Mutably borrows self, then passes self.deref_mut() into the pipe function. Read more
The alignment of pointer.
The type for initializers.
Initializes a with the given initializer. Read more
Dereferences the given pointer. Read more
Mutably dereferences the given pointer. Read more
Drops the object pointed to by the given pointer. Read more
The ffi type that is used to represent Self.
Should always be Self
Immutable access to a value. Read more
Mutable access to a value. Read more
Immutable access to the Borrow<B> of a value. Read more
Mutable access to the BorrowMut<B> of a value. Read more
Immutable access to the AsRef<R> view of a value. Read more
Mutable access to the AsMut<R> view of a value. Read more
Immutable access to the Deref::Target of a value. Read more
Mutable access to the Deref::Target of a value. Read more
Calls .tap() only in debug builds, and is erased in release builds.
Calls .tap_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow() only in debug builds, and is erased in release builds. Read more
Calls .tap_borrow_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref() only in debug builds, and is erased in release builds. Read more
Calls .tap_ref_mut() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref() only in debug builds, and is erased in release builds. Read more
Calls .tap_deref_mut() only in debug builds, and is erased in release builds. Read more
Encode the hex strict representing self into the result. Lower case letters are used (e.g. f9b4ca) Read more
Encode the hex strict representing self into the result. Upper case letters are used (e.g. F9B4CA) Read more
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
Attempts to convert self into T using TryInto<T>. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
The counterpart to unchecked_from.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more