use no_std_net::SocketAddr;
pub trait UdpClientStack {
type UdpSocket;
type Error: core::fmt::Debug;
fn socket(&mut self) -> Result<Self::UdpSocket, Self::Error>;
fn connect(
&mut self,
socket: &mut Self::UdpSocket,
remote: SocketAddr,
) -> Result<(), Self::Error>;
fn send(&mut self, socket: &mut Self::UdpSocket, buffer: &[u8]) -> nb::Result<(), Self::Error>;
fn receive(
&mut self,
socket: &mut Self::UdpSocket,
buffer: &mut [u8],
) -> nb::Result<(usize, SocketAddr), Self::Error>;
fn close(&mut self, socket: Self::UdpSocket) -> Result<(), Self::Error>;
}
pub trait UdpFullStack: UdpClientStack {
fn bind(&mut self, socket: &mut Self::UdpSocket, local_port: u16) -> Result<(), Self::Error>;
fn send_to(
&mut self,
socket: &mut Self::UdpSocket,
remote: SocketAddr,
buffer: &[u8],
) -> nb::Result<(), Self::Error>;
}