Trait Hash

Source
pub trait Hash:
    'static
    + MaybeSerializeDeserialize
    + Debug
    + Clone
    + Eq
    + PartialEq
    + Hasher<Out = Self::Output> {
    type Output: Member + MaybeSerializeDeserialize + Debug + Hash + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + Encode + Decode;

    // Required methods
    fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output;
    fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output;

    // Provided methods
    fn hash(s: &[u8]) -> Self::Output { ... }
    fn hash_of<S: Encode>(s: &S) -> Self::Output { ... }
}
Expand description

Abstraction around hashing

Required Associated Types§

Source

type Output: Member + MaybeSerializeDeserialize + Debug + Hash + AsRef<[u8]> + AsMut<[u8]> + Copy + Default + Encode + Decode

The hash type produced.

Required Methods§

Source

fn ordered_trie_root(input: Vec<Vec<u8>>) -> Self::Output

The ordered Patricia tree root of the given input.

Source

fn trie_root(input: Vec<(Vec<u8>, Vec<u8>)>) -> Self::Output

The Patricia tree root of the given mapping.

Provided Methods§

Source

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

Produce the hash of some byte-slice.

Source

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

Produce the hash of some codec-encodable value.

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§