pub struct Resolver<'a> { /* private fields */ }Expand description
Resolves dependencies while a service is being constructed.
Each construction gets its own frame linked to the frame that requested it, so the chain of services under construction lives on the stack.
Use it only on the constructing thread. Construction of cached instances is serialised per container and per scope, so handing a resolver to another thread and waiting for it deadlocks.
Implementations§
Source§impl<'a> Resolver<'a>
impl<'a> Resolver<'a>
Sourcepub fn resolve<T: ?Sized + Send + Sync + 'static>(
&self,
) -> Result<Arc<T>, ResolveError>
pub fn resolve<T: ?Sized + Send + Sync + 'static>( &self, ) -> Result<Arc<T>, ResolveError>
Resolves a dependency of the service under construction.
When T is registered more than once, the last registration wins; use
resolve_all for every one.
Sourcepub fn resolve_all<T: ?Sized + Send + Sync + 'static>(
&self,
) -> Result<Vec<Arc<T>>, ResolveError>
pub fn resolve_all<T: ?Sized + Send + Sync + 'static>( &self, ) -> Result<Vec<Arc<T>>, ResolveError>
Resolves every registration of T, in registration order. The first
failure fails the whole call; nothing is cached for the failed member.
Sourcepub fn construction_error(&self, source: impl Into<BoxError>) -> ResolveError
pub fn construction_error(&self, source: impl Into<BoxError>) -> ResolveError
Wraps a constructor failure with the current dependency path.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Resolver<'a>
impl<'a> !UnwindSafe for Resolver<'a>
impl<'a> Freeze for Resolver<'a>
impl<'a> Send for Resolver<'a>
impl<'a> Sync for Resolver<'a>
impl<'a> Unpin for Resolver<'a>
impl<'a> UnsafeUnpin for Resolver<'a>
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