Struct jwt::Token

source ·
pub struct Token<H, C, S> { /* private fields */ }
Expand description

Representation of a structured JWT. Methods vary based on the signature type S.

Implementations§

source§

impl<H, C> Token<H, C, Unsigned>

source

pub fn new(header: H, claims: C) -> Self

Create a new unsigned token, with mutable headers and claims.

source

pub fn header_mut(&mut self) -> &mut H

source

pub fn claims_mut(&mut self) -> &mut C

source§

impl<'a, H, C> Token<H, C, Signed>

source

pub fn as_str(&self) -> &str

Get the string representation of the token.

source§

impl<'a, H: FromBase64, C: FromBase64> Token<H, C, Unverified<'a>>

source

pub fn parse_unverified( token_str: &str, ) -> Result<Token<H, C, Unverified<'_>>, Error>

Not recommended. Parse the header and claims without checking the validity of the signature.

source§

impl<H, C, S> Token<H, C, S>

source

pub fn header(&self) -> &H

source

pub fn claims(&self) -> &C

source

pub fn remove_signature(self) -> Token<H, C, Unsigned>

Trait Implementations§

source§

impl<H, C> Default for Token<H, C, Unsigned>
where H: Default, C: Default,

source§

fn default() -> Self

Returns the “default value” for a type. Read more
source§

impl<H, C, S> From<Token<H, C, S>> for (H, C)

source§

fn from(token: Token<H, C, S>) -> Self

Converts to this type from the input type.
source§

impl<H, C> From<Token<H, C, Signed>> for String

source§

fn from(token: Token<H, C, Signed>) -> Self

Converts to this type from the input type.
source§

impl<H, C> SignWithKey<Token<H, C, Signed>> for Token<H, C, Unsigned>
where H: ToBase64 + JoseHeader, C: ToBase64,

source§

fn sign_with_key( self, key: &impl SigningAlgorithm, ) -> Result<Token<H, C, Signed>, Error>

source§

impl<H, C> SignWithStore<Token<H, C, Signed>> for Token<H, C, Unsigned>
where H: ToBase64 + JoseHeader, C: ToBase64,

source§

fn sign_with_store<S, A>(self, store: &S) -> Result<Token<H, C, Signed>, Error>
where S: Store<Algorithm = A>, A: SigningAlgorithm,

source§

impl<'a, H, C> VerifyWithKey<Token<H, C, Verified>> for &'a str

source§

impl<'a, H: JoseHeader, C> VerifyWithKey<Token<H, C, Verified>> for Token<H, C, Unverified<'a>>

source§

impl<'a, H, C> VerifyWithStore<Token<H, C, Verified>> for &'a str

source§

fn verify_with_store<S, A>( self, store: &S, ) -> Result<Token<H, C, Verified>, Error>
where S: Store<Algorithm = A>, A: VerifyingAlgorithm,

source§

impl<'a, H: JoseHeader, C> VerifyWithStore<Token<H, C, Verified>> for Token<H, C, Unverified<'a>>

source§

fn verify_with_store<S, A>( self, store: &S, ) -> Result<Token<H, C, Verified>, Error>
where S: Store<Algorithm = A>, A: VerifyingAlgorithm,

Auto Trait Implementations§

§

impl<H, C, S> Freeze for Token<H, C, S>
where H: Freeze, C: Freeze, S: Freeze,

§

impl<H, C, S> RefUnwindSafe for Token<H, C, S>

§

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

§

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

§

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

§

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

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

source§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.