#[non_exhaustive]pub struct Claims { /* private fields */ }Expand description
JWT claims structure.
Fields are intentionally crate-private. Construct via Claims::builder
and read via the accessor methods. The custom map is gated by
Claims::get_claim / Claims::sanitized_custom so reserved JWT
claim names (iss, aud, nbf, jti, …) can never be retrieved as
custom data, even when serde’s #[serde(flatten)] lets them in.
Implementations§
Source§impl Claims
impl Claims
Sourcepub fn into_roles(self) -> Vec<String>
pub fn into_roles(self) -> Vec<String>
Consume the claims and return the owned roles vector.
Sourcepub fn is_expired(&self) -> bool
pub fn is_expired(&self) -> bool
Check if the token is expired.
Sourcepub fn get_claim(&self, key: &str) -> Option<&Value>
pub fn get_claim(&self, key: &str) -> Option<&Value>
Get a custom claim value.
Returns None for reserved JWT claims (iss, aud, nbf, jti, etc.)
to prevent claim injection via #[serde(flatten)].
Sourcepub fn sanitized_custom(&self) -> HashMap<String, Value>
pub fn sanitized_custom(&self) -> HashMap<String, Value>
Get custom claims with reserved JWT claims filtered out.
Prevents claim injection where standard JWT claims like iss, aud,
or jti end up in the custom claims map via #[serde(flatten)].
Sourcepub fn builder() -> ClaimsBuilder
pub fn builder() -> ClaimsBuilder
Create a builder for constructing claims.
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>,
Auto Trait Implementations§
impl Freeze for Claims
impl RefUnwindSafe for Claims
impl Send for Claims
impl Sync for Claims
impl Unpin for Claims
impl UnsafeUnpin 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§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>
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