pub trait Runtime:
Send
+ Sync
+ 'static {
// Required methods
fn spawn_boxed(&self, fut: BoxFuture<'static, ()>) -> Result<(), SpawnError>;
fn connect_tcp_stream(
&self,
addr: &SocketAddr,
) -> BoxFuture<'static, Result<Pin<Box<dyn TcpStream>>>>;
fn bind_tcp_listener(
&self,
addr: &SocketAddr,
) -> Result<Pin<Box<dyn TcpListener>>>;
fn bind_udp_socket(
&self,
addr: &SocketAddr,
) -> Result<Pin<Box<dyn UdpSocket>>>;
fn new_delay(&self, dur: Duration) -> Pin<Box<dyn Delay>>;
fn new_delay_at(&self, at: Instant) -> Pin<Box<dyn Delay>>;
fn new_interval(&self, dur: Duration) -> Pin<Box<dyn Interval>>;
}
Expand description
The runtime trait.
Required Methods§
Sourcefn spawn_boxed(&self, fut: BoxFuture<'static, ()>) -> Result<(), SpawnError>
fn spawn_boxed(&self, fut: BoxFuture<'static, ()>) -> Result<(), SpawnError>
Spawn a new future.
Sourcefn connect_tcp_stream(
&self,
addr: &SocketAddr,
) -> BoxFuture<'static, Result<Pin<Box<dyn TcpStream>>>>
fn connect_tcp_stream( &self, addr: &SocketAddr, ) -> BoxFuture<'static, Result<Pin<Box<dyn TcpStream>>>>
Create a new TcpStream
.
This method is defined on the Runtime
trait because defining it on
TcpStream
would prevent it from being a trait object.
Sourcefn bind_tcp_listener(
&self,
addr: &SocketAddr,
) -> Result<Pin<Box<dyn TcpListener>>>
fn bind_tcp_listener( &self, addr: &SocketAddr, ) -> Result<Pin<Box<dyn TcpListener>>>
Create a new TcpListener
.
This method is defined on the Runtime
trait because defining it on
TcpListener
would prevent it from being a trait object.
Sourcefn bind_udp_socket(&self, addr: &SocketAddr) -> Result<Pin<Box<dyn UdpSocket>>>
fn bind_udp_socket(&self, addr: &SocketAddr) -> Result<Pin<Box<dyn UdpSocket>>>
Create a new UdpSocket
.
This method is defined on the Runtime
trait because defining it on
UdpSocket
would prevent it from being a trait object.
Sourcefn new_delay(&self, dur: Duration) -> Pin<Box<dyn Delay>>
fn new_delay(&self, dur: Duration) -> Pin<Box<dyn Delay>>
Create a new Future that wakes up after the given duration
This method is defined on the Runtime
trait because defining it on
Delay
would prevent it from being a trait object.