Skip to main content

UdpTransport

Trait UdpTransport 

Source
pub trait UdpTransport {
    type Addr: RemoteAddr;

    // Required methods
    fn try_recv(
        &mut self,
        buf: &mut [u8],
    ) -> Result<Option<(usize, Self::Addr)>>;
    fn send_to(&mut self, buf: &[u8], addr: &Self::Addr) -> Result<usize>;
}
Expand description

A non-blocking UDP transport that a SoeMultiplexer can be driven over.

Implementations should not block: try_recv returns Ok(None) when no datagram is immediately available.

Required Associated Types§

Source

type Addr: RemoteAddr

The address type identifying remote peers.

Required Methods§

Source

fn try_recv(&mut self, buf: &mut [u8]) -> Result<Option<(usize, Self::Addr)>>

Attempts to receive a single datagram without blocking. Returns Ok(None) if none is available, or Ok(Some((len, from))) on success.

Source

fn send_to(&mut self, buf: &[u8], addr: &Self::Addr) -> Result<usize>

Sends buf to addr, returning the number of bytes sent.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl UdpTransport for UdpSocket

Source§

type Addr = SocketAddr

Source§

fn try_recv(&mut self, buf: &mut [u8]) -> Result<Option<(usize, Self::Addr)>>

Source§

fn send_to(&mut self, buf: &[u8], addr: &Self::Addr) -> Result<usize>

Implementors§