pub trait HashAlgorithm:
Sized
+ PartialEq
+ Eq
+ Debug
+ Clone {
// Required method
fn len(&self) -> usize;
// Provided methods
fn from_cose_number(number: impl Into<i128>) -> Option<Self> { ... }
fn from_ni_id(number: u8) -> Option<Self> { ... }
fn from_ni_name(name: &str) -> Option<Self> { ... }
}Expand description
A hash algorithm identifier.
While const traits are not stable yet, implementers should prepare for the constructors and
other methods to be const functions.
Required Methods§
Provided Methods§
Sourcefn from_cose_number(number: impl Into<i128>) -> Option<Self>
fn from_cose_number(number: impl Into<i128>) -> Option<Self>
Selects a hash algorithm from its COSE number.
The algorithm number comes from the “COSE Algorithms” registry maintained by IANA.
This works from Into<i128> because the numeric range of CBOR integers is effectively that
of a i65 (the sign is in the data type); inlining will take care of systems not actually
materializing any i128 comparisons, let alone arithmetic.
Sourcefn from_ni_id(number: u8) -> Option<Self>
fn from_ni_id(number: u8) -> Option<Self>
Selects a hash algorithm from a Suite ID out of the IANA Named Information Hash Algorith Registry
https://www.iana.org/assignments/named-information/named-information.xhtml#hash-alg
Note that while the number is expressed as a u8, the actual usable value space is
0..=63 excluding the reserved 32; implementations must return None for values outside this
range.
Sourcefn from_ni_name(name: &str) -> Option<Self>
fn from_ni_name(name: &str) -> Option<Self>
Selects a hash algorithm from a Hash Name String out of the IANA Named Information Hash Algorith Registry
https://www.iana.org/assignments/named-information/named-information.xhtml#hash-alg
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".