Struct Event

Source
pub struct Event { /* private fields */ }
Expand description

An object that can receive or send notifications.

Implementations§

Source§

impl Event

Source

pub fn new() -> Self

Creates a new event.

Source

pub fn notify(&self, n: usize)

Notify a number of awaiting events that the predicate should be checked.

If less events than requested are currently awaiting, then all awaiting event are notified.

Source

pub fn notify_one(&self)

Notify one awaiting event (if any) that the predicate should be checked.

Source

pub fn notify_all(&self)

Notify all awaiting events that the predicate should be checked.

Source

pub fn wait_until<F, T>(&self, predicate: F) -> WaitUntil<'_, F, T>
where F: FnMut() -> Option<T>,

Returns a future that can be awaited until the provided predicate is satisfied.

Source

pub fn wait_until_or_timeout<F, T, D>( &self, predicate: F, deadline: D, ) -> WaitUntilOrTimeout<'_, F, T, D>
where F: FnMut() -> Option<T>, D: Future<Output = ()>,

Returns a future that can be awaited until the provided predicate is satisfied or until the provided future completes.

The deadline is specified as a Future that is expected to resolves to () after some duration, such as a tokio::time::Sleep future.

Trait Implementations§

Source§

impl Default for Event

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Send for Event

Source§

impl Sync for Event

Auto Trait Implementations§

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

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.