Trait udp_sas_async::UdpSas
source · pub trait UdpSas: Sized {
// Required methods
fn bind_sas<A: ToSocketAddrs>(addr: A) -> Result<Self>;
fn send_sas(
&self,
buf: &[u8],
target: &SocketAddr,
local: &IpAddr
) -> Result<usize>;
fn recv_sas(&self, buf: &mut [u8]) -> Result<(usize, SocketAddr, IpAddr)>;
}Expand description
An extension trait to support source address selection in std::net::UdpSocket
See module level documentation for more details.
Required Methods§
sourcefn bind_sas<A: ToSocketAddrs>(addr: A) -> Result<Self>
fn bind_sas<A: ToSocketAddrs>(addr: A) -> Result<Self>
Creates a UDP socket from the given address.
The address type can be any implementor of ToSocketAddrs trait. See
its documentation for concrete examples.
The new socket is configured with the IP_PKTINFO or IPV6_RECVPKTINFO option enabled.
Examples
use std::net::UdpSocket;
use udp_sas_async::UdpSas;
let socket = UdpSocket::bind_sas("127.0.0.1:34254").expect("couldn't bind to address");Object Safety§
This trait is not object safe.