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§
Sourcefn new_timer(&self, i: Instant) -> Pin<Box<dyn AsyncTimer>>
fn new_timer(&self, i: Instant) -> Pin<Box<dyn AsyncTimer>>
Construct a timer that will expire at i
Sourcefn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)
fn spawn(&self, future: Pin<Box<dyn Future<Output = ()> + Send>>)
Drive future
to completion in the background
Sourcefn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>
fn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>
Convert t
into the socket type used by this runtime