Struct fog_crypto::hash::HashState[][src]

pub struct HashState { /* fields omitted */ }

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

impl HashState[src]

pub fn new() -> HashState[src]

Initialize a new hasher.

pub fn with_version(version: u8) -> Result<HashState, CryptoError>[src]

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.

pub fn version(&self) -> u8[src]

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

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

Update the hasher with new input data.

pub fn hash(&self) -> Hash[src]

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

pub fn finalize(self) -> Hash[src]

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

Trait Implementations

impl Clone for HashState[src]

impl Debug for HashState[src]

impl Default for HashState[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>,