Trait Chooser

Source
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>> { ... }
    fn async_feedback<'a>(
        &'a self,
        feedback: ChooserFeedback<'a>,
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'a>> { ... }
}
Expand description

选择 IP 地址接口

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

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

Required Methods§

Source

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

选择 IP 地址列表

Source

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

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

Provided Methods§

Source

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

异步选择 IP 地址列表

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

Source

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

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

Trait Implementations§

Source§

impl<'clone> Clone for Box<dyn Chooser + 'clone>

Source§

fn clone(&self) -> Box<dyn Chooser + 'clone>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn Chooser + Send + 'clone>

Source§

fn clone(&self) -> Box<dyn Chooser + Send + 'clone>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn Chooser + Sync + Send + 'clone>

Source§

fn clone(&self) -> Box<dyn Chooser + Sync + Send + 'clone>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'clone> Clone for Box<dyn Chooser + Sync + 'clone>

Source§

fn clone(&self) -> Box<dyn Chooser + Sync + 'clone>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Implementations on Foreign Types§

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§