Policy

Trait Policy 

Source
pub trait Policy: Sized {
    type CacheItem;
    type Ordering: Iterator<Item = usize>;

    // Required methods
    fn refresh_cache<'life0, 'life1, 'async_trait, Resolver>(
        &'life0 self,
        client: &'life1 SrvClient<Resolver, Self>,
    ) -> Pin<Box<dyn Future<Output = Result<Cache<Self::CacheItem>, Error<Resolver::Error>>> + Send + 'async_trait>>
       where Resolver: 'async_trait + SrvResolver,
             Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn order(&self, items: &[Self::CacheItem]) -> Self::Ordering;
    fn cache_item_to_uri(item: &Self::CacheItem) -> &Uri;

    // Provided methods
    fn note_success(&self, uri: &Uri) { ... }
    fn note_failure(&self, uri: &Uri) { ... }
}
Expand description

Policy for SrvClient to use when selecting SRV targets to recommend.

Required Associated Types§

Source

type CacheItem

Type of item stored in a client’s cache.

Source

type Ordering: Iterator<Item = usize>

Iterator of indices used to order cache items.

Required Methods§

Source

fn refresh_cache<'life0, 'life1, 'async_trait, Resolver>( &'life0 self, client: &'life1 SrvClient<Resolver, Self>, ) -> Pin<Box<dyn Future<Output = Result<Cache<Self::CacheItem>, Error<Resolver::Error>>> + Send + 'async_trait>>
where Resolver: 'async_trait + SrvResolver, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Obtains a refreshed cache for a client.

Source

fn order(&self, items: &[Self::CacheItem]) -> Self::Ordering

Creates an iterator of indices corresponding to cache items in the order a SrvClient should try using them to perform an operation.

Source

fn cache_item_to_uri(item: &Self::CacheItem) -> &Uri

Converts a reference to a cached item into a reference to a Uri.

Provided Methods§

Source

fn note_success(&self, uri: &Uri)

Makes any policy adjustments following a successful execution on uri.

Source

fn note_failure(&self, uri: &Uri)

Makes any policy adjustments following a failed execution on uri.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§