Trait Hasher

pub trait Hasher: Sync + Send {
    type Out: AsRef<[u8]> + AsMut<[u8]> + Default + MaybeDebug + Ord + PartialEq + Eq + Hash + Send + Sync + Clone + Copy;
    type StdHasher: Sync + Send + Default + Hasher;

    const LENGTH: usize;

    // Required method
    fn hash(x: &[u8]) -> Self::Out;
}
Expand description

Trait describing an object that can hash a slice of bytes. Used to abstract other types over the hashing algorithm. Defines a single hash method and an Out associated type with the necessary bounds.

Required Associated Constants§

const LENGTH: usize

The length in bytes of the Hasher output.

Required Associated Types§

type Out: AsRef<[u8]> + AsMut<[u8]> + Default + MaybeDebug + Ord + PartialEq + Eq + Hash + Send + Sync + Clone + Copy

The output type of the Hasher

type StdHasher: Sync + Send + Default + Hasher

What to use to build HashMaps with this Hasher.

Required Methods§

fn hash(x: &[u8]) -> Self::Out

Compute the hash of the provided slice of bytes returning the Out type of the Hasher.

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.

Implementations on Foreign Types§

§

impl Hasher for Blake2Hasher

§

const LENGTH: usize = 32usize

§

type Out = H256

§

type StdHasher = Hash256StdHasher

§

fn hash(x: &[u8]) -> <Blake2Hasher as Hasher>::Out

§

impl Hasher for BlakeTwo256

§

const LENGTH: usize = 32usize

§

type Out = H256

§

type StdHasher = Hash256StdHasher

§

fn hash(s: &[u8]) -> <BlakeTwo256 as Hasher>::Out

§

impl Hasher for Keccak256

§

const LENGTH: usize = 32usize

§

type Out = H256

§

type StdHasher = Hash256StdHasher

§

fn hash(s: &[u8]) -> <Keccak256 as Hasher>::Out

§

impl Hasher for KeccakHasher

§

const LENGTH: usize = 32usize

§

type Out = H256

§

type StdHasher = Hash256StdHasher

§

fn hash(x: &[u8]) -> <KeccakHasher as Hasher>::Out

§

impl Hasher for KeccakHasher

§

const LENGTH: usize = 32usize

§

type Out = H256

§

type StdHasher = Hash256StdHasher

§

fn hash(x: &[u8]) -> <KeccakHasher as Hasher>::Out

Implementors§