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§
Sourcefn send_to(&self, bytes: &[u8], target: SocketAddr) -> Result<usize>
fn send_to(&self, bytes: &[u8], target: SocketAddr) -> Result<usize>
§Errors
Propagates socket or gateway failures.
Sourcefn recv_from(&self, bytes: &mut [u8]) -> Result<(usize, SocketAddr)>
fn recv_from(&self, bytes: &mut [u8]) -> Result<(usize, SocketAddr)>
§Errors
Propagates socket or gateway failures.
Sourcefn local_addr(&self) -> Result<SocketAddr>
fn local_addr(&self) -> Result<SocketAddr>
§Errors
Propagates address inspection failure.
Provided Methods§
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".