pub trait Socket: Debug {
// Required methods
fn new<T: ToSocketAddrs>(_: T, _: usize) -> Result<Self, Error>
where Self: Sized;
fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>;
fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>;
fn local_addr(&self) -> Result<SocketAddr, Error>;
}
Expand description
Trait describing a non-blocking low latency socket.
Required Methods§
Sourcefn new<T: ToSocketAddrs>(_: T, _: usize) -> Result<Self, Error>where
Self: Sized,
fn new<T: ToSocketAddrs>(_: T, _: usize) -> Result<Self, Error>where
Self: Sized,
Method that tries to bind a new socket at the specified address.
Sourcefn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>
fn try_recv(&mut self) -> Result<(SocketAddr, Vec<u8>), TryRecvError>
Method that attempts to return a incoming packet on this socket without blocking.
Sourcefn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>
fn send_to(&mut self, data: &[u8], addr: SocketAddr) -> Result<usize, Error>
Method sending data on the socket to the given address. On success, returns the number of bytes written.
Sourcefn local_addr(&self) -> Result<SocketAddr, Error>
fn local_addr(&self) -> Result<SocketAddr, Error>
Method returning the address of the actual, underlying socket.