Trait waiter::Waiter

source ·
pub trait Waiter<T, E> {
    fn default_wait_timeout(&self) -> Option<Duration>;
    fn default_delay(&self) -> Duration;
    fn poll(&mut self) -> Result<Option<T>, E>;
    fn timeout_error(&self) -> E;

    fn wait(self) -> Result<T, E>
    where
        Self: Sized
, { ... } fn wait_for(self, duration: Duration) -> Result<T, E>
    where
        Self: Sized
, { ... } fn wait_for_with_delay(
        self,
        duration: Duration,
        delay: Duration
    ) -> Result<T, E>
    where
        Self: Sized
, { ... } fn wait_forever(self) -> Result<T, E>
    where
        Self: Sized
, { ... } fn wait_forever_with_delay(self, delay: Duration) -> Result<T, E>
    where
        Self: Sized
, { ... } }
Expand description

Trait representing a waiter for some asynchronous action to finish.

The type T is the final type of the action, E is an error.

Required Methods

Default timeout for this action.

This timeout is used in the wait method. If `None, wait forever by default.

Default delay between two retries.

Update the current state of the action.

Returns T if the action is finished, None if it is not. All errors are propagated via the Result.

This method should not be called again after it returned the final result.

Error to return on timeout.

Provided Methods

Wait for the default amount of time.

Consumes the Waiter. Returns OperationTimedOut if the timeout is reached.

Wait for specified amount of time.

Returns OperationTimedOut if the timeout is reached.

Wait for specified amount of time.

Wait forever.

Wait forever with given delay between attempts.

Implementors