Trait trust_dns_proto::udp::UdpSocket
source · pub trait UdpSocketwhere
Self: Send + Sync + Sized + Unpin,{
type Time: Time;
// Required methods
fn connect<'async_trait>(
addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
fn connect_with_bind<'async_trait>(
addr: SocketAddr,
bind_addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
fn bind<'async_trait>(
addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait;
fn poll_recv_from(
&self,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<(usize, SocketAddr)>>;
fn poll_send_to(
&self,
cx: &mut Context<'_>,
buf: &[u8],
target: SocketAddr
) -> Poll<Result<usize>>;
// Provided methods
fn recv_from<'life0, 'life1, 'async_trait>(
&'life0 self,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr)>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn send_to<'life0, 'life1, 'async_trait>(
&'life0 self,
buf: &'life1 [u8],
target: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<usize>> + Send + 'async_trait>>
where Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}
Expand description
Trait for UdpSocket
Required Associated Types§
Required Methods§
sourcefn connect<'async_trait>(
addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn connect<'async_trait>( addr: SocketAddr ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait,
setups up a “client” udp connection that will only receive packets from the associated address
sourcefn connect_with_bind<'async_trait>(
addr: SocketAddr,
bind_addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn connect_with_bind<'async_trait>( addr: SocketAddr, bind_addr: SocketAddr ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait,
same as connect, but binds to the specified local address for seding address
sourcefn bind<'async_trait>(
addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn bind<'async_trait>( addr: SocketAddr ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait,
a “server” UDP socket, that bind to the local listening address, and unbound remote address (can receive from anything)
sourcefn poll_recv_from(
&self,
cx: &mut Context<'_>,
buf: &mut [u8]
) -> Poll<Result<(usize, SocketAddr)>>
fn poll_recv_from( &self, cx: &mut Context<'_>, buf: &mut [u8] ) -> Poll<Result<(usize, SocketAddr)>>
Poll once Receive data from the socket and returns the number of bytes read and the address from where the data came on success.
sourcefn poll_send_to(
&self,
cx: &mut Context<'_>,
buf: &[u8],
target: SocketAddr
) -> Poll<Result<usize>>
fn poll_send_to( &self, cx: &mut Context<'_>, buf: &[u8], target: SocketAddr ) -> Poll<Result<usize>>
Poll once to send data to the given address.
Provided Methods§
sourcefn recv_from<'life0, 'life1, 'async_trait>(
&'life0 self,
buf: &'life1 mut [u8]
) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr)>> + Send + 'async_trait>>where
Self: Sync + 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn recv_from<'life0, 'life1, 'async_trait>( &'life0 self, buf: &'life1 mut [u8] ) -> Pin<Box<dyn Future<Output = Result<(usize, SocketAddr)>> + Send + 'async_trait>>where Self: Sync + 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,
Receive data from the socket and returns the number of bytes read and the address from where the data came on success.
Implementations on Foreign Types§
source§impl UdpSocket for UdpSocket
impl UdpSocket for UdpSocket
source§fn connect<'async_trait>(
addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn connect<'async_trait>( addr: SocketAddr ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait,
setups up a “client” udp connection that will only receive packets from the associated address
if the addr is ipv4 then it will bind local addr to 0.0.0.0:0, ipv6 [::]0
source§fn connect_with_bind<'async_trait>(
_addr: SocketAddr,
bind_addr: SocketAddr
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
fn connect_with_bind<'async_trait>( _addr: SocketAddr, bind_addr: SocketAddr ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait,
same as connect, but binds to the specified local address for seding address