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§

source

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. An InvalidSignatureLen 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 calling Self::try_from_slice().

Required Methods§

source

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.

source

fn as_bytes(&self) -> Cow<'_, [u8]>

Represents this signature as bytes.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl AlgorithmSignature for Signature

source§

const LENGTH: Option<NonZeroUsize> = _

source§

fn try_from_slice(bytes: &[u8]) -> Result<Self>

source§

fn as_bytes(&self) -> Cow<'_, [u8]>

source§

impl AlgorithmSignature for Signature

source§

const LENGTH: Option<NonZeroUsize> = _

source§

fn try_from_slice(slice: &[u8]) -> Result<Self>

source§

fn as_bytes(&self) -> Cow<'_, [u8]>

source§

impl AlgorithmSignature for Signature

source§

const LENGTH: Option<NonZeroUsize> = _

source§

fn try_from_slice(slice: &[u8]) -> Result<Self>

source§

fn as_bytes(&self) -> Cow<'_, [u8]>

Implementors§