pub struct AsyncOnceCell<T> { /* private fields */ }
Expand description
This structure contains a cell for a single value. The cell can be written only once, and can be read many times. Readers are provided with async API, that waits for write to happen. This is similar to tokio::sync::watch, except one difference:
- tokio::sync::watch requires existing receiver to work. If no subscriber is registered, and the value is sent to channel, the value is dropped
- Unlike with tokio::sync::watch, it is possible to write to AsyncOnceCell when no readers are registered, and value will be available later when AsyncOnceCell::get is called
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T> !Freeze for AsyncOnceCell<T>
impl<T> !RefUnwindSafe for AsyncOnceCell<T>
impl<T> Send for AsyncOnceCell<T>
impl<T> Sync for AsyncOnceCell<T>
impl<T> Unpin for AsyncOnceCell<T>where
T: Unpin,
impl<T> !UnwindSafe for AsyncOnceCell<T>
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