[][src]Struct medallion::Token

pub struct Token<H = (), C = ()> {
    pub header: Header<H>,
    pub payload: Payload<C>,
    // some fields omitted
}

Main struct representing a JSON Web Token, composed of a header and a set of claims.

Fields

header: Header<H>payload: Payload<C>

Implementations

impl<H, C> Token<H, C> where
    H: Serialize + DeserializeOwned,
    C: Serialize + DeserializeOwned
[src]

Provide the ability to parse a token, verify it and sign/serialize it.

pub fn new(header: Header<H>, payload: Payload<C>) -> Token<H, C>[src]

pub fn parse(raw: &str) -> Result<Token<H, C>>[src]

Parse a token from a string.

pub fn verify(&self, key: &[u8]) -> Result<bool>[src]

Verify a token with a key and the token's specific algorithm.

pub fn sign(&self, key: &[u8]) -> Result<String>[src]

Generate the signed token from a key with the specific algorithm as a url-safe, base64 string.

Trait Implementations

impl<H: Debug, C: Debug> Debug for Token<H, C>[src]

impl<H: Default, C: Default> Default for Token<H, C>[src]

impl<H, C> PartialEq<Token<H, C>> for Token<H, C> where
    H: PartialEq,
    C: PartialEq
[src]

Auto Trait Implementations

impl<H, C> RefUnwindSafe for Token<H, C> where
    C: RefUnwindSafe,
    H: RefUnwindSafe

impl<H, C> Send for Token<H, C> where
    C: Send,
    H: Send

impl<H, C> Sync for Token<H, C> where
    C: Sync,
    H: Sync

impl<H, C> Unpin for Token<H, C> where
    C: Unpin,
    H: Unpin

impl<H, C> UnwindSafe for Token<H, C> where
    C: UnwindSafe,
    H: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.