Disconnect

Trait Disconnect 

Source
pub trait Disconnect: P2P
where Self: Clone + Send + Sync + 'static,
{ // Required method fn handle_disconnect<'life0, 'async_trait>( &'life0 self, peer_addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait; // Provided method fn enable_disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where Self: Sync + 'async_trait, 'life0: 'async_trait { ... } }
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§

Source

fn handle_disconnect<'life0, 'async_trait>( &'life0 self, peer_addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

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§

Source

fn enable_disconnect<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: Sync + 'async_trait, 'life0: 'async_trait,

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

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§