pub struct HashState { /* private fields */ }
Expand description

A hasher that can incrementally take in data and produce a hash at any time.

Example

// Create a hash by feeding in bytes repeatedly
let mut hash_state = HashState::new();
hash_state.update(b"I am the first part of a data sequence");
let hash_first = hash_state.hash(); // Produce a hash of just the first part
hash_state.update(b"And I am their sibling, the second part of a data sequence");
let hash_full = hash_state.finalize(); // Consume the HashState
println!("hash_first(Base58): {}", hash_first);
println!("hash_full(Base58): {}", hash_full);

Implementations

Initialize a new hasher.

Initialize a new hasher with a specific algorithm version. You should avoid this except when working through an upgrade process, where you may briefly need to support more than one version. Fails if the version isn’t supported.

Get the version of hash that this hasher will produce on completion.

Update the hasher with new input data.

Get the hash of the data fed into the algorithm so far.

Finalize the hasher and produce a hash. Functions like hash() but consumes the state.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.