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
sourcefn default_wait_timeout(&self) -> Option<Duration>
fn default_wait_timeout(&self) -> Option<Duration>
Default timeout for this action.
This timeout is used in the wait
method.
If `None, wait forever by default.
sourcefn default_delay(&self) -> Duration
fn default_delay(&self) -> Duration
Default delay between two retries.
sourcefn poll(&mut self) -> Result<Option<T>, E>
fn poll(&mut self) -> Result<Option<T>, E>
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.
sourcefn timeout_error(&self) -> E
fn timeout_error(&self) -> E
Error to return on timeout.
Provided Methods
sourcefn wait(self) -> Result<T, E>where
Self: Sized,
fn wait(self) -> Result<T, E>where
Self: Sized,
Wait for the default amount of time.
Consumes the Waiter
.
Returns OperationTimedOut
if the timeout is reached.
sourcefn wait_for(self, duration: Duration) -> Result<T, E>where
Self: Sized,
fn wait_for(self, duration: Duration) -> Result<T, E>where
Self: Sized,
Wait for specified amount of time.
Returns OperationTimedOut
if the timeout is reached.
sourcefn wait_for_with_delay(self, duration: Duration, delay: Duration) -> Result<T, E>where
Self: Sized,
fn wait_for_with_delay(self, duration: Duration, delay: Duration) -> Result<T, E>where
Self: Sized,
Wait for specified amount of time.
sourcefn wait_forever(self) -> Result<T, E>where
Self: Sized,
fn wait_forever(self) -> Result<T, E>where
Self: Sized,
Wait forever.
sourcefn wait_forever_with_delay(self, delay: Duration) -> Result<T, E>where
Self: Sized,
fn wait_forever_with_delay(self, delay: Duration) -> Result<T, E>where
Self: Sized,
Wait forever with given delay between attempts.