5 stable releases

3.0.0 Jun 24, 2019
2.2.0 Apr 15, 2019
2.1.0 Apr 15, 2019
2.0.0 Mar 8, 2019
1.0.0 Mar 8, 2019

#20 in #datagram

Download history 174/week @ 2024-07-21 221/week @ 2024-07-28 192/week @ 2024-08-04 258/week @ 2024-08-11 135/week @ 2024-08-18 204/week @ 2024-08-25 197/week @ 2024-09-01 215/week @ 2024-09-08 145/week @ 2024-09-15 193/week @ 2024-09-22 149/week @ 2024-09-29 95/week @ 2024-10-06 159/week @ 2024-10-13 162/week @ 2024-10-20 153/week @ 2024-10-27 198/week @ 2024-11-03

677 downloads per month
Used in 11 crates (3 directly)

MIT/Apache

12KB
65 lines

async-datagram

crates.io version build status downloads docs.rs docs

Async datagram traits.

Examples

Basic usage

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
  }
}

Installation

$ cargo add async-datagram

Safety

This crate uses #![deny(unsafe_code)] to ensure everything is implemented in 100% Safe Rust.

Contributing

Want to join us? Check out our "Contributing" guide and take a look at some of these issues:

References

None.

License

MIT OR Apache-2.0

No runtime deps