Struct chksum_hash_sha2_384::Update

source ·
pub struct Update { /* private fields */ }
Expand description

A hash state containing an internal buffer that can handle an unknown amount of input data.

§Example

use chksum_hash_sha2_384 as sha2_384;

// Create a new hash instance
let mut hash = sha2_384::Update::new();

// Fill with data
hash.update("data");

// Finalize and create a digest
let digest = hash.finalize().digest();
assert_eq!(
    digest.to_hex_lowercase(),
    "2039e0f0b92728499fb88e23ebc3cfd0554b28400b0ed7b753055c88b5865c3c2aa72c6a1a9ae0a755d87900a4a6ff41"
);

// Reset to default values
hash.reset();

// Produce a hash digest using internal finalization
let digest = hash.digest();
assert_eq!(
    digest.to_hex_lowercase(),
    "38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"
);

Implementations§

source§

impl Update

source

pub fn new() -> Self

Creates a new hash.

source

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

Updates the internal state with an input data.

§Performance issues

To achieve maximum performance, the length of incoming data parts should be a multiple of the block length.

In any other case, an internal buffer is used, which can cause a speed decrease in performance.

source

pub fn finalize(&self) -> Finalize

Applies padding and produces the finalized state.

source

pub fn reset(&mut self) -> &mut Self

Resets the internal state to default values.

source

pub fn digest(&self) -> Digest

Produces the hash digest using internal finalization.

Trait Implementations§

source§

impl<'arbitrary> Arbitrary<'arbitrary> for Update

source§

fn arbitrary(u: &mut Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the given unstructured data. Read more
source§

fn arbitrary_take_rest(u: Unstructured<'arbitrary>) -> Result<Self>

Generate an arbitrary value of Self from the entirety of the given unstructured data. Read more
source§

fn size_hint(depth: usize) -> (usize, Option<usize>)

Get a size hint for how many bytes out of an Unstructured this type needs to construct itself. Read more
source§

impl Clone for Update

source§

fn clone(&self) -> Update

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Update

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Update

source§

fn default() -> Self

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

impl PartialEq for Update

source§

fn eq(&self, other: &Update) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl Update for Update

§

type Digest = Digest

The type representing the digest produced by finalizing the hash.
§

type Finalize = Finalize

The type representing the finalized state, which can be converted into a digest.
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.
source§

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

Produces the hash digest using internal finalization.
source§

impl Eq for Update

source§

impl StructuralPartialEq for Update

Auto Trait Implementations§

§

impl Freeze for Update

§

impl RefUnwindSafe for Update

§

impl Send for Update

§

impl Sync for Update

§

impl Unpin for Update

§

impl UnwindSafe for Update

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.