Hashed

Trait Hashed 

Source
pub trait Hashed: Sized {
    type Algorithm: Digest<OutputSize = Self::OutputSize> + Send;
    type OutputSize: ArrayLength<u8> + Unsigned;

    // Required method
    fn from_digest(output: GenericArray<u8, Self::OutputSize>) -> Self;
}
Expand description

This trait provides a formal representation of actual hash values.

This trait is called Hashed because Rust already has a trait called Hash, which is used for hashing keys in hash maps. To avoid confusion, this trait is called Hashed which hopefully makes it clear that it represents the result of a hashing algorithm, and not the hashable type or the algorithm itself.

Required Associated Types§

Source

type Algorithm: Digest<OutputSize = Self::OutputSize> + Send

The hashing algorithm to use produce the hash.

Source

type OutputSize: ArrayLength<u8> + Unsigned

The output size of the hashing algorithm.

Required Methods§

Source

fn from_digest(output: GenericArray<u8, Self::OutputSize>) -> Self

Converts the output of the hashing algorithm to the Hashed type.

§Parameters
  • output - The output of the hashing algorithm, taken as input here.

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§