jwt_compact

Trait AlgorithmSignature

Source
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.

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.

Implementations on Foreign Types§

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(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]>

Implementors§