Trait AsyncUdpSocket

Source
pub trait AsyncUdpSocket<P: ConnectionPeer>: Send + Sync {
    // Required methods
    fn send_to<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        buf: &'life1 [u8],
        peer: &'life2 Peer<P>,
    ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn recv_from<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        buf: &'life1 mut [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(usize, Peer<P>)>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

An abstract representation of an asynchronous UDP socket.

Required Methods§

Source

fn send_to<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, buf: &'life1 [u8], peer: &'life2 Peer<P>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Attempts to send data on the socket to a given peer. Note that this should return nearly immediately, rather than awaiting something internally.

Source

fn recv_from<'life0, 'life1, 'async_trait>( &'life0 mut self, buf: &'life1 mut [u8], ) -> Pin<Box<dyn Future<Output = Result<(usize, Peer<P>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Attempts to receive a single datagram on the socket.

Implementations on Foreign Types§

Source§

impl AsyncUdpSocket<SocketAddr> for UdpSocket

Source§

fn send_to<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, buf: &'life1 [u8], peer: &'life2 Peer<SocketAddr>, ) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Source§

fn recv_from<'life0, 'life1, 'async_trait>( &'life0 mut self, buf: &'life1 mut [u8], ) -> Pin<Box<dyn Future<Output = Result<(usize, Peer<SocketAddr>)>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Implementors§

Source§

impl<Link: LinkDecider + Sync + Send> AsyncUdpSocket<char> for MockUdpSocket<Link>