iroh_quinn

Trait Runtime

Source
pub trait Runtime:
    Send
    + Sync
    + Debug
    + 'static {
    // Required methods
    fn new_timer(&self, i: Instant) -> Pin<Box<dyn AsyncTimer>>;
    fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>);
    fn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>;

    // Provided method
    fn now(&self) -> Instant { ... }
}
Expand description

Abstracts I/O and timer operations for runtime independence

Required Methods§

Source

fn new_timer(&self, i: Instant) -> Pin<Box<dyn AsyncTimer>>

Construct a timer that will expire at i

Source

fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)

Drive future to completion in the background

Source

fn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>

Convert t into the socket type used by this runtime

Provided Methods§

Source

fn now(&self) -> Instant

Look up the current time

Allows simulating the flow of time for testing.

Implementors§