fuchsia_bluetooth::expectation::asynchronous

Trait ExpectableState

Source
pub trait ExpectableState: Clone {
    type State: 'static;

    // Required methods
    fn store_task(&mut self, cx: &mut Context<'_>) -> usize;
    fn remove_task(&mut self, key: usize);
    fn notify_state_changed(&self);
    fn read(&self) -> Self::State;
}
Expand description

Trait for objects that allow futures to trigger based on state changes

This trait will commonly be used via the ExpectableStateExt extension trait which provides the convenient when_satisfied function.

You can implement this trait for your own types which implement their own state tracking and notification of futures, or you can use the ExpectationHarness struct in this module which provides a ready to use implementation.

Required Associated Types§

Source

type State: 'static

Type of current state we are tracking

Required Methods§

Source

fn store_task(&mut self, cx: &mut Context<'_>) -> usize

Register a task as needing waking when state changes

Source

fn remove_task(&mut self, key: usize)

Remove a task from being tracked. Called by ExpectationFuture when polled.

Source

fn notify_state_changed(&self)

Notify all pending tasks that state has changed

Source

fn read(&self) -> Self::State

Read a snapshot of the current State

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§

Source§

impl<S: Clone + 'static, A> ExpectableState for Expectable<S, A>

Source§

type State = S