1use crate::client::{AsVerify, ProviderClient};
2use futures::future::BoxFuture;
3use thiserror::Error;
4
5#[derive(Debug, Error)]
6pub enum VerifyError {
7 #[error("invalid authentication")]
8 InvalidAuthentication,
9 #[error("provider error: {0}")]
10 ProviderError(String),
11 #[error("http error: {0}")]
12 HttpError(
13 #[from]
14 #[source]
15 reqwest::Error,
16 ),
17}
18
19pub trait VerifyClient: ProviderClient + Clone {
22 fn verify(&self) -> impl Future<Output = Result<(), VerifyError>> + Send;
24}
25
26pub trait VerifyClientDyn: ProviderClient {
27 fn verify(&self) -> BoxFuture<'_, Result<(), VerifyError>>;
29}
30
31impl<T> VerifyClientDyn for T
32where
33 T: VerifyClient,
34{
35 fn verify(&self) -> BoxFuture<'_, Result<(), VerifyError>> {
36 Box::pin(self.verify())
37 }
38}
39
40impl<T> AsVerify for T
41where
42 T: VerifyClientDyn + Clone + 'static,
43{
44 fn as_verify(&self) -> Option<Box<dyn VerifyClientDyn>> {
45 Some(Box::new(self.clone()))
46 }
47}