Skip to main content

JwtClaims

Struct JwtClaims 

Source
pub struct JwtClaims { /* private fields */ }
Expand description

Standard and extensible JSON Web Token claims payload.

Implementations§

Source§

impl JwtClaims

Inherent implementation of JwtClaims.

Source

pub fn new<S>(subject: S, ttl_secs: u64) -> Self
where S: Into<String>,

Creates a minimal JwtClaims payload for subject expiring in ttl_secs.

§Arguments
  • S - Subject identifier convertible into String.
  • u64 - Lifetime in seconds from current Unix time.
§Returns
  • Self - Constructed claims payload.
Source

pub fn with_roles<I, S>(self, roles: I) -> Self
where I: IntoIterator<Item = S>, S: Into<String>,

Attaches RBAC roles to this claims payload.

§Arguments
  • I - Iterator of role names.
§Returns
  • Self - Updated claims payload.
Source

pub fn with_issuer<S>(self, issuer: S) -> Self
where S: Into<String>,

Sets the iss issuer claim.

§Arguments
  • S - Issuer identifier.
§Returns
  • Self - Updated claims payload.
Source

pub fn with_audience<S>(self, audience: S) -> Self
where S: Into<String>,

Sets the aud audience claim.

§Arguments
  • S - Audience identifier.
§Returns
  • Self - Updated claims payload.
Source§

impl JwtClaims

Source

pub fn get_sub(&self) -> &String

Source

pub fn get_mut_sub(&mut self) -> &mut String

Source

pub fn set_sub(&mut self, val: String) -> &mut Self

Source

pub fn get_iss(&self) -> Option<String>

Source

pub fn try_get_iss(&self) -> Option<String>

Source

pub fn get_mut_iss(&mut self) -> &mut Option<String>

Source

pub fn set_iss(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_aud(&self) -> Option<String>

Source

pub fn try_get_aud(&self) -> Option<String>

Source

pub fn get_mut_aud(&mut self) -> &mut Option<String>

Source

pub fn set_aud(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_exp(&self) -> Option<u64>

Source

pub fn try_get_exp(&self) -> Option<u64>

Source

pub fn get_mut_exp(&mut self) -> &mut Option<u64>

Source

pub fn set_exp(&mut self, val: Option<u64>) -> &mut Self

Source

pub fn get_nbf(&self) -> Option<u64>

Source

pub fn try_get_nbf(&self) -> Option<u64>

Source

pub fn get_mut_nbf(&mut self) -> &mut Option<u64>

Source

pub fn set_nbf(&mut self, val: Option<u64>) -> &mut Self

Source

pub fn get_iat(&self) -> Option<u64>

Source

pub fn try_get_iat(&self) -> Option<u64>

Source

pub fn get_mut_iat(&mut self) -> &mut Option<u64>

Source

pub fn set_iat(&mut self, val: Option<u64>) -> &mut Self

Source

pub fn get_jti(&self) -> Option<String>

Source

pub fn try_get_jti(&self) -> Option<String>

Source

pub fn get_mut_jti(&mut self) -> &mut Option<String>

Source

pub fn set_jti(&mut self, val: Option<String>) -> &mut Self

Source

pub fn get_roles(&self) -> &Vec<String>

Source

pub fn get_mut_roles(&mut self) -> &mut Vec<String>

Source

pub fn set_roles(&mut self, val: Vec<String>) -> &mut Self

Source

pub fn get_extra(&self) -> &HashMap<String, Value>

Source

pub fn get_mut_extra(&mut self) -> &mut HashMap<String, Value>

Source

pub fn set_extra(&mut self, val: HashMap<String, Value>) -> &mut Self

Trait Implementations§

Source§

impl Clone for JwtClaims

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for JwtClaims

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for JwtClaims

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for JwtClaims

Single-pass Serde deserialization for JwtClaims without #[serde(flatten)] buffering.

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserializes a JSON claims object directly via [JwtClaimsVisitor].

§Arguments
  • D - Serde deserializer.
§Returns
  • Result<Self, D::Error> - Deserialized JwtClaims or error.
Source§

impl PartialEq for JwtClaims

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for JwtClaims

Single-pass Serde serialization for JwtClaims without #[serde(flatten)] overhead.

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serializes standard claims and flattened extra entries directly into a JSON map.

§Arguments
  • S - Serde serializer.
§Returns
  • Result<S::Ok, S::Error> - Serialized representation or error.
Source§

impl StructuralPartialEq for JwtClaims

Auto Trait Implementations§

§

impl Forget for JwtClaims

§

impl Freeze for JwtClaims

§

impl Move for JwtClaims

§

impl RefUnwindSafe for JwtClaims

§

impl Send for JwtClaims
where RawVecInner: Send, RawTable<(String, Value)>: Send,

§

impl Sync for JwtClaims
where RawVecInner: Sync, RawTable<(String, Value)>: Sync,

§

impl Unpin for JwtClaims
where *const u8 is !null: Unpin, *const LeafNode<String, Value> is !null: Unpin, Box<(String, Value)>: Unpin,

§

impl UnsafeUnpin for JwtClaims

§

impl UnwindSafe for JwtClaims
where RawVecInner: UnwindSafe, HashMap<String, Value>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> AnySend for T
where T: Any + Send,

Source§

impl<T> AnySendClone for T
where T: Any + Send + Clone,

Source§

impl<T> AnySendSync for T
where T: Any + Send + Sync,

Source§

impl<T> AnySendSyncClone for T
where T: Any + Send + Sync + Clone,

Source§

impl<T> AnySync for T
where T: Any + Sync,

Source§

impl<T> AnySyncClone for T
where T: Any + Sync + Clone,

Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more