pub struct SharedCell<T> { /* private fields */ }
Expand description
A wrapper class that facilitates sharing an item across different users, supporting:
- Ability grab a reference-counted reference to the item
- Ability to consume the item, leaving the cell in an unusable state
Implementations§
Sourcepub fn borrow(&self) -> Result<SharedCellRef<T>, EmptyCellError>
pub fn borrow(&self) -> Result<SharedCellRef<T>, EmptyCellError>
Borrow the cell, returning a reference to the item. If the cell is empty, returns an error. While references are held, the cell cannot be taken below.
Sourcepub async fn with_mut<F, R>(&self, f: F) -> Result<R, EmptyCellError>
pub async fn with_mut<F, R>(&self, f: F) -> Result<R, EmptyCellError>
Execute given closure with write access to the underlying data. If the cell is empty, returns an error.
Sourcepub async fn take(&self) -> Result<T, EmptyCellError>
pub async fn take(&self) -> Result<T, EmptyCellError>
Take the item out of the cell, leaving it in an unusable state.
pub fn blocking_take(&self) -> Result<T, EmptyCellError>
pub fn try_take(&self) -> Result<T, TryTakeError>
Trait Implementations§
fn try_discard(&self) -> Result<(), TryTakeError>
fn discard<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<(), EmptyCellError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn blocking_discard(&self) -> Result<(), EmptyCellError>
Auto Trait Implementations§
Blanket Implementations§
§impl<T> AnySync for T
impl<T> AnySync for T
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<A, M> Handler<IndexedErasedUnbound<M>> for A
impl<A, M> Handler<IndexedErasedUnbound<M>> for A
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more