Trait pea2pea::protocols::Disconnect[][src]

pub trait Disconnect: Pea2Pea where
    Self: Clone + Send + Sync + 'static, 
{ fn handle_disconnect<'life0, 'async_trait>(
        &'life0 self,
        addr: SocketAddr
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
; fn enable_disconnect(&self) { ... } }
Expand description

Can be used to automatically perform some extra actions when the node disconnects from its peer, which is especially practical if the disconnect is triggered automatically, e.g. due to the peer exceeding the allowed number of failures or severing its connection with the node on its own.

Required methods

Any extra actions to be executed during a disconnect; in order to still be able to communicate with the peer in the usual manner (i.e. via Writing), only its SocketAddr (as opposed to the related Connection object) is provided as an argument.

Provided methods

Attaches the behavior specified in Disconnect::handle_disconnect to every occurrence of the node disconnecting from a peer.

Implementors