pub trait Connection: Send + Sync {
type Message;
type Error;
// Required methods
fn peer_endpoint(&self) -> Result<Endpoint, Self::Error>;
fn local_endpoint(&self) -> Result<Endpoint, Self::Error>;
fn recv<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<Self::Message, Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn send<'life0, 'async_trait>(
&'life0 self,
msg: Self::Message,
) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}
Expand description
Connection is a generic network connection interface for
[udp::UdpConn
], [tcp::TcpConn
], [tls::TlsConn
], [ws::WsConn
],
and [unix::UnixConn
].
If you are familiar with the Go language, this is similar to the Conn interface
Required Associated Types§
Required Methods§
Sourcefn peer_endpoint(&self) -> Result<Endpoint, Self::Error>
fn peer_endpoint(&self) -> Result<Endpoint, Self::Error>
Returns the remote peer endpoint of this connection
Sourcefn local_endpoint(&self) -> Result<Endpoint, Self::Error>
fn local_endpoint(&self) -> Result<Endpoint, Self::Error>
Returns the local socket endpoint of this connection