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
sourceimpl HeaderAndClaims<Map<String, Value>>
impl HeaderAndClaims<Map<String, Value>>
pub fn new_dynamic() -> Self
sourceimpl<ExtraClaims> HeaderAndClaims<ExtraClaims>
impl<ExtraClaims> HeaderAndClaims<ExtraClaims>
pub fn with_claims(extra: ExtraClaims) -> Self
pub fn header(&self) -> &Header
pub fn claims(&self) -> &Claims<ExtraClaims>
pub fn header_mut(&mut self) -> &mut Header
pub fn claims_mut(&mut self) -> &mut Claims<ExtraClaims>
pub fn set_kid(&mut self, kid: impl Into<String>) -> &mut Self
pub fn set_iss(&mut self, iss: impl Into<String>) -> &mut Self
pub fn set_sub(&mut self, sub: impl Into<String>) -> &mut Self
pub fn set_jti(&mut self, jti: impl Into<String>) -> &mut Self
pub fn set_auds(&mut self, auds: Vec<String>) -> &mut Self
pub fn add_aud(&mut self, aud: impl Into<String>) -> &mut Self
sourcepub fn set_iat_now(&mut self) -> &mut Self
pub fn set_iat_now(&mut self) -> &mut Self
Set token issued-at time (iat
) to the current system time, i.e.
SystemTime::now()
.
sourcepub fn iat_is_later_than(&self, t: SystemTime) -> bool
pub fn iat_is_later_than(&self, t: SystemTime) -> bool
Check that iat
is present and is later than t
.
sourcepub fn set_exp_from_now(&mut self, dur: Duration) -> &mut Self
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
.
sourcepub fn set_nbf_from_now(&mut self, dur: Duration) -> &mut Self
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
.
Trait Implementations
sourceimpl<ExtraClaims: Debug> Debug for HeaderAndClaims<ExtraClaims>
impl<ExtraClaims: Debug> Debug for HeaderAndClaims<ExtraClaims>
sourceimpl<ExtraClaims: Default> Default for HeaderAndClaims<ExtraClaims>
impl<ExtraClaims: Default> Default for HeaderAndClaims<ExtraClaims>
sourcefn default() -> HeaderAndClaims<ExtraClaims>
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
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Instruments this type with the provided Span
, returning an
Instrumented
wrapper. Read more