Struct Claims
pub struct Claims {
pub iat: u64,
pub exp: Option<u64>,
}
Expand description
Claims in JWT are used to represent a set of information about an entity.
Claims are essentially key-value pairs that are encoded as JSON objects and included in the payload of a JWT. They are used to transmit information such as the identity of the entity, the time the JWT was issued, and the expiration time of the JWT, among others.
The Engine API spec requires that just the iat
(issued-at) claim is provided.
It ignores claims that are optional or additional for this specification.
Fields§
§iat: u64
The “iat” value MUST be a number containing a NumericDate value. According to the RFC A NumericDate represents the number of seconds since the UNIX_EPOCH.
exp: Option<u64>
The “exp” (expiration time) claim identifies the expiration time on or after which the JWT MUST NOT be accepted for processing.
Implementations§
§impl Claims
impl Claims
pub fn with_current_timestamp() -> Claims
pub fn with_current_timestamp() -> Claims
Creates a new instance of Claims
with the current timestamp as the iat
claim.
pub fn is_within_time_window(&self) -> bool
pub fn is_within_time_window(&self) -> bool
Checks if the iat
claim is within the allowed range from the current time.
Trait Implementations§
§impl<'de> Deserialize<'de> for Claims
impl<'de> Deserialize<'de> for Claims
§fn deserialize<__D>(
__deserializer: __D,
) -> Result<Claims, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<Claims, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
§impl Serialize for Claims
impl Serialize for Claims
§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
impl Copy for Claims
Auto Trait Implementations§
impl Freeze for Claims
impl RefUnwindSafe for Claims
impl Send for Claims
impl Sync for Claims
impl Unpin for Claims
impl UnwindSafe for Claims
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<T> ErasedDestructor for Twhere
T: 'static,
impl<T> MaybeSend for Twhere
T: Send,
impl<T> MaybeSendSync for T
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.
Size: 24 bytes