pub trait Socket {
type Error: Debug;
fn connect<A: ToSocketAddrs>(&mut self, addr: A) -> Result<(), Self::Error>;
fn send(&self, msg: &[u8]) -> Result<(), Self::Error>;
fn recv(
&self,
buffer: &mut [u8]
) -> Result<(usize, SocketAddr), Self::Error>;
fn poll(
&self
) -> Result<Option<(ArrayVec<[u8; 1152]>, SocketAddr)>, Self::Error> { ... }
}
Expand description
A CoAP network socket
This mirrors the Udp socket traits in embedded-nal, but allows us to implement them for foreign types (like std::net::UdpSocket
).
One notable difference is that connect
ing is expected to modify the internal state of a Socket
,
not yield a connected socket type (like std::net::UdpSocket::connect
).
Associated Types
Required methods
Connect as a client to some remote host