Struct async_progress::Progress[][src]

pub struct Progress<State> where
    State: 'static + Clone + Send + Sync + Eq + Debug
{ /* fields omitted */ }
Expand description

A progress tracker.

You can call set_state and it will notify observers of the new state.

To wait for a specific state, you can call wait or once.

Progress is Clone and it’s methods only require a shared reference for convenience.

Implementations

Create a Progress with an initial state.

Set a new state. Observers will be notified.

Check the current state.

Create an event stream that will only fire for the given state. This is a stream and if you call set_state several times with the given state, this will yield several events.

Note that events fired before you call this will not be delivered to the stream. It’s recommended to set up all observers first and then start doing work that can call set_state.

Note that this method uses block_on to lock a mutex on the pharos object, so it might block the thread. All operations on Progress are really short, so this shouldn’t be a problem as long as you haven’t set up an observer by calling Progress::observe with a bounded channel with a low queue size. If the sending of an event (in set_state) returns pending, and this method is called, that will deadlock.

Create a future that will resolve when a certain state is next triggered.

Note that events fired before you call this will not be delivered to the stream. It’s recommended to set up all observers first and then start doing work that can call set_state.

Note that this method uses block_on to lock a mutex on the pharos object, so it might block the thread. All operations on Progress are really short, so this shouldn’t be a problem as long as you haven’t set up an observer by calling Progress::observe with a bounded channel with a low queue size. If the sending of an event (in set_state) returns pending, and this method is called, that will deadlock.

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Avoid configuring pharos with a bounded channel of a low queue size. It is possible to create a deadlock if the send in Progress::set_state returns pending and you call another method on Progress that uses block_on, notably Progress::current.

The error type that is returned if observing is not possible. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.