pub trait AsyncUdpSocket:
Send
+ Sync
+ Debug {
// Required methods
fn poll_send(
&self,
cx: &mut Context<'_>,
transmit: &Transmit<'_>,
) -> Poll<Result<usize>>;
fn poll_recv(
&self,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> Poll<Result<usize>>;
fn local_addr(&self) -> Result<SocketAddr>;
fn traffic_class(&self) -> Result<u32>;
// Provided methods
fn max_receive_batch(&self) -> usize { ... }
fn unmarked(&self) -> bool { ... }
}Expand description
A UDP socket of a runtime, in the poll form of quinn-udp’s so that batched send and receive
(sendmmsg, recvmmsg, GSO, GRO) fit.
Required Methods§
Sourcefn poll_send(
&self,
cx: &mut Context<'_>,
transmit: &Transmit<'_>,
) -> Poll<Result<usize>>
fn poll_send( &self, cx: &mut Context<'_>, transmit: &Transmit<'_>, ) -> Poll<Result<usize>>
Sends transmit, marked with its traffic_class. Pending when the socket cannot take
it now (the driver then counts it lost, as UDP would).
Sourcefn poll_recv(
&self,
cx: &mut Context<'_>,
bufs: &mut [IoSliceMut<'_>],
meta: &mut [RecvMeta],
) -> Poll<Result<usize>>
fn poll_recv( &self, cx: &mut Context<'_>, bufs: &mut [IoSliceMut<'_>], meta: &mut [RecvMeta], ) -> Poll<Result<usize>>
Receives up to bufs.len() datagrams (at most max_receive_batch),
filling meta alongside; how many.
Sourcefn local_addr(&self) -> Result<SocketAddr>
fn local_addr(&self) -> Result<SocketAddr>
The address it is bound to.
Sourcefn traffic_class(&self) -> Result<u32>
fn traffic_class(&self) -> Result<u32>
The TOS / Traffic Class byte the operating system reports for the socket (getsockopt
of IP_TOS / IPV6_TCLASS): what its next datagram carries.
§Errors
The option is not offered on this platform.
Provided Methods§
Sourcefn max_receive_batch(&self) -> usize
fn max_receive_batch(&self) -> usize
How many buffers one poll_recv can fill. 1 by default.
Sourcefn unmarked(&self) -> bool
fn unmarked(&self) -> bool
Whether the platform refused to mark this socket: its datagrams leave with traffic
class 0 whatever the transmit asks (see crate::sockets::set_traffic_class).
Implementations§
Source§impl<'a> dyn AsyncUdpSocket + 'a
impl<'a> dyn AsyncUdpSocket + 'a
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".