pub struct JwtClaims<T = Map>(/* private fields */);
Available on crate feature
jwt
only.Expand description
JWT Claims.
Implementations§
Source§impl<T: Default + Serialize + DeserializeOwned> JwtClaims<T>
impl<T: Default + Serialize + DeserializeOwned> JwtClaims<T>
Sourcepub fn new(subject: impl ToString) -> Self
pub fn new(subject: impl ToString) -> Self
Creates a new instance with the default data and max-age
.
Sourcepub fn with_data(subject: impl ToString, data: T) -> Self
pub fn with_data(subject: impl ToString, data: T) -> Self
Creates a new instance with the custom data.
Sourcepub fn with_max_age(subject: impl ToString, max_age: Duration) -> Self
pub fn with_max_age(subject: impl ToString, max_age: Duration) -> Self
Creates a new instance, expiring in max-age
.
Sourcepub fn refresh_token(&self) -> Result<String, Error>
pub fn refresh_token(&self) -> Result<String, Error>
Generates an access token signed with the shared secret access key.
Sourcepub fn access_token(self) -> Result<String, Error>
pub fn access_token(self) -> Result<String, Error>
Generates an access token signed with the shared secret access key.
Source§impl<T> JwtClaims<T>
impl<T> JwtClaims<T>
Sourcepub fn set_issuer(&mut self, issuer: impl ToString)
pub fn set_issuer(&mut self, issuer: impl ToString)
Sets the issuer.
Sourcepub fn set_audience(&mut self, audience: impl ToString)
pub fn set_audience(&mut self, audience: impl ToString)
Sets the audience.
Sourcepub fn set_jwt_id(&mut self, jwt_id: impl ToString)
pub fn set_jwt_id(&mut self, jwt_id: impl ToString)
Sets the JWT identifier.
Sourcepub fn expires_at(&self) -> DateTime
pub fn expires_at(&self) -> DateTime
Returns the time the claims expire at.
Sourcepub fn expires_in(&self) -> Duration
pub fn expires_in(&self) -> Duration
Returns the time when the claims will expire in.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for JwtClaims<T>where
T: Freeze,
impl<T> RefUnwindSafe for JwtClaims<T>where
T: RefUnwindSafe,
impl<T> Send for JwtClaims<T>where
T: Send,
impl<T> Sync for JwtClaims<T>where
T: Sync,
impl<T> Unpin for JwtClaims<T>where
T: Unpin,
impl<T> UnwindSafe for JwtClaims<T>where
T: 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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>
Converts
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>
Converts
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