Struct jwtk::HeaderAndClaims

source ·
pub struct HeaderAndClaims<ExtraClaims> { /* private fields */ }
Expand description

JWT header and claims.

ExtraClaims

Use serde_json::Map<String, Value> for dynamic claims.

Or define your own claims type which implements Serialize/Deserialize.

Implementations§

source§

impl HeaderAndClaims<Map<String, Value>>

source

pub fn new_dynamic() -> Self

source§

impl<ExtraClaims> HeaderAndClaims<ExtraClaims>

source

pub fn with_claims(extra: ExtraClaims) -> Self

source

pub fn header(&self) -> &Header

source

pub fn claims(&self) -> &Claims<ExtraClaims>

source

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

source

pub fn claims_mut(&mut self) -> &mut Claims<ExtraClaims>

source

pub fn set_kid(&mut self, kid: impl Into<String>) -> &mut Self

source

pub fn set_iss(&mut self, iss: impl Into<String>) -> &mut Self

source

pub fn set_sub(&mut self, sub: impl Into<String>) -> &mut Self

source

pub fn set_jti(&mut self, jti: impl Into<String>) -> &mut Self

source

pub fn set_auds(&mut self, auds: Vec<String>) -> &mut Self

source

pub fn add_aud(&mut self, aud: impl Into<String>) -> &mut Self

source

pub fn set_iat_now(&mut self) -> &mut Self

Set token issued-at time (iat) to the current system time, i.e. SystemTime::now().

source

pub fn iat_is_later_than(&self, t: SystemTime) -> bool

Check that iat is present and is later than t.

source

pub fn set_exp_from_now(&mut self, dur: Duration) -> &mut Self

Set token expiration time (exp) to some time after the current time, i.e., SystemTime::now() + dur.

source

pub fn set_nbf_from_now(&mut self, dur: Duration) -> &mut Self

Set token not-before time (nbf) to some time after the current time, i.e., SystemTime::now() + dur.

source§

impl HeaderAndClaims<Map<String, Value>>

source

pub fn insert(&mut self, k: impl Into<String>, v: impl Into<Value>) -> &mut Self

Trait Implementations§

source§

impl<ExtraClaims: Debug> Debug for HeaderAndClaims<ExtraClaims>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<ExtraClaims: Default> Default for HeaderAndClaims<ExtraClaims>

source§

fn default() -> HeaderAndClaims<ExtraClaims>

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

Auto Trait Implementations§

§

impl<ExtraClaims> RefUnwindSafe for HeaderAndClaims<ExtraClaims>where ExtraClaims: RefUnwindSafe,

§

impl<ExtraClaims> Send for HeaderAndClaims<ExtraClaims>where ExtraClaims: Send,

§

impl<ExtraClaims> Sync for HeaderAndClaims<ExtraClaims>where ExtraClaims: Sync,

§

impl<ExtraClaims> Unpin for HeaderAndClaims<ExtraClaims>where ExtraClaims: Unpin,

§

impl<ExtraClaims> UnwindSafe for HeaderAndClaims<ExtraClaims>where ExtraClaims: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for Twhere 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, U> TryFrom<U> for Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.