pub struct Claims {
pub iat: u64,
pub exp: Option<u64>,
}
jwt
only.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§
source§impl Claims
impl Claims
sourcepub fn with_current_timestamp() -> Self
pub fn with_current_timestamp() -> Self
Creates a new instance of Claims
with the current timestamp as the iat
claim.
sourcepub 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§
source§impl<'de> Deserialize<'de> for Claims
impl<'de> Deserialize<'de> for Claims
source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
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,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)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