Skip to main content

PingDelegate

Trait PingDelegate 

Source
pub trait PingDelegate:
    Send
    + Sync
    + 'static {
    type Id: Id;
    type Address: CheapClone + Send + Sync + 'static;

    // Required methods
    fn ack_payload(&self) -> impl Future<Output = Bytes> + Send;
    fn notify_ping_complete(
        &self,
        node: Arc<NodeState<Self::Id, Self::Address>>,
        rtt: Duration,
        payload: Bytes,
    ) -> impl Future<Output = ()> + Send;

    // Provided method
    fn disable_reliable_pings(&self, _target: &Self::Id) -> bool { ... }
}
Expand description

Used to notify an observer how long it took for a ping message to complete a round trip. It can also be used for writing arbitrary byte slices into ack messages. Note that in order to be meaningful for RTT estimates, this delegate does not apply to indirect pings, nor fallback pings sent over promised connection.

Required Associated Types§

Source

type Id: Id

The id type of the delegate

Source

type Address: CheapClone + Send + Sync + 'static

The address type of the delegate

Required Methods§

Source

fn ack_payload(&self) -> impl Future<Output = Bytes> + Send

Invoked when an ack is being sent; the returned bytes will be appended to the ack

Source

fn notify_ping_complete( &self, node: Arc<NodeState<Self::Id, Self::Address>>, rtt: Duration, payload: Bytes, ) -> impl Future<Output = ()> + Send

Invoked when an ack for a ping is received

Provided Methods§

Source

fn disable_reliable_pings(&self, _target: &Self::Id) -> bool

Invoked when we want to send a ping message to target by promised connection. Return true if the target node does not expect ping message from promised connection.

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<T: PingDelegate + ?Sized> PingDelegate for Arc<T>
where Arc<T>: Send + Sync + 'static,

Source§

type Id = <T as PingDelegate>::Id

Source§

type Address = <T as PingDelegate>::Address

Source§

fn ack_payload(&self) -> impl Future<Output = Bytes> + Send

Source§

fn notify_ping_complete( &self, node: Arc<NodeState<Self::Id, Self::Address>>, rtt: Duration, payload: Bytes, ) -> impl Future<Output = ()> + Send

Source§

fn disable_reliable_pings(&self, _target: &Self::Id) -> bool

Source§

impl<T: PingDelegate + ?Sized> PingDelegate for Box<T>
where Box<T>: Send + Sync + 'static,

Source§

type Id = <T as PingDelegate>::Id

Source§

type Address = <T as PingDelegate>::Address

Source§

fn ack_payload(&self) -> impl Future<Output = Bytes> + Send

Source§

fn notify_ping_complete( &self, node: Arc<NodeState<Self::Id, Self::Address>>, rtt: Duration, payload: Bytes, ) -> impl Future<Output = ()> + Send

Source§

fn disable_reliable_pings(&self, _target: &Self::Id) -> bool

Implementors§

Source§

impl<I, A> PingDelegate for VoidDelegate<I, A>
where I: Id + Send + Sync + 'static, A: CheapClone + Send + Sync + 'static,

Source§

type Id = I

Source§

type Address = A

Source§

impl<I, Address, A, C, E, M, N, P> PingDelegate for CompositeDelegate<I, Address, A, C, E, M, N, P>
where I: Id + Send + Sync + 'static, Address: CheapClone + Send + Sync + 'static, A: AliveDelegate<Id = I, Address = Address>, C: ConflictDelegate<Id = I, Address = Address>, E: EventDelegate<Id = I, Address = Address>, M: MergeDelegate<Id = I, Address = Address>, N: NodeDelegate, P: PingDelegate<Id = I, Address = Address>,

Source§

type Id = I

Source§

type Address = Address