Skip to main content

Digest

Struct Digest 

Source
pub struct Digest { /* private fields */ }
Expand description

A digest algorithm, bound at creation.

compute is one-shot and stateless per call (the resource is reusable), mirroring crypto.subtle.digest. The byte stream is the only ingestion path; the result is chunking-invariant. The streaming contract in README.md applies.

Security:

  • A digest authenticates nothing by itself. There is deliberately no verify here: checking untrusted data against a known digest is an integrity comparison, done by the caller with a constant-time byte comparison (see README.md, “Terminology”) of compute’s result. When authenticity is needed, use a mac-key.

Implementations§

Source§

impl Digest

Source

pub async fn compute(&self, data: StreamReader<u8>) -> Result<Vec<u8>, Error>

Digest an entire byte stream. A success resolves only after the stream is fully drained (its writer dropped).

Fails only for operational reasons (error.other).

Source§

impl Digest

Source

pub fn algorithm_name(&self) -> String

The registry name of the algorithm this resource is bound to, e.g. "SHA-256" (as crypto.subtle.digest spells it). For a digest the algorithm is the hash, so there is no separate algorithm-hash getter.

Trait Implementations§

Source§

impl Debug for Digest

Source§

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

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

impl From<Digest> for Digest

Source§

fn from(raw: Digest) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

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.

§

impl<T> Resource for T
where T: 'static,

§

type Rep = Option<T>

The type which is actually stored in-memory for this resource. Read more
Source§

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

Source§

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>,

Source§

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.