pub struct Receiver<T> { /* private fields */ }Expand description
Consumer side. Each receiver tracks its own seen-version, so two receivers can be at different positions in the value stream and neither blocks the other.
Implementations§
Source§impl<T> Receiver<T>
impl<T> Receiver<T>
Sourcepub async fn changed(&mut self) -> Result<(), RecvError>
pub async fn changed(&mut self) -> Result<(), RecvError>
Park until the current value differs from this receiver’s
last-seen version. Returns Err(RecvError) if the sender has
been dropped and no further value can ever arrive. Does NOT
update the seen-version — call borrow_and_update after to
acknowledge.
Sourcepub fn has_changed(&self) -> Result<bool, RecvError>
pub fn has_changed(&self) -> Result<bool, RecvError>
Non-blocking check: has a new value arrived since the last
borrow_and_update?
Sourcepub fn borrow(&self) -> Ref<'_, T>
pub fn borrow(&self) -> Ref<'_, T>
Read-only borrow of the current value without updating
seen-state. A follow-up changed() call will still return
Ok(()) if the version changed before this borrow.
Sourcepub fn borrow_and_update(&mut self) -> Ref<'_, T>
pub fn borrow_and_update(&mut self) -> Ref<'_, T>
Read the current value and mark it as seen so the next
changed() call only resolves on a subsequent send.
Trait Implementations§
Auto Trait Implementations§
impl<T> Freeze for Receiver<T>
impl<T> RefUnwindSafe for Receiver<T>where
Arc<Inner<T>>: RefUnwindSafe,
impl<T> Send for Receiver<T>
impl<T> Sync for Receiver<T>
impl<T> Unpin for Receiver<T>
impl<T> UnsafeUnpin for Receiver<T>where
Arc<Inner<T>>: UnsafeUnpin,
impl<T> UnwindSafe for Receiver<T>where
Arc<Inner<T>>: UnwindSafe,
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