Struct tokio_sync::watch::Receiver [−][src]
Receives values from the associated Sender.
Instances are created by the channel function.
Implementations
impl<T> Receiver<T>[src]
pub fn get_ref(&self) -> Ref<'_, T>[src]
Returns a reference to the most recently sent value
Outstanding borrows hold a read lock. This means that long lived borrows could cause the send half to block. It is recommended to keep the borrow as short lived as possible.
Examples
use tokio::sync::watch; let (_, rx) = watch::channel("hello"); assert_eq!(*rx.get_ref(), "hello");
pub async fn recv_ref(&mut self) -> Option<Ref<'_, T>>[src]
Attempts to receive the latest value sent via the channel.
If a new, unobserved, value has been sent, a reference to it is
returned. If no new value has been sent, then Pending is returned and
the current task is notified once a new value is sent.
Only the most recent value is returned. If the receiver is falling behind the sender, intermediate values are dropped.
impl<T: Clone> Receiver<T>[src]
pub async fn recv(&mut self) -> Option<T>[src]
Attempts to clone the latest value sent via the channel.
This is equivalent to calling clone() on the value returned by
recv().
Trait Implementations
impl<T> Clone for Receiver<T>[src]
fn clone(&self) -> Self[src]
pub fn clone_from(&mut self, source: &Self)1.0.0[src]
impl<T: Debug> Debug for Receiver<T>[src]
impl<T> Drop for Receiver<T>[src]
Auto Trait Implementations
impl<T> !RefUnwindSafe for Receiver<T>
impl<T> Send for Receiver<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Sync for Receiver<T> where
T: Send + Sync,
T: Send + Sync,
impl<T> Unpin for Receiver<T>
impl<T> !UnwindSafe for Receiver<T>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized, [src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized, [src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized, [src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T[src]
impl<T> From<T> for T[src]
impl<T, U> Into<U> for T where
U: From<T>, [src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone, [src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T[src]
pub fn clone_into(&self, target: &mut T)[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>, [src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>, [src]
U: TryFrom<T>,