#[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::SignatureToken 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>
Source§impl<A, T, H> Debug for SignedToken<A, T, H>
impl<A, T, H> Debug for SignedToken<A, T, H>
Source§impl<A: Algorithm + ?Sized, T, H> Decode for SignedToken<A, T, H>
impl<A: Algorithm + ?Sized, T, H> Decode for SignedToken<A, T, H>
Source§fn decode<__CodecInputEdqy: Input>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<Self, Error>
fn decode<__CodecInputEdqy: Input>( __codec_input_edqy: &mut __CodecInputEdqy, ) -> Result<Self, Error>
Attempt to deserialise the value from input.
Source§fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
fn decode_into<I>(
input: &mut I,
dst: &mut MaybeUninit<Self>,
) -> Result<DecodeFinished, Error>where
I: Input,
Attempt to deserialize the value from input into a pre-allocated piece of memory. Read more
Source§impl<'de, A: Algorithm + ?Sized, T, H> Deserialize<'de> for SignedToken<A, T, H>
impl<'de, A: Algorithm + ?Sized, T, H> Deserialize<'de> for SignedToken<A, T, H>
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
Source§impl<A: Algorithm + ?Sized, T, H> Encode for SignedToken<A, T, H>
impl<A: Algorithm + ?Sized, T, H> Encode for SignedToken<A, T, H>
Source§fn size_hint(&self) -> usize
fn size_hint(&self) -> usize
If possible give a hint of expected size of the encoding. Read more
Source§fn encode_to<__CodecOutputEdqy: Output + ?Sized>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy: Output + ?Sized>( &self, __codec_dest_edqy: &mut __CodecOutputEdqy, )
Convert self to a slice and append it to the destination.
Source§fn using_encoded<R, F>(&self, f: F) -> R
fn using_encoded<R, F>(&self, f: F) -> R
Convert self to a slice and then invoke the given closure with it.
Source§fn encoded_size(&self) -> usize
fn encoded_size(&self) -> usize
Calculates the encoded size. Read more
Source§impl<A: Algorithm + ?Sized, T, H> MaxEncodedLen for SignedToken<A, T, H>
impl<A: Algorithm + ?Sized, T, H> MaxEncodedLen for SignedToken<A, T, H>
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
impl<A: Algorithm + ?Sized, T, H> EncodeLike 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