pub trait OnConnect: P2P{
// 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§
Sourcefn on_connect<'life0, 'async_trait>(
&'life0 self,
addr: SocketAddr,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
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§
Sourcefn enable_on_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
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.
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.