Struct async_atomic::GenericSubscriber

source ·
pub struct GenericSubscriber<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>> = Atomic<T>> { /* private fields */ }

Implementations§

source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> GenericSubscriber<T, D, R>

source

pub fn new(atomic_ref: D) -> Self

Create subscriber for atomic.

If there are multiple subscribers for single atomic then only one of them is notified.

source

pub fn wait<F: FnMut(T) -> bool>(&mut self, pred: F) -> Wait<'_, T, F>

Asynchronously wait for predicate to be true.

source

pub fn wait_and_update<F: FnMut(T) -> Option<T>>( &mut self, map: F ) -> WaitAndUpdate<'_, T, F>

Asynchronously wait until map returned Some(x) and then store x in atomic.

This is an asynchronous version of Atomic::fetch_update.

source§

impl<T: Copy + PartialEq, D: AsRef<R>, R: AsRef<Atomic<T>>> GenericSubscriber<T, D, R>

source

pub fn changed(self) -> Changed<T, D, R>

Convert subscriber into stream that yields when value is changed.

source

pub fn into_stream(self) -> Changed<T, D, R>

Trait Implementations§

source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> AsRef<D> for GenericSubscriber<T, D, R>

source§

fn as_ref(&self) -> &D

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl<T: Copy, D: AsRef<R>, R: AsRef<Atomic<T>>> Deref for GenericSubscriber<T, D, R>

§

type Target = D

The resulting type after dereferencing.
source§

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

Dereferences the value.

Auto Trait Implementations§

§

impl<T, D, R> Freeze for GenericSubscriber<T, D, R>
where D: Freeze,

§

impl<T, D, R> RefUnwindSafe for GenericSubscriber<T, D, R>

§

impl<T, D, R> Send for GenericSubscriber<T, D, R>
where D: Send, T: Send, R: Send,

§

impl<T, D, R> Sync for GenericSubscriber<T, D, R>
where D: Sync, T: Sync, R: Sync,

§

impl<T, D, R> Unpin for GenericSubscriber<T, D, R>
where D: Unpin, T: Unpin, R: Unpin,

§

impl<T, D, R> UnwindSafe for GenericSubscriber<T, D, R>
where D: UnwindSafe, T: UnwindSafe, R: UnwindSafe,

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<T, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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.