pub trait Chooser: DynClone + Debug + Sync + Send {
    // Required methods
    fn choose(
        &self,
        ips: &[IpAddrWithPort],
        opts: ChooseOptions<'_>
    ) -> ChosenResults;
    fn feedback(&self, feedback: ChooserFeedback<'_>);

    // Provided methods
    fn async_choose<'a>(
        &'a self,
        ips: &'a [IpAddrWithPort],
        opts: ChooseOptions<'a>
    ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>> { ... }
    fn async_feedback<'a>(
        &'a self,
        feedback: ChooserFeedback<'a>
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>> { ... }
}
Expand description

选择 IP 地址接口

还提供了对选择结果的反馈接口,用以修正自身选择逻辑,优化选择结果

同时提供阻塞接口和异步接口,异步接口则需要启用 async 功能

Required Methods§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

选择 IP 地址列表

fn feedback(&self, feedback: ChooserFeedback<'_>)

反馈选择的 IP 地址列表的结果

Provided Methods§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

异步选择 IP 地址列表

该方法的异步版本为 Self::async_choose

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

异步反馈选择的 IP 地址列表的结果

Implementations on Foreign Types§

§

impl<T> Chooser for Rc<T>where T: Chooser + ?Sized, Rc<T>: DynClone + Debug + Sync + Send,

§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

§

fn feedback(&self, feedback: ChooserFeedback<'_>)

§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

§

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

§

impl<T> Chooser for Arc<T>where T: Chooser + ?Sized, Arc<T>: DynClone + Debug + Sync + Send,

§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

§

fn feedback(&self, feedback: ChooserFeedback<'_>)

§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

§

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

§

impl<'b, T> Chooser for &'b Twhere T: 'b + Chooser + ?Sized, &'b T: DynClone + Debug + Sync + Send,

§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

§

fn feedback(&self, feedback: ChooserFeedback<'_>)

§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

§

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

§

impl<T> Chooser for Box<T, Global>where T: Chooser + ?Sized, Box<T, Global>: DynClone + Debug + Sync + Send,

§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

§

fn feedback(&self, feedback: ChooserFeedback<'_>)

§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

§

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

§

impl<'b, T> Chooser for &'b mut Twhere T: 'b + Chooser + ?Sized, &'b mut T: DynClone + Debug + Sync + Send,

§

fn choose( &self, ips: &[IpAddrWithPort], opts: ChooseOptions<'_> ) -> ChosenResults

§

fn feedback(&self, feedback: ChooserFeedback<'_>)

§

fn async_choose<'a>( &'a self, ips: &'a [IpAddrWithPort], opts: ChooseOptions<'a> ) -> Pin<Box<dyn Future<Output = ChosenResults> + Send + 'a, Global>>

§

fn async_feedback<'a>( &'a self, feedback: ChooserFeedback<'a> ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a, Global>>

Implementors§

§

impl Chooser for DirectChooser

§

impl Chooser for IpChooser

§

impl Chooser for SubnetChooser

§

impl<C> Chooser for NeverEmptyHandedChooser<C>where C: Chooser + Clone,

§

impl<C> Chooser for ShuffledChooser<C>where C: Chooser + Clone,