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
impl ContractValidator
Sourcepub const INITIALIZATION_PERIOD: Duration
pub const INITIALIZATION_PERIOD: Duration
Initial updating interval for calling ContractValidator::update_contracts().
Sourcepub const UPDATE_PERIOD: Duration = CONTRACTS_FETCHING_INTERVAL
pub const UPDATE_PERIOD: Duration = CONTRACTS_FETCHING_INTERVAL
Remaining updating interval for calling ContractValidator::update_contracts().
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.
Sourcepub fn authenticate(
&self,
client_id: &ClientId,
client_secret: &ClientSecret,
) -> Result<ClientData, AuthenticationError>
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.
Sourcepub fn is_ready(&self) -> bool
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.
Sourcepub async fn update_contracts(&self) -> Result<(), UpdateError>
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§
Source§impl FromContext<ConfigureContext> for ContractValidator
impl FromContext<ConfigureContext> for ContractValidator
type Error = ExtractionError
fn from_context( context: &ConfigureContext, ) -> Result<ContractValidator, <ContractValidator as FromContext<ConfigureContext>>::Error>
fn from_context_always(context: &C) -> Selfwhere
Self: FromContext<C, E, Error = !>,
Auto Trait Implementations§
impl !Freeze for ContractValidator
impl !RefUnwindSafe for ContractValidator
impl !Send for ContractValidator
impl !Sync for ContractValidator
impl !UnwindSafe for ContractValidator
impl Unpin for ContractValidator
impl UnsafeUnpin for ContractValidator
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<C, T> Extract<T> for Cwhere
T: FromContext<C>,
impl<C, T> Extract<T> for Cwhere
T: FromContext<C>,
Source§impl<C, T> FromContextOnce<C, Repeat> for Twhere
T: for<'c> FromContext<C> + 'c,
impl<C, T> FromContextOnce<C, Repeat> for Twhere
T: for<'c> FromContext<C> + 'c,
type Error = <T as FromContext<C>>::Error
type Future<'c> = Ready<Result<T, <T as FromContextOnce<C, Repeat>>::Error>> where C: 'c, T: 'c
fn from_context_once( context: Exclusive<'_, C>, ) -> <T as FromContextOnce<C, Repeat>>::Future<'_>
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> ⓘ
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> ⓘ
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