Hasher

Trait Hasher 

Source
pub trait Hasher {
    type Output: Hash;

    // Required methods
    fn new(metadata: &Metadata) -> Self;
    fn hash(&self, s: &[u8]) -> Self::Output;

    // Provided method
    fn hash_of<S: Encode>(&self, s: &S) -> Self::Output { ... }
}
Expand description

This represents the hasher used by a node to hash things like block headers and extrinsics.

Required Associated Types§

Source

type Output: Hash

The type given back from the hash operation

Required Methods§

Source

fn new(metadata: &Metadata) -> Self

Construct a new hasher.

Source

fn hash(&self, s: &[u8]) -> Self::Output

Hash some bytes to the given output type.

Provided Methods§

Source

fn hash_of<S: Encode>(&self, s: &S) -> Self::Output

Hash some SCALE encodable type to the given output type.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§