#[non_exhaustive]pub enum DigestAlgorithm {
Sha256,
Sha512,
}Expand description
A hash algorithm registered with the IANA Hash Algorithm Names
registry and accepted by RFC 9530 Content-Digest.
Only the algorithms the Fediverse actually uses today are
enumerated; future algorithms can be added without breaking the wire
format because the variant set is #[non_exhaustive].
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Sha256
SHA-256 — universally supported by today’s Fediverse.
Sha512
SHA-512 — emitted by Mitra and Takahē, accepted by Mastodon 4.5+.
Implementations§
Source§impl DigestAlgorithm
impl DigestAlgorithm
Sourcepub const fn token(self) -> &'static str
pub const fn token(self) -> &'static str
IANA-registered token used as the dictionary key in the wire header.
Sourcepub fn hash(self, body: &[u8]) -> Vec<u8> ⓘ
pub fn hash(self, body: &[u8]) -> Vec<u8> ⓘ
Computes the digest bytes of body under this algorithm.
Sourcepub const fn from_token(token: &str) -> Option<Self>
pub const fn from_token(token: &str) -> Option<Self>
Parses the IANA token into an algorithm variant. Returns None
for tokens this crate does not recognise.
RFC 9530 mandates the lowercase canonical form on the wire, but
real-world senders occasionally emit SHA-256; we follow
Postel’s law and accept any ASCII casing on the read side while
still emitting the canonical form.
Trait Implementations§
Source§impl Clone for DigestAlgorithm
impl Clone for DigestAlgorithm
Source§fn clone(&self) -> DigestAlgorithm
fn clone(&self) -> DigestAlgorithm
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for DigestAlgorithm
Source§impl Debug for DigestAlgorithm
impl Debug for DigestAlgorithm
impl Eq for DigestAlgorithm
Source§impl Hash for DigestAlgorithm
impl Hash for DigestAlgorithm
Source§impl PartialEq for DigestAlgorithm
impl PartialEq for DigestAlgorithm
Source§fn eq(&self, other: &DigestAlgorithm) -> bool
fn eq(&self, other: &DigestAlgorithm) -> bool
self and other values to be equal, and is used by ==.impl StructuralPartialEq for DigestAlgorithm
Auto Trait Implementations§
impl Freeze for DigestAlgorithm
impl RefUnwindSafe for DigestAlgorithm
impl Send for DigestAlgorithm
impl Sync for DigestAlgorithm
impl Unpin for DigestAlgorithm
impl UnsafeUnpin for DigestAlgorithm
impl UnwindSafe for DigestAlgorithm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.