pub trait ProxyDB:
Send
+ Sync
+ 'static {
type Error: Send + 'static;
// Required method
fn get_proxies_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
limit: Option<NonZeroUsize>,
) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_;
// Provided methods
fn get_proxies(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
limit: Option<NonZeroUsize>,
) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_ { ... }
fn get_proxy_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_ { ... }
fn get_proxy(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_ { ... }
}Expand description
The trait to implement to provide a proxy database to other facilities,
such as connection pools, to provide proxy candidates based on the given
ProxyContext and ProxyFilter.
Required Associated Types§
Required Methods§
Sourcefn get_proxies_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
limit: Option<NonZeroUsize>,
) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
Return matching Proxy values in database-defined preference order,
after applying an additional predicate and optional result limit.
Provided Methods§
Sourcefn get_proxies(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
limit: Option<NonZeroUsize>,
) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
Return matching Proxy values in database-defined preference order,
up to the optional result limit.
Sourcefn get_proxy_if(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
predicate: impl ProxyQueryPredicate,
) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
Return one matching proxy after applying an additional predicate.
Implementations may override this to provide a more efficient random selection path. By default the first plural result is returned.
Sourcefn get_proxy(
&self,
ctx: ProxyContext,
filter: ProxyFilter,
) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
Get a Proxy based on the given ProxyContext and ProxyFilter,
or return an error in case no Proxy could be returned.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".
Implementations on Foreign Types§
Source§impl ProxyDB for ()
impl ProxyDB for ()
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, _ctx: ProxyContext, _filter: ProxyFilter, _predicate: impl ProxyQueryPredicate, _limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, _ctx: ProxyContext, _filter: ProxyFilter, _predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, _ctx: ProxyContext, _filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D, E, F, G, H, I> ProxyDB for Either9<A, B, C, D, E, F, G, H, I>where
A: ProxyDB<Error: Into<BoxError>>,
B: ProxyDB<Error: Into<BoxError>>,
C: ProxyDB<Error: Into<BoxError>>,
D: ProxyDB<Error: Into<BoxError>>,
E: ProxyDB<Error: Into<BoxError>>,
F: ProxyDB<Error: Into<BoxError>>,
G: ProxyDB<Error: Into<BoxError>>,
H: ProxyDB<Error: Into<BoxError>>,
I: ProxyDB<Error: Into<BoxError>>,
impl<A, B, C, D, E, F, G, H, I> ProxyDB for Either9<A, B, C, D, E, F, G, H, I>where
A: ProxyDB<Error: Into<BoxError>>,
B: ProxyDB<Error: Into<BoxError>>,
C: ProxyDB<Error: Into<BoxError>>,
D: ProxyDB<Error: Into<BoxError>>,
E: ProxyDB<Error: Into<BoxError>>,
F: ProxyDB<Error: Into<BoxError>>,
G: ProxyDB<Error: Into<BoxError>>,
H: ProxyDB<Error: Into<BoxError>>,
I: ProxyDB<Error: Into<BoxError>>,
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D, E, F, G, H> ProxyDB for Either8<A, B, C, D, E, F, G, H>
impl<A, B, C, D, E, F, G, H> ProxyDB for Either8<A, B, C, D, E, F, G, H>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D, E, F, G> ProxyDB for Either7<A, B, C, D, E, F, G>
impl<A, B, C, D, E, F, G> ProxyDB for Either7<A, B, C, D, E, F, G>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D, E, F> ProxyDB for Either6<A, B, C, D, E, F>
impl<A, B, C, D, E, F> ProxyDB for Either6<A, B, C, D, E, F>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D, E> ProxyDB for Either5<A, B, C, D, E>
impl<A, B, C, D, E> ProxyDB for Either5<A, B, C, D, E>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C, D> ProxyDB for Either4<A, B, C, D>
impl<A, B, C, D> ProxyDB for Either4<A, B, C, D>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B, C> ProxyDB for Either3<A, B, C>
impl<A, B, C> ProxyDB for Either3<A, B, C>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<A, B> ProxyDB for Either<A, B>
impl<A, B> ProxyDB for Either<A, B>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Source§impl<T> ProxyDB for Arc<T>where
T: ProxyDB,
impl<T> ProxyDB for Arc<T>where
T: ProxyDB,
type Error = <T as ProxyDB>::Error
fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> impl Future<Output = Result<NonEmptyVec<Proxy>, Self::Error>> + Send + '_
fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> impl Future<Output = Result<Proxy, Self::Error>> + Send + '_
Source§impl<T> ProxyDB for Option<T>
impl<T> ProxyDB for Option<T>
type Error = Box<dyn Error + Sync + Send>
async fn get_proxies_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxies( &self, ctx: ProxyContext, filter: ProxyFilter, limit: Option<NonZeroUsize>, ) -> Result<NonEmptyVec<Proxy>, Self::Error>
async fn get_proxy_if( &self, ctx: ProxyContext, filter: ProxyFilter, predicate: impl ProxyQueryPredicate, ) -> Result<Proxy, Self::Error>
async fn get_proxy( &self, ctx: ProxyContext, filter: ProxyFilter, ) -> Result<Proxy, Self::Error>
Implementors§
Source§impl ProxyDB for MemoryProxyDB
Available on crate feature memory-db only.
impl ProxyDB for MemoryProxyDB
memory-db only.