Skip to main content

Runtime

Trait Runtime 

Source
pub trait Runtime<'a> {
    // Required methods
    fn push_boxed(&mut self, future: BoxFuture<'static, ()>);
    fn spawn_boxed(
        &'a mut self,
        future: BoxFuture<'static, ()>,
    ) -> SpawnedFuture<'a> ;
    fn sleep<'b>(&'a self, duration: Duration) -> BoxFuture<'b, ()>;
    fn stop(&mut self) -> Stop ;

    // Provided methods
    fn push(&mut self, future: impl Future<Output = ()> + 'static) { ... }
    fn spawn(
        &'a mut self,
        future: impl Future<Output = ()> + 'static,
    ) -> SpawnedFuture<'a>  { ... }
    fn sleep_ms<'b>(&'a self, amount: u64) -> BoxFuture<'b, ()> { ... }
}
Expand description

Auto-trait with the methods that will actually be called by the users of the runtime.

Required Methods§

Source

fn push_boxed(&mut self, future: BoxFuture<'static, ()>)

Adds a new future to the queue to be completed.

Source

fn spawn_boxed( &'a mut self, future: BoxFuture<'static, ()>, ) -> SpawnedFuture<'a>

Adds a new future to the queue to be completed and returns a future waiting for the added future’s completion.

Source

fn sleep<'b>(&'a self, duration: Duration) -> BoxFuture<'b, ()>

Asynchronously sleeps

Source

fn stop(&mut self) -> Stop

Stops the runtime. This does not exit the process.

Provided Methods§

Source

fn push(&mut self, future: impl Future<Output = ()> + 'static)

Adds a new future to the queue to be completed.

Source

fn spawn( &'a mut self, future: impl Future<Output = ()> + 'static, ) -> SpawnedFuture<'a>

Adds a new future to the queue to be completed and returns a future waiting for the added future’s completion.

Source

fn sleep_ms<'b>(&'a self, amount: u64) -> BoxFuture<'b, ()>

Asynchronously sleeps some amount of milliseconds

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§

Source§

impl<'a> Runtime<'a> for RuntimeWrapper<'a>

Source§

impl<'a, T: InternalRuntime + Sized> Runtime<'a> for T