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 { ... }
}展开描述
对 I/O 与定时器操作的抽象,用于运行时无关性
必需方法§
源代码fn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>
fn wrap_udp_socket(&self, t: UdpSocket) -> Result<Arc<dyn AsyncUdpSocket>>
将 t 转换为本运行时所使用的套接字类型