embassy-sync

Crates

git

Versions

default

Flavors

embassy_sync::watch

Struct Receiver

Source
pub struct Receiver<'a, M: RawMutex, T: Clone, const N: usize>(/* private fields */);
Expand description

A receiver of a Watch channel.

Implementations§

Source§

impl<'a, M: RawMutex, T: Clone, const N: usize> Receiver<'a, M, T, N>

Source

pub fn as_dyn(self) -> DynReceiver<'a, T>

Converts the Receiver into a DynReceiver.

Methods from Deref<Target = Rcv<'a, T, Watch<M, T, N>>>§

Source

pub async fn get(&mut self) -> T

Returns the current value of the Watch once it is initialized, marking it as seen.

Note: Futures do nothing unless you .await or poll them.

Source

pub fn try_get(&mut self) -> Option<T>

Tries to get the current value of the Watch without waiting, marking it as seen.

Source

pub async fn get_and<F>(&mut self, f: F) -> T
where F: Fn(&T) -> bool,

Returns the value of the Watch if it matches the predicate function f, or waits for it to match, marking it as seen.

Note: Futures do nothing unless you .await or poll them.

Source

pub fn try_get_and<F>(&mut self, f: F) -> Option<T>
where F: Fn(&T) -> bool,

Tries to get the current value of the Watch if it matches the predicate function f without waiting, marking it as seen.

Source

pub async fn changed(&mut self) -> T

Waits for the Watch to change and returns the new value, marking it as seen.

Note: Futures do nothing unless you .await or poll them.

Source

pub fn try_changed(&mut self) -> Option<T>

Tries to get the new value of the watch without waiting, marking it as seen.

Source

pub async fn changed_and<F>(&mut self, f: F) -> T
where F: Fn(&T) -> bool,

Waits for the Watch to change to a value which satisfies the predicate function f and returns the new value, marking it as seen.

Note: Futures do nothing unless you .await or poll them.

Source

pub fn try_changed_and<F>(&mut self, f: F) -> Option<T>
where F: Fn(&T) -> bool,

Tries to get the new value of the watch which satisfies the predicate function f and returns the new value without waiting, marking it as seen.

Source

pub fn contains_value(&self) -> bool

Checks if the Watch contains a value. If this returns true, then awaiting Rcv::get will return immediately.

Trait Implementations§

Source§

impl<'a, M: RawMutex, T: Clone, const N: usize> Deref for Receiver<'a, M, T, N>

Source§

type Target = Rcv<'a, T, Watch<M, T, N>>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl<'a, M: RawMutex, T: Clone, const N: usize> DerefMut for Receiver<'a, M, T, N>

Source§

fn deref_mut(&mut self) -> &mut Self::Target

Mutably dereferences the value.
Source§

impl<'a, M: RawMutex, T: Clone, const N: usize> Into<DynReceiver<'a, T>> for Receiver<'a, M, T, N>

Source§

fn into(self) -> DynReceiver<'a, T>

Converts this type into the (usually inferred) input type.

Auto Trait Implementations§

§

impl<'a, M, T, const N: usize> Freeze for Receiver<'a, M, T, N>

§

impl<'a, M, T, const N: usize> !RefUnwindSafe for Receiver<'a, M, T, N>

§

impl<'a, M, T, const N: usize> Send for Receiver<'a, M, T, N>
where T: Send, M: Sync,

§

impl<'a, M, T, const N: usize> Sync for Receiver<'a, M, T, N>
where T: Sync + Send, M: Sync,

§

impl<'a, M, T, const N: usize> Unpin for Receiver<'a, M, T, N>
where T: Unpin,

§

impl<'a, M, T, const N: usize> !UnwindSafe for Receiver<'a, M, T, N>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.