pub struct TakeCell<T> { /* private fields */ }Expand description
A thread-safe cell that holds a value which can be taken exactly once.
After taking the value, subsequent attempts to take it will return None.
Implementations§
Source§impl<T> TakeCell<T>where
T: StreamReader,
impl<T> TakeCell<T>where
T: StreamReader,
Sourcepub fn take_if(&self, predicate: impl FnOnce(&T::Info) -> bool) -> Option<T>
pub fn take_if(&self, predicate: impl FnOnce(&T::Info) -> bool) -> Option<T>
Takes the reader out of the cell if its info matches the given predicate.
Use this method to conditionally handle incoming streams based on info fields such as topic or attributes.
This method will only take the reader if the provided predicate returns true when called with the reader’s info.
If the predicate returns false or the reader has already been taken, this method returns None.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for TakeCell<T>
impl<T> !RefUnwindSafe for TakeCell<T>
impl<T> Send for TakeCell<T>
impl<T> Sync for TakeCell<T>
impl<T> Unpin for TakeCell<T>
impl<T> UnsafeUnpin for TakeCell<T>
impl<T> !UnwindSafe for TakeCell<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