pub trait RuntimeProvider:
Clone
+ Send
+ Sync
+ Unpin
+ 'static {
type Handle: Clone + Send + Spawn + Sync + Unpin;
type Timer: Time + Send + Unpin;
type Udp: DnsUdpSocket + Send;
type Tcp: DnsTcpStream;
// Required methods
fn create_handle(&self) -> Self::Handle;
fn connect_tcp(
&self,
server_addr: SocketAddr,
bind_addr: Option<SocketAddr>,
timeout: Option<Duration>,
) -> Pin<Box<dyn Send + Future<Output = Result<Self::Tcp>>>>;
fn bind_udp(
&self,
local_addr: SocketAddr,
server_addr: SocketAddr,
) -> Pin<Box<dyn Send + Future<Output = Result<Self::Udp>>>>;
// Provided method
fn quic_binder(&self) -> Option<&dyn QuicSocketBinder> { ... }
}
Expand description
RuntimeProvider defines which async runtime that handles IO and timers.
Required Associated Types§
Sourcetype Udp: DnsUdpSocket + Send
type Udp: DnsUdpSocket + Send
UdpSocket
Sourcetype Tcp: DnsTcpStream
type Tcp: DnsTcpStream
TcpStream
Required Methods§
Sourcefn create_handle(&self) -> Self::Handle
fn create_handle(&self) -> Self::Handle
Create a runtime handle
Sourcefn connect_tcp(
&self,
server_addr: SocketAddr,
bind_addr: Option<SocketAddr>,
timeout: Option<Duration>,
) -> Pin<Box<dyn Send + Future<Output = Result<Self::Tcp>>>>
fn connect_tcp( &self, server_addr: SocketAddr, bind_addr: Option<SocketAddr>, timeout: Option<Duration>, ) -> Pin<Box<dyn Send + Future<Output = Result<Self::Tcp>>>>
Create a TCP connection with custom configuration.
Sourcefn bind_udp(
&self,
local_addr: SocketAddr,
server_addr: SocketAddr,
) -> Pin<Box<dyn Send + Future<Output = Result<Self::Udp>>>>
fn bind_udp( &self, local_addr: SocketAddr, server_addr: SocketAddr, ) -> Pin<Box<dyn Send + Future<Output = Result<Self::Udp>>>>
Create a UDP socket bound to local_addr
. The returned value should not be connected to server_addr
.
Notice: the future should be ready once returned at best effort. Otherwise UDP DNS may need much more retries.
Provided Methods§
Sourcefn quic_binder(&self) -> Option<&dyn QuicSocketBinder>
fn quic_binder(&self) -> Option<&dyn QuicSocketBinder>
Yields an object that knows how to bind a QUIC socket.
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.