Struct ShaDigest

Source
pub struct ShaDigest<'d, A, S: Borrow<Sha<'d>>> { /* private fields */ }
Available on crate feature unstable only.
Expand description

An active digest

This implementation might fail after u32::MAX/8 bytes, to increase please see ::finish() length/self.cursor usage

Implementations§

Source§

impl<'d, A: ShaAlgorithm, S: Borrow<Sha<'d>>> ShaDigest<'d, A, S>

Source

pub fn new(sha: S) -> Self

Creates a new digest

Source

pub fn restore(sha: S, ctx: &mut Context<A>) -> Self

Restores a previously saved digest.

Source

pub fn is_busy(&self) -> bool

Returns true if the hardware is processing the next message.

Source

pub fn update<'a>(&mut self, incoming: &'a [u8]) -> Result<&'a [u8], Infallible>

Updates the SHA digest with the provided data buffer.

Source

pub fn finish(&mut self, output: &mut [u8]) -> Result<(), Infallible>

Finish of the calculation (if not already) and copy result to output After finish() is called update()s will contribute to a new hash which can be calculated again with finish().

Typically, output is expected to be the size of ShaAlgorithm::DIGEST_LENGTH, but smaller inputs can be given to get a “short hash”

Source

pub fn save(&mut self, context: &mut Context<A>) -> Result<(), Infallible>

Save the current state of the digest for later continuation.

Source

pub fn cancel(self) -> S

Discard the current digest and return the peripheral.

Auto Trait Implementations§

§

impl<'d, A, S> Freeze for ShaDigest<'d, A, S>
where S: Freeze,

§

impl<'d, A, S> RefUnwindSafe for ShaDigest<'d, A, S>
where S: RefUnwindSafe, A: RefUnwindSafe,

§

impl<'d, A, S> Send for ShaDigest<'d, A, S>
where S: Send, A: Send,

§

impl<'d, A, S> Sync for ShaDigest<'d, A, S>
where S: Sync, A: Sync,

§

impl<'d, A, S> Unpin for ShaDigest<'d, A, S>
where S: Unpin, A: Unpin,

§

impl<'d, A, S> UnwindSafe for ShaDigest<'d, A, S>
where S: UnwindSafe, A: UnwindSafe,

Blanket Implementations§

§

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

§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

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

§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
§

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

§

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

Mutably borrows from an owned value. Read more
§

impl<T> From<T> for T

§

fn from(t: T) -> T

Returns the argument unchanged.

§

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

§

fn into(self) -> U

Calls U::from(self).

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

§

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

§

type Error = Infallible

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

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

Performs the conversion.
§

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.
§

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

Performs the conversion.