pub trait AsyncConnection {
type Error;
// Required methods
fn read<'fut>(
&'fut mut self,
buf: &'fut mut [u8],
) -> impl Future<Output = Result<usize, Self::Error>> + 'fut;
fn write<'fut>(
&'fut mut self,
buf: &'fut [u8],
) -> impl Future<Output = Result<usize, Self::Error>> + 'fut;
fn poll_readable(&self, cx: &mut Context<'_>) -> bool;
fn poll_writable(&self, cx: &mut Context<'_>) -> bool;
fn close(self) -> impl Future<Output = Result<(), Self::Error>>;
}Expand description
Asynchronous connection that provides the basic API for sending and receiving data.
Required Associated Types§
Required Methods§
Sourcefn read<'fut>(
&'fut mut self,
buf: &'fut mut [u8],
) -> impl Future<Output = Result<usize, Self::Error>> + 'fut
fn read<'fut>( &'fut mut self, buf: &'fut mut [u8], ) -> impl Future<Output = Result<usize, Self::Error>> + 'fut
Receives a single datagram message on the socket. On success, returns the number of bytes read.
Sourcefn write<'fut>(
&'fut mut self,
buf: &'fut [u8],
) -> impl Future<Output = Result<usize, Self::Error>> + 'fut
fn write<'fut>( &'fut mut self, buf: &'fut [u8], ) -> impl Future<Output = Result<usize, Self::Error>> + 'fut
Sends data on the socket. On success, returns the number of bytes written.
Sourcefn poll_readable(&self, cx: &mut Context<'_>) -> bool
fn poll_readable(&self, cx: &mut Context<'_>) -> bool
Polls the I/O handle for readability.
Sourcefn poll_writable(&self, cx: &mut Context<'_>) -> bool
fn poll_writable(&self, cx: &mut Context<'_>) -> bool
Polls the I/O handle for writeability.
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.