Trait UdpSocket

Source
pub trait UdpSocket: Sized {
    type Error: Error;

    // Required methods
    fn enable_broadcast<'life0, 'async_trait>(
        &'life0 mut self,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
    fn connect<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        addr: &'life1 SocketAddr,
    ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        buf: &'life1 [u8],
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn send_to<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        buf: &'life1 [u8],
        addr: &'life2 SocketAddr,
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn recv<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        but: &'life1 mut [u8],
    ) -> Pin<Box<dyn Future<Output = Result<usize, Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
    fn recv_from<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        buf: &'life1 mut [u8],
    ) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr), Self::Error>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

A generic contract for an UDP socket. Used to be agnostic of the underlying async framework used.

Required Associated Types§

Required Methods§

Source

fn enable_broadcast<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

When enabled, this socket is allowed to send packets to a broadcast address.

Source

fn connect<'life0, 'life1, 'async_trait>( &'life0 mut self, addr: &'life1 SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Connects the UDP socket setting to default destination for send() and limiting packets that are read via recv from the address specified in addr.

Source

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

Sends data on the socket to the remote address to which it is connected. On success, returns the number of bytes written.

Source

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

Sends data on the socket to the given address. On success, returns the number of bytes written.

Source

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

Receives a single datagram on the socket from the remote address to which it is connected. On success, returns the number of bytes read.

Source

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

Receives a single datagram on the socket. On success, returns the number of bytes read and the origin.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl UdpSocket for UdpSocket

Source§

type Error = Error

Source§

fn enable_broadcast<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn connect<'life0, 'life1, 'async_trait>( &'life0 mut self, addr: &'life1 SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

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

Source§

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

Source§

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

Source§

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

Source§

impl UdpSocket for UdpSocket

Source§

type Error = Error

Source§

fn enable_broadcast<'life0, 'async_trait>( &'life0 mut self, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Source§

fn connect<'life0, 'life1, 'async_trait>( &'life0 mut self, addr: &'life1 SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<(), Self::Error>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Source§

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

Source§

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

Source§

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

Source§

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

Implementors§