pub trait AlgorithmSignature: Sized {
const LENGTH: Option<NonZeroUsize> = None;
// Required methods
fn try_from_slice(slice: &[u8]) -> Result<Self>;
fn as_bytes(&self) -> Cow<'_, [u8]>;
}
Expand description
Signature for a certain JWT signing Algorithm
.
We require that signature can be restored from a byte slice, and can be represented as a byte slice.
Provided Associated Constants§
Sourceconst LENGTH: Option<NonZeroUsize> = None
const LENGTH: Option<NonZeroUsize> = None
Constant byte length of signatures supported by the Algorithm
, or None
if
the signature length is variable.
- If this value is
Some(_)
, the signature will be first checked for its length during token verification. AnInvalidSignatureLen
error will be raised if the length is invalid.Self::try_from_slice()
will thus always receive a slice with the expected length. - If this value is
None
, no length check is performed before callingSelf::try_from_slice()
.
Required Methods§
Sourcefn try_from_slice(slice: &[u8]) -> Result<Self>
fn try_from_slice(slice: &[u8]) -> Result<Self>
Attempts to restore a signature from a byte slice. This method may fail if the slice is malformed.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.