Skip to main content

ContractValidator

Struct ContractValidator 

Source
pub struct ContractValidator { /* private fields */ }
Expand description

The object that will collect the contracts and provide the functionality to validate incoming requests.

Implementations§

Source§

impl ContractValidator

Source

pub const INITIALIZATION_PERIOD: Duration

Initial updating interval for calling ContractValidator::update_contracts().

Source

pub const UPDATE_PERIOD: Duration = CONTRACTS_FETCHING_INTERVAL

Remaining updating interval for calling ContractValidator::update_contracts().

Source

pub fn authorize( &self, client_id: &ClientId, ) -> Result<ClientData, AuthorizationError>

Validates if client_id credential can be authorized in the current API contract. If the validation is succesful, this method returns the ClientData of client_id. Otherwise an AuthorizationError is returned.

Source

pub fn authenticate( &self, client_id: &ClientId, client_secret: &ClientSecret, ) -> Result<ClientData, AuthenticationError>

Validates if client_id and client_secret credentials can be authenticated in the current API contract. If the validation is succesful, this method returns the ClientData of client_id. Otherwise an AuthenticationError is returned.

Source

pub fn is_ready(&self) -> bool

Returns true if contracts have been pulled and are available locally. This method can be used to determine if the ContractValidator is ready for authorization and authentication operations.

Source

pub async fn update_contracts(&self) -> Result<(), UpdateError>

Updates local contracts database. This method is intended to be called periodically in order to keep the local contracts database up to date. During initialization time, this method should be invoked in a period of ContractValidator::INITIALIZATION_PERIOD. After initialization, this method should be invoked in a period of ContractValidator::UPDATE_PERIOD.

Trait Implementations§

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<C, T> Extract<T> for C
where T: FromContext<C>,

Source§

type Error = <T as FromContext<C>>::Error

Source§

fn extract(&self) -> Result<T, <C as Extract<T>>::Error>

Source§

fn extract_always(&self) -> T
where Self: Extract<T, Error = Infallible>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<C, T> FromContextOnce<C, Repeat> for T
where T: for<'c> FromContext<C> + 'c,

Source§

type Error = <T as FromContext<C>>::Error

Source§

type Future<'c> = Ready<Result<T, <T as FromContextOnce<C, Repeat>>::Error>> where C: 'c, T: 'c

Source§

fn from_context_once( context: Exclusive<'_, C>, ) -> <T as FromContextOnce<C, Repeat>>::Future<'_>

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.