Trait Hash

Source
pub trait Hash: Default {
    type Digest: Digest;

    // Required methods
    fn update<T>(&mut self, data: T)
       where T: AsRef<[u8]>;
    fn reset(&mut self);
    fn digest(&self) -> Self::Digest;

    // Provided method
    fn hash<T>(data: T) -> Self::Digest
       where T: AsRef<[u8]> { ... }
}
Expand description

A trait for hash objects.

Required Associated Types§

Source

type Digest: Digest

The type representing the digest produced by finalizing the hash.

Required Methods§

Source

fn update<T>(&mut self, data: T)
where T: AsRef<[u8]>,

Updates the hash state with an input data.

Source

fn reset(&mut self)

Resets the hash state to its initial state.

Source

fn digest(&self) -> Self::Digest

Produces the hash digest.

Provided Methods§

Source

fn hash<T>(data: T) -> Self::Digest
where T: AsRef<[u8]>,

Calculates the hash digest of an input data.

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§