pub trait Transport:
PollSendToVectored
+ Send
+ Sync
+ Unpin
+ 'static {
// Required methods
fn recv_from<'a>(
&'a self,
buf: &'a mut [u8],
) -> impl Future<Output = Result<(usize, SocketAddr)>> + Send + Sync + 'a;
fn send_to<'a>(
&'a self,
buf: &'a [u8],
target: SocketAddr,
) -> impl Future<Output = Result<usize>> + Send + Sync + 'a;
fn poll_send_to(
&self,
cx: &mut Context<'_>,
buf: &[u8],
target: SocketAddr,
) -> Poll<Result<usize>>;
fn bind_addr(&self) -> SocketAddr;
}Expand description
An abstraction for underlying transport. UDP is default, but can be swapped to a custom transport.
Tests use mock transport.
Required Methods§
fn recv_from<'a>( &'a self, buf: &'a mut [u8], ) -> impl Future<Output = Result<(usize, SocketAddr)>> + Send + Sync + 'a
fn send_to<'a>( &'a self, buf: &'a [u8], target: SocketAddr, ) -> impl Future<Output = Result<usize>> + Send + Sync + 'a
fn poll_send_to( &self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr, ) -> Poll<Result<usize>>
fn bind_addr(&self) -> SocketAddr
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.