Trait AsyncDatagram

Source
pub trait AsyncDatagram {
    type Sender;
    type Receiver;
    type Err;

    // Required methods
    fn poll_send_to(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &[u8],
        receiver: &Self::Receiver,
    ) -> Poll<Result<usize, Self::Err>>;
    fn poll_recv_from(
        self: Pin<&mut Self>,
        cx: &mut Context<'_>,
        buf: &mut [u8],
    ) -> Poll<Result<(usize, Self::Sender), Self::Err>>;
}
Expand description

Implement a datagram protocol.

Required Associated Types§

Source

type Sender

Specifies which target to send the data to.

Source

type Receiver

Specifies which target the data was received from.

Source

type Err

The type of failures yielded by this trait.

Required Methods§

Source

fn poll_send_to( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &[u8], receiver: &Self::Receiver, ) -> Poll<Result<usize, Self::Err>>

Sends data on the IO interface to the specified target.

On success, returns the number of bytes written.

Source

fn poll_recv_from( self: Pin<&mut Self>, cx: &mut Context<'_>, buf: &mut [u8], ) -> Poll<Result<(usize, Self::Sender), Self::Err>>

Receives data from the IO interface.

On success, returns the number of bytes read and the target from whence the data came.

Implementors§