Trait Update

Source
pub trait Update: Default {
    type Digest: Digest;
    type Finalize: Finalize<Digest = Self::Digest, Update = Self>;

    // Required methods
    fn update(&mut self, data: impl AsRef<[u8]>);
    fn finalize(&self) -> Self::Finalize;
    fn reset(&mut self);

    // Provided method
    fn digest(&self) -> Self::Digest { ... }
}
Expand description

A trait for hash objects in an in-progress state.

This trait defines the common interface for hash objects that are in the process of being updated with new data. Implementations of this trait typically maintain an internal state that evolves as new data is added.

Required Associated Types§

Source

type Digest: Digest

The type representing the digest produced by finalizing the hash.

Source

type Finalize: Finalize<Digest = Self::Digest, Update = Self>

The type representing the finalized state, which can be converted into a digest.

Required Methods§

Source

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

Updates the hash state with an input data.

Source

fn finalize(&self) -> Self::Finalize

Finalizes the hash state.

Source

fn reset(&mut self)

Resets the hash state to its initial state.

Provided Methods§

Source

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

Produces the hash digest using internal finalization.

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§