[][src]Crate async_datagram

Async datagram traits.

Example

use async_datagram::AsyncDatagram;
use std::task::{Context, Poll};
use std::pin::Pin;

struct Udp;

impl AsyncDatagram for Udp {
  type Sender = std::net::SocketAddr;
  type Receiver = std::net::SocketAddr;
  type Err = std::io::Error;

  fn poll_send_to(
    self: Pin<&mut Self>,
    cx: &mut Context<'_>,
    buf: &[u8],
    target: &Self::Receiver,
  ) -> Poll<Result<usize, Self::Err>> {
    Poll::Ready(Ok(0))
  }

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

Traits

AsyncDatagram

Implement a datagram protocol.