Trait RuntimeProvider

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 Future<Output = Result<Self::Tcp, Error>> + Send>>;
    fn bind_udp(
        &self,
        local_addr: SocketAddr,
        server_addr: SocketAddr,
    ) -> Pin<Box<dyn Future<Output = Result<Self::Udp, Error>> + Send>>;

    // Provided method
    fn quic_binder(&self) -> Option<&dyn QuicSocketBinder> { ... }
}
Expand description

RuntimeProvider defines which async runtime that handles IO and timers.

Required Associated Types§

type Handle: Clone + Send + Spawn + Sync + Unpin

Handle to the executor;

type Timer: Time + Send + Unpin

Timer

type Udp: DnsUdpSocket + Send

UdpSocket

type Tcp: DnsTcpStream

TcpStream

Required Methods§

fn create_handle(&self) -> Self::Handle

Create a runtime handle

fn connect_tcp( &self, server_addr: SocketAddr, bind_addr: Option<SocketAddr>, timeout: Option<Duration>, ) -> Pin<Box<dyn Future<Output = Result<Self::Tcp, Error>> + Send>>

Create a TCP connection with custom configuration.

fn bind_udp( &self, local_addr: SocketAddr, server_addr: SocketAddr, ) -> Pin<Box<dyn Future<Output = Result<Self::Udp, Error>> + Send>>

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§

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.

Implementors§

§

impl RuntimeProvider for TokioRuntimeProvider

§

type Handle = TokioHandle

§

type Timer = TokioTime

§

type Udp = UdpSocket

§

type Tcp = AsyncIoTokioAsStd<TcpStream>