pub struct Claim<T, V = ()> { /* private fields */ }
Implementations§
source§impl<T, V> Claim<T, V>where
V: Validator<T>,
impl<T, V> Claim<T, V>where
V: Validator<T>,
pub const fn new(claim: &'static str) -> Self
sourcepub fn insert<I>(
&self,
claims: &mut HashMap<String, Value>,
value: I,
) -> Result<(), ClaimError>
pub fn insert<I>( &self, claims: &mut HashMap<String, Value>, value: I, ) -> Result<(), ClaimError>
Insert a claim into the given claims map.
§Errors
Returns an error if the value failed to serialize.
sourcepub fn extract_required(
&self,
claims: &mut HashMap<String, Value>,
) -> Result<T, ClaimError>
pub fn extract_required( &self, claims: &mut HashMap<String, Value>, ) -> Result<T, ClaimError>
Extract a claim from the given claims map.
§Errors
Returns an error if the value failed to deserialize, if its value is invalid or if the claim is missing.
sourcepub fn extract_required_with_options<I>(
&self,
claims: &mut HashMap<String, Value>,
validator: I,
) -> Result<T, ClaimError>
pub fn extract_required_with_options<I>( &self, claims: &mut HashMap<String, Value>, validator: I, ) -> Result<T, ClaimError>
Extract a claim from the given claims map, with the given options.
§Errors
Returns an error if the value failed to deserialize, if its value is invalid or if the claim is missing.
sourcepub fn extract_optional(
&self,
claims: &mut HashMap<String, Value>,
) -> Result<Option<T>, ClaimError>
pub fn extract_optional( &self, claims: &mut HashMap<String, Value>, ) -> Result<Option<T>, ClaimError>
Extract a claim from the given claims map, if it exists.
§Errors
Returns an error if the value failed to deserialize or if its value is invalid.
sourcepub fn extract_optional_with_options<I>(
&self,
claims: &mut HashMap<String, Value>,
validator: I,
) -> Result<Option<T>, ClaimError>
pub fn extract_optional_with_options<I>( &self, claims: &mut HashMap<String, Value>, validator: I, ) -> Result<Option<T>, ClaimError>
Extract a claim from the given claims map, if it exists, with the given options.
§Errors
Returns an error if the value failed to deserialize or if its value is invalid.
Auto Trait Implementations§
impl<T, V> Freeze for Claim<T, V>
impl<T, V> RefUnwindSafe for Claim<T, V>where
T: RefUnwindSafe,
V: RefUnwindSafe,
impl<T, V> Send for Claim<T, V>
impl<T, V> Sync for Claim<T, V>
impl<T, V> Unpin for Claim<T, V>
impl<T, V> UnwindSafe for Claim<T, V>where
T: UnwindSafe,
V: UnwindSafe,
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> 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 more