Trait jwt_compact::AlgorithmSignature [−][src]
pub trait AlgorithmSignature: Sized {
const LENGTH: Option<NonZeroUsize>;
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.
Associated Constants
const LENGTH: Option<NonZeroUsize>
const LENGTH: Option<NonZeroUsize>
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
Attempts to restore a signature from a byte slice. This method may fail if the slice is malformed.