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>>
impl HeaderAndClaims<Map<String, Value>>
pub fn new_dynamic() -> Self
Source§impl<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§
Source§impl<ExtraClaims: Clone> Clone for HeaderAndClaims<ExtraClaims>
impl<ExtraClaims: Clone> Clone for HeaderAndClaims<ExtraClaims>
Source§fn clone(&self) -> HeaderAndClaims<ExtraClaims>
fn clone(&self) -> HeaderAndClaims<ExtraClaims>
Returns a duplicate of the value. Read more
1.0.0 · Source§const fn clone_from(&mut self, source: &Self)
const fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreSource§impl<ExtraClaims: Debug> Debug for HeaderAndClaims<ExtraClaims>
impl<ExtraClaims: Debug> Debug for HeaderAndClaims<ExtraClaims>
Source§impl<ExtraClaims: Default> Default for HeaderAndClaims<ExtraClaims>
impl<ExtraClaims: Default> Default for HeaderAndClaims<ExtraClaims>
Source§fn default() -> HeaderAndClaims<ExtraClaims>
fn default() -> HeaderAndClaims<ExtraClaims>
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl<ExtraClaims> Freeze for HeaderAndClaims<ExtraClaims>where
ExtraClaims: Freeze,
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more