pub struct AsyncFactoryContext { /* private fields */ }Expand description
Handle for propagating the async resolution chain into detached tasks.
Obtained from ServiceProvider::async_context inside an async factory
(the call captures the current chain synchronously). Clone it into a spawned
task and resolve through it; self/cross dependency cycles across tasks are
then reported as RdiError::CircularDependency instead of dead-locking.
ⓘ
.async_singleton(|sp| Box::pin(async move {
let ctx = sp.async_context().expect("built provider");
let worker = tokio::spawn({
let ctx = ctx.clone();
async move { ctx.get_async::<Dep>().await }
});
let dep = worker.await.unwrap().unwrap();
Arc::new(Service { dep })
}))Implementations§
Source§impl AsyncFactoryContext
impl AsyncFactoryContext
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for AsyncFactoryContext
impl !UnwindSafe for AsyncFactoryContext
impl Forget for AsyncFactoryContext
impl Freeze for AsyncFactoryContext
impl Move for AsyncFactoryContext
impl Send for AsyncFactoryContext
impl Sync for AsyncFactoryContext
impl Unpin for AsyncFactoryContext
impl UnsafeUnpin for AsyncFactoryContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more