AsyncConnection

Trait AsyncConnection 

Source
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§

Source

type Error

The error type that is returned by the connection.

Required Methods§

Source

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.

Source

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.

Source

fn poll_readable(&self, cx: &mut Context<'_>) -> bool

Polls the I/O handle for readability.

Source

fn poll_writable(&self, cx: &mut Context<'_>) -> bool

Polls the I/O handle for writeability.

Source

fn close(self) -> impl Future<Output = Result<(), Self::Error>>

Closes the connection.

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§