async_transport/runtime/
mod.rs1#[cfg(not(feature = "metal-io"))]
2use crate::{Capabilities, RecvMeta, Transmit};
3#[cfg(not(feature = "metal-io"))]
4use std::{
5    fmt::Debug,
6    io::{self, IoSliceMut},
7    net::SocketAddr,
8    task::{Context, Poll},
9};
10
11#[cfg(feature = "runtime-smol")]
12mod smol;
13#[cfg(feature = "runtime-smol")]
14pub use self::smol::UdpSocket;
15
16#[cfg(feature = "runtime-async-std")]
17mod async_std;
18#[cfg(feature = "runtime-async-std")]
19pub use self::async_std::UdpSocket;
20
21#[cfg(feature = "runtime-tokio")]
22mod tokio;
23#[cfg(feature = "runtime-tokio")]
24pub use self::tokio::UdpSocket;
25
26#[cfg(feature = "metal-io")]
27mod metal_io;
28#[cfg(feature = "metal-io")]
29pub use self::metal_io::UdpSocket;
30
31#[cfg(not(feature = "metal-io"))]
32pub trait AsyncUdpSocket: Send + Debug + 'static {
34    fn poll_send(
37        &self,
38        cx: &mut Context<'_>,
39        capabilities: &Capabilities,
40        transmits: &[Transmit],
41    ) -> Poll<Result<usize, io::Error>>;
42
43    fn poll_recv(
45        &self,
46        cx: &mut Context<'_>,
47        bufs: &mut [IoSliceMut<'_>],
48        meta: &mut [RecvMeta],
49    ) -> Poll<io::Result<usize>>;
50
51    fn local_addr(&self) -> io::Result<SocketAddr>;
53
54    fn peer_addr(&self) -> io::Result<SocketAddr>;
56}