Skip to main content

PunchSocket

Trait PunchSocket 

Source
pub trait PunchSocket: Send + Sync {
    // Required methods
    fn send_to(&self, bytes: &[u8], target: SocketAddr) -> Result<usize>;
    fn recv_from(&self, bytes: &mut [u8]) -> Result<(usize, SocketAddr)>;
    fn local_addr(&self) -> Result<SocketAddr>;
    fn prepare(&self, bound: Option<Duration>) -> Result<()>;

    // Provided method
    fn wake(&self) -> Result<()> { ... }
}
Expand description

Datagram I/O shared by address observation and the direct carrier. A gateway adapter must preserve the actual remote endpoint on receive.

Required Methods§

Source

fn send_to(&self, bytes: &[u8], target: SocketAddr) -> Result<usize>

§Errors

Propagates socket or gateway failures.

Source

fn recv_from(&self, bytes: &mut [u8]) -> Result<(usize, SocketAddr)>

§Errors

Propagates socket or gateway failures.

Source

fn local_addr(&self) -> Result<SocketAddr>

§Errors

Propagates address inspection failure.

Source

fn prepare(&self, bound: Option<Duration>) -> Result<()>

Sets an observation bound, or parks indefinitely on delivery.

§Errors

Refuses connected sockets and propagates socket setup failures.

Provided Methods§

Source

fn wake(&self) -> Result<()>

Interrupts a parked receiver through its owned socket.

§Errors

Propagates address inspection and wake delivery failures.

Dyn Compatibility§

This trait is dyn compatible.

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

Implementations on Foreign Types§

Source§

impl PunchSocket for UdpSocket

Source§

fn send_to(&self, bytes: &[u8], target: SocketAddr) -> Result<usize>

Source§

fn recv_from(&self, bytes: &mut [u8]) -> Result<(usize, SocketAddr)>

Source§

fn local_addr(&self) -> Result<SocketAddr>

Source§

fn prepare(&self, bound: Option<Duration>) -> Result<()>

Implementors§