Crates.io | async-datagram |
lib.rs | async-datagram |
version | 3.0.0 |
source | src |
created_at | 2019-03-08 00:17:53.657511 |
updated_at | 2019-06-24 09:47:58.827113 |
description | Async datagram traits. |
homepage | |
repository | https://github.com/rustasync/async-datagram |
max_upload_size | |
id | 119398 |
size | 29,419 |
Async datagram traits.
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
}
}
$ cargo add async-datagram
This crate uses #![deny(unsafe_code)]
to ensure everything is implemented in
100% Safe Rust.
Want to join us? Check out our "Contributing" guide and take a look at some of these issues:
None.
MIT OR Apache-2.0