pub trait AsyncAfterSpawner: Copy + Send + Sync + 'static {
    type JoinError: Debug + Display + Send + 'static;
    type JoinHandle<F>: AfterHandle<F, Self::JoinError>
       where F: Send + 'static;

    // Required methods
    fn spawn_after<F>(
        duration: Duration,
        future: F
    ) -> Self::JoinHandle<F::Output>
       where F::Output: Send + 'static,
             F: Future + Send + 'static;
    fn spawn_after_at<F>(
        instant: Instant,
        future: F
    ) -> Self::JoinHandle<F::Output>
       where F::Output: Send + 'static,
             F: Future + Send + 'static;

    // Provided methods
    fn spawn_after_detach<F>(duration: Duration, future: F)
       where F::Output: Send + 'static,
             F: Future + Send + 'static { ... }
    fn spawn_after_at_detach<F>(instant: Instant, future: F)
       where F::Output: Send + 'static,
             F: Future + Send + 'static { ... }
}
Available on crate feature time only.
Expand description

A spawner trait for spawning futures. Go’s time.AfterFunc equivalent.

Required Associated Types§

source

type JoinError: Debug + Display + Send + 'static

The join error type for the join handle

source

type JoinHandle<F>: AfterHandle<F, Self::JoinError> where F: Send + 'static

The handle returned by the spawner when a future is spawned.

Required Methods§

source

fn spawn_after<F>(duration: Duration, future: F) -> Self::JoinHandle<F::Output>
where F::Output: Send + 'static, F: Future + Send + 'static,

Spawn a future onto the runtime and run the given future after the given duration

source

fn spawn_after_at<F>(instant: Instant, future: F) -> Self::JoinHandle<F::Output>
where F::Output: Send + 'static, F: Future + Send + 'static,

Spawn a future onto the runtime and run the given future after reach the given instant

Provided Methods§

source

fn spawn_after_detach<F>(duration: Duration, future: F)
where F::Output: Send + 'static, F: Future + Send + 'static,

Spawn and detach a future onto the runtime and run the given future after the given duration

source

fn spawn_after_at_detach<F>(instant: Instant, future: F)
where F::Output: Send + 'static, F: Future + Send + 'static,

Spawn and detach a future onto the runtime and run the given future after reach the given instant

Object Safety§

This trait is not object safe.

Implementors§

source§

impl AsyncAfterSpawner for AsyncStdSpawner

Available on crate feature async-std only.
§

type JoinError = Infallible

§

type JoinHandle<F> = AsyncStdAfterHandle<F> where F: Send + 'static

source§

impl AsyncAfterSpawner for SmolSpawner

Available on crate feature smol only.
§

type JoinError = Canceled

§

type JoinHandle<F> = SmolAfterHandle<F> where F: Send + 'static

source§

impl AsyncAfterSpawner for TokioSpawner

Available on crate feature tokio only.
§

type JoinError = JoinError

§

type JoinHandle<F> = TokioAfterHandle<F> where F: Send + 'static

source§

impl AsyncAfterSpawner for WasmSpawner

Available on crate feature wasm only.
§

type JoinError = Canceled

§

type JoinHandle<F> = WasmAfterHandle<F> where F: Send + 'static