Validate

Trait Validate 

Source
pub trait Validate {
    type Claims;

    // Required method
    fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>;

    // Provided methods
    fn and_then<V>(self, other: V) -> impl Validate<Claims = Self::Claims>
       where Self: Sized,
             V: Validate<Claims = Self::Claims> { ... }
    fn map<T>(
        self,
        f: impl for<'a> Fn(&'a T) -> &'a Self::Claims,
    ) -> impl Validate<Claims = T>
       where Self: Sized { ... }
}
Expand description

Validation rules for the claims in a PASETO

Required Associated Types§

Source

type Claims

The type of claim that can be validated

Required Methods§

Source

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

The validation to perform on the claims

Provided Methods§

Source

fn and_then<V>(self, other: V) -> impl Validate<Claims = Self::Claims>
where Self: Sized, V: Validate<Claims = Self::Claims>,

Extend the validation with another validation.

Source

fn map<T>( self, f: impl for<'a> Fn(&'a T) -> &'a Self::Claims, ) -> impl Validate<Claims = T>
where Self: Sized,

Convert this validator into a validator of another type

Implementations on Foreign Types§

Source§

impl<T: Validate + ?Sized> Validate for Box<T>

Source§

type Claims = <T as Validate>::Claims

Source§

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

Source§

impl<T: Validate + ?Sized> Validate for Rc<T>

Source§

type Claims = <T as Validate>::Claims

Source§

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

Source§

impl<T: Validate + ?Sized> Validate for Arc<T>

Source§

type Claims = <T as Validate>::Claims

Source§

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

Source§

impl<T: Validate> Validate for [T]

Source§

type Claims = <T as Validate>::Claims

Source§

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

Source§

impl<T: Validate> Validate for Vec<T>

Source§

type Claims = <T as Validate>::Claims

Source§

fn validate(&self, claims: &Self::Claims) -> Result<(), PasetoError>

Implementors§

Source§

impl<Claims> Validate for NoValidation<Claims>

Source§

type Claims = Claims