1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
use crate::{RecvMeta, Transmit, UdpState};
use std::{
fmt::Debug,
io::{self, IoSliceMut},
net::SocketAddr,
task::{Context, Poll},
};
#[cfg(feature = "runtime-async-std")]
mod async_std;
#[cfg(feature = "runtime-async-std")]
pub use self::async_std::UdpSocket;
#[cfg(feature = "runtime-tokio")]
mod tokio;
#[cfg(feature = "runtime-tokio")]
pub use self::tokio::UdpSocket;
pub trait AsyncUdpSocket: Send + Debug + 'static {
fn poll_send(
&self,
cx: &mut Context<'_>,
state: &UdpState,
transmits: &[Transmit],
) -> Poll<Result<usize, io::Error>>;
fn poll_recv(
&self,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> Poll<io::Result<usize>>;
fn local_addr(&self) -> io::Result<SocketAddr>;
}