Struct jwt_compact::SignedToken
source · #[non_exhaustive]pub struct SignedToken<A: Algorithm + ?Sized, T, H = Empty> {
pub signature: A::Signature,
pub token: Token<T, H>,
}
Expand description
Token
together with the validated token signature.
§Examples
#[derive(Serialize, Deserialize)]
struct MyClaims {
// Custom claims in the token...
}
let token_string: String = // token from an external source
let token = UntrustedToken::new(&token_string)?;
let signed = Hs256.validator::<MyClaims>(&key)
.validate_for_signed_token(&token)?;
// `signature` is strongly typed.
let signature: Hs256Signature = signed.signature;
// Token itself is available via `token` field.
let claims = signed.token.claims();
claims.validate_expiration(&TimeOptions::default())?;
// Process the claims...
Fields (Non-exhaustive)§
This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional
Struct { .. }
syntax; cannot be matched against without a wildcard ..
; and struct update syntax will not work.signature: A::Signature
Token signature.
token: Token<T, H>
Verified token.
Trait Implementations§
source§impl<A, T, H> Clone for SignedToken<A, T, H>
impl<A, T, H> Clone for SignedToken<A, T, H>
Auto Trait Implementations§
impl<A, T, H> Freeze for SignedToken<A, T, H>
impl<A, T, H> RefUnwindSafe for SignedToken<A, T, H>
impl<A, T, H> Send for SignedToken<A, T, H>
impl<A, T, H> Sync for SignedToken<A, T, H>
impl<A, T, H> Unpin for SignedToken<A, T, H>
impl<A, T, H> UnwindSafe for SignedToken<A, T, H>
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§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)