pub struct LazyProvider<T>{ /* private fields */ }Expand description
A provider that lazily initializes a value on first access.
Thread-safe: concurrent calls to get() will only trigger one initialization;
other callers wait for it to complete.
Implementations§
Source§impl<T> LazyProvider<T>
impl<T> LazyProvider<T>
Sourcepub fn new<F, Fut>(factory: F) -> LazyProvider<T>
pub fn new<F, Fut>(factory: F) -> LazyProvider<T>
Create a new lazy provider with the given async factory.
Sourcepub async fn get(&self) -> Result<T, DependencyError>
pub async fn get(&self) -> Result<T, DependencyError>
Get the value, initializing it on first call.
Trait Implementations§
Auto Trait Implementations§
impl<T> !RefUnwindSafe for LazyProvider<T>
impl<T> !UnwindSafe for LazyProvider<T>
impl<T> Forget for LazyProvider<T>
impl<T> Freeze for LazyProvider<T>
impl<T> Move for LazyProvider<T>
impl<T> Send for LazyProvider<T>
impl<T> Sync for LazyProvider<T>
impl<T> Unpin for LazyProvider<T>
impl<T> UnsafeUnpin for LazyProvider<T>where
Arc<OnceCell<T>>: UnsafeUnpin,
Arc<dyn Fn() -> Pin<Box<dyn Future<Output = Result<T, DependencyError>> + Send>> + Send + Sync>: UnsafeUnpin,
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