Trait agnostic_lite::AsyncAfterSpawner
source · 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§
sourcetype JoinHandle<F>: AfterHandle<F, Self::JoinError>
where
F: Send + 'static
type JoinHandle<F>: AfterHandle<F, Self::JoinError> where F: Send + 'static
The handle returned by the spawner when a future is spawned.
Required Methods§
sourcefn spawn_after<F>(duration: Duration, future: F) -> Self::JoinHandle<F::Output>
fn spawn_after<F>(duration: Duration, future: F) -> Self::JoinHandle<F::Output>
Spawn a future onto the runtime and run the given future after the given duration
sourcefn spawn_after_at<F>(instant: Instant, future: F) -> Self::JoinHandle<F::Output>
fn spawn_after_at<F>(instant: Instant, future: F) -> Self::JoinHandle<F::Output>
Spawn a future onto the runtime and run the given future after reach the given instant
Provided Methods§
sourcefn spawn_after_detach<F>(duration: Duration, future: F)
fn spawn_after_detach<F>(duration: Duration, future: F)
Spawn and detach a future onto the runtime and run the given future after the given duration
Object Safety§
This trait is not object safe.
Implementors§
source§impl AsyncAfterSpawner for AsyncStdSpawner
Available on crate feature async-std only.
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.
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.
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.
impl AsyncAfterSpawner for WasmSpawner
Available on crate feature
wasm only.