abol_rt/net.rs
1use async_trait::async_trait;
2use std::io::Result;
3use std::net::SocketAddr;
4
5#[async_trait]
6pub trait AsyncUdpSocket: Send + Sync {
7 /// Returns the local address this socket is bound to.
8 fn local_addr(&self) -> Result<SocketAddr>;
9
10 /// Sends data to the given target address.
11 async fn send_to(&self, buf: &[u8], target: SocketAddr) -> Result<usize>;
12
13 /// Receives data from the socket, returning the number of bytes and the source address.
14 async fn recv_from(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr)>;
15}