[][src]Trait async_coap::datagram::AsyncRecvFrom

pub trait AsyncRecvFrom: DatagramSocketTypes {
    fn poll_recv_from(
        self: Pin<&Self>,
        cx: &mut Context,
        buf: &mut [u8]
    ) -> Poll<Result<(usize, Self::SocketAddr, Option<Self::SocketAddr>), Self::Error>>; fn next_recv_from<'a, 'b>(
        &'a self,
        buf: &'b mut [u8]
    ) -> NextRecvFromFuture<'a, 'b, Self> { ... } }

Trait for providing recv_from functionality for asynchronous, datagram-based sockets.

The value returned on success is a tuple of the following:

(bytes_written: usize,
 remote_socket_addr: SocketAddr,
 local_socket_addr: Option<SocketAddr>)

local_socket_addr indicates the local address that the packet was sent to, and may not be supported. If this isn't supported, local_socket_addr will be set to None.

Required methods

fn poll_recv_from(
    self: Pin<&Self>,
    cx: &mut Context,
    buf: &mut [u8]
) -> Poll<Result<(usize, Self::SocketAddr, Option<Self::SocketAddr>), Self::Error>>

A non-blocking1, poll_* version of std::net::UdpSocket::recv_from that can optionally provide the destination (local) SocketAddr.

If you need to receive a packet from within an async block, see AsyncRecvFrom::next_recv_from, which returns a Future.


  1. Note that while the spirit of this method intends for it to be non-blocking, AllowStdUdpSocket can in fact block execution depending on the state of the underlying std::net::UdpSocket

Loading content...

Provided methods

Important traits for NextRecvFromFuture<'a, 'b, T>
fn next_recv_from<'a, 'b>(
    &'a self,
    buf: &'b mut [u8]
) -> NextRecvFromFuture<'a, 'b, Self>

Returns a future that uses poll_recv_from.

Loading content...

Implementors

impl AsyncRecvFrom for AllowStdUdpSocket[src]

impl AsyncRecvFrom for LoopbackSocket[src]

impl AsyncRecvFrom for NullSocket[src]

Loading content...