#[non_exhaustive]pub struct SignedToken<A, T, H = Empty>{
pub signature: <A as Algorithm>::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 as Algorithm>::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§fn clone(&self) -> SignedToken<A, T, H>
fn clone(&self) -> SignedToken<A, T, H>
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl<A, T, H> Debug for SignedToken<A, T, H>
impl<A, T, H> Debug for SignedToken<A, T, H>
Source§impl<A, T, H> Decode for SignedToken<A, T, H>
impl<A, T, H> Decode for SignedToken<A, T, H>
Source§fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<SignedToken<A, T, H>, Error>where
__CodecInputEdqy: Input,
fn decode<__CodecInputEdqy>(
__codec_input_edqy: &mut __CodecInputEdqy,
) -> Result<SignedToken<A, T, H>, Error>where
__CodecInputEdqy: Input,
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, T, H> Deserialize<'de> for SignedToken<A, T, H>where
A: Algorithm + ?Sized,
T: Deserialize<'de>,
H: Deserialize<'de>,
<A as Algorithm>::Signature: Deserialize<'de>,
impl<'de, A, T, H> Deserialize<'de> for SignedToken<A, T, H>where
A: Algorithm + ?Sized,
T: Deserialize<'de>,
H: Deserialize<'de>,
<A as Algorithm>::Signature: Deserialize<'de>,
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<SignedToken<A, T, H>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<SignedToken<A, T, H>, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl<A, T, H> Encode for SignedToken<A, T, H>
impl<A, 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>(
&self,
__codec_dest_edqy: &mut __CodecOutputEdqy,
)
fn encode_to<__CodecOutputEdqy>( &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, T, H> MaxEncodedLen for SignedToken<A, T, H>where
A: Algorithm + ?Sized,
<A as Algorithm>::Signature: MaxEncodedLen,
Token<T, H>: MaxEncodedLen,
impl<A, T, H> MaxEncodedLen for SignedToken<A, T, H>where
A: Algorithm + ?Sized,
<A as Algorithm>::Signature: MaxEncodedLen,
Token<T, H>: MaxEncodedLen,
Source§fn max_encoded_len() -> usize
fn max_encoded_len() -> usize
Upper bound, in bytes, of the maximum encoded size of this item.
Source§impl<A, T, H> Serialize for SignedToken<A, T, H>
impl<A, T, H> Serialize for SignedToken<A, T, H>
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl<A, 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
Source§impl<T> CheckedConversion for T
impl<T> CheckedConversion for 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>
Converts
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>
Converts
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 moreSource§impl<T, Outer> IsWrappedBy<Outer> for T
impl<T, Outer> IsWrappedBy<Outer> for T
Source§impl<T> SaturatedConversion for T
impl<T> SaturatedConversion for T
Source§fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
fn saturated_from<T>(t: T) -> Selfwhere
Self: UniqueSaturatedFrom<T>,
Source§fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
fn saturated_into<T>(self) -> Twhere
Self: UniqueSaturatedInto<T>,
Consume self to return an equivalent value of
T. Read moreSource§impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
impl<T, U> TryIntoKey<U> for Twhere
U: TryFromKey<T>,
type Error = <U as TryFromKey<T>>::Error
fn try_into_key(self) -> Result<U, <U as TryFromKey<T>>::Error>
Source§impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
impl<S, T> UncheckedInto<T> for Swhere
T: UncheckedFrom<S>,
Source§fn unchecked_into(self) -> T
fn unchecked_into(self) -> T
The counterpart to
unchecked_from.Source§impl<T, S> UniqueSaturatedInto<T> for S
impl<T, S> UniqueSaturatedInto<T> for S
Source§fn unique_saturated_into(self) -> T
fn unique_saturated_into(self) -> T
Consume self to return an equivalent value of
T.