pub struct Claims {
pub sub: String,
pub exp: usize,
pub iat: usize,
}
Expand description
The claims of a JWT
Fields§
§sub: String
§exp: usize
§iat: usize
Implementations§
Source§impl Claims
impl Claims
Sourcepub fn new(sub: String) -> Self
pub fn new(sub: String) -> Self
Create a claim with a given subject The expiration time is set to 7 days from the moment of creation
Sourcepub async fn encode(&self, key: &EncodingKey) -> Result<String>
pub async fn encode(&self, key: &EncodingKey) -> Result<String>
Encode the claims into a JWT string
pub async fn decode(token: &str, key: &DecodingKey) -> Result<Self>
pub async fn decode_validation( token: &str, key: &DecodingKey, validation: &Validation, ) -> Result<Self>
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>,
Deserialize this value from the given Serde deserializer. Read more
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
Mutably borrows from an owned value. Read more
Source§impl<S, T> FromRequest<S, ViaParts> for T
impl<S, T> FromRequest<S, ViaParts> for T
Source§type Rejection = <T as FromRequestParts<S>>::Rejection
type Rejection = <T as FromRequestParts<S>>::Rejection
If the extractor fails it’ll use this “rejection” type. A rejection is
a kind of error that can be converted into a response.