pub type LifecycleFuture<'a, T = ()> = Pin<Box<dyn Future<Output = Result<T, ModeActivationError>> + Send + 'a>>;Expand description
Pinned, boxed, send-able future for Mode::on_activate.
The explicit Pin<Box<dyn Future + Send>> desugaring (rather
than async fn in trait) is needed because:
- Object safety.
Modehas an associated type (Mode::Guard) and is not directly object-safe. The dispatcher stores modes asArc<dyn DynMode>via theDynModeadapter; the adapter’son_activate_dynreturns a future whose output is type-erased toBox<dyn Any + Send>. Sendbound. Lifecycle futures may be scheduled across threads (M-async.2 swapspoll_nowfor runtime-spawned.await); the future itself must beSendso the executor can move it between worker threads.- Explicit lifetime. Modes capture their
&selfand theModeContext(owned,Send + 'static); the future’s lifetime is tied to&selfvia'a.
The default type parameter T = () lets marker modes write
LifecycleFuture<'_> without naming the unit type.
Aliased Type§
pub struct LifecycleFuture<'a, T = ()> { /* private fields */ }