pub trait AsyncLocalAfterSpawner: Copy + 'static {
    type JoinError: Debug + Display + 'static;
    type JoinHandle<F>: LocalAfterHandle<F, Self::JoinError>
       where F: 'static;

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

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

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

Required Associated Types§

source

type JoinError: Debug + Display + 'static

The join error type for the join handle

source

type JoinHandle<F>: LocalAfterHandle<F, Self::JoinError> where F: 'static

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

Required Methods§

source

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

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

source

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

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

Provided Methods§

source

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

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

source

fn spawn_local_after_at_detach<F>(instant: Instant, future: F)
where F::Output: 'static, F: Future + '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 AsyncLocalAfterSpawner for AsyncStdSpawner

Available on crate feature async-std only.
§

type JoinError = Infallible

§

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

source§

impl AsyncLocalAfterSpawner for SmolSpawner

Available on crate feature smol only.
§

type JoinError = Canceled

§

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

source§

impl AsyncLocalAfterSpawner for TokioSpawner

Available on crate feature tokio only.
§

type JoinError = JoinError

§

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

source§

impl AsyncLocalAfterSpawner for WasmSpawner

Available on crate feature wasm only.
§

type JoinError = Canceled

§

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