Trait udp_connector::Socket
source · pub trait Socket {
fn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr)>;
fn local_addr(&self) -> SocketAddr;
fn send_to(&mut self, buffer: &[u8], target: SocketAddr) -> Result<()>;
}
Expand description
A generic trait over a socket. This is automatically implemented for UdpSocket
but can be implemented for your own connector as well.
Required Methods
sourcefn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr)>
fn recv_from(&mut self, buffer: &mut [u8]) -> Result<(usize, SocketAddr)>
Receive data from any remote, returning the amount of bytes read, and the SocketAddr that the data was received from
sourcefn local_addr(&self) -> SocketAddr
fn local_addr(&self) -> SocketAddr
The local SocketAddr we’re listening on