#[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
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
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 fn from_token(token: &str) -> Option<Self>
pub fn from_token(token: &str) -> Option<Self>
Parses the IANA token into an algorithm variant. Returns None
for tokens this crate does not recognise.
Trait Implementations§
Source§impl Clone for DigestAlgorithm
impl Clone for DigestAlgorithm
Source§fn clone(&self) -> DigestAlgorithm
fn clone(&self) -> DigestAlgorithm
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DigestAlgorithm
impl Debug for DigestAlgorithm
Source§impl Hash for DigestAlgorithm
impl Hash for DigestAlgorithm
Source§impl PartialEq for DigestAlgorithm
impl PartialEq for DigestAlgorithm
impl Copy for DigestAlgorithm
impl Eq for DigestAlgorithm
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
Mutably borrows from an owned value. Read more
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
Compare self to
key and return true if they are equal.