pub trait OnConnect: P2Pwhere
    Self: Clone + Send + Sync + 'static,{
    // Required method
    fn on_connect<'life0, 'async_trait>(
        &'life0 self,
        addr: SocketAddr
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;

    // Provided method
    fn enable_on_connect<'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 initial actions once the connection with a peer is fully established.

Required Methods§

source

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

Any initial actions to be executed after the handshake is concluded; in order to 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_on_connect<'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 OnConnect::on_connect right after every successful handshake.

Implementors§