pub trait Backoff:
Send
+ Sync
+ 'static {
// Required methods
fn next_backoff(&self) -> impl Future<Output = bool> + Send;
fn reset(&self) -> impl Future<Output = ()> + Send;
}
Expand description
A backoff trait where a single mutable reference represents a single backoff session.
Backoffs are expected to implement Clone
and make sure when cloning too reset any state within the backoff,
to ensure that each backoff clone has its own independent state, which starts from a clean slate.
Required Methods§
fn next_backoff(&self) -> impl Future<Output = bool> + Send
fn next_backoff(&self) -> impl Future<Output = bool> + Send
Initiate the next backoff in the sequence. Return false in case no backoff is possible anymore (e.g. max retries).
It is expected that the backoff implementation resets itself prior to returning false.
fn reset(&self) -> impl Future<Output = ()> + Send
fn reset(&self) -> impl Future<Output = ()> + Send
Reset the backoff to its initial state.
Note that Backoff::next_backoff
resets automatically when it returns false,
so this method should only be used when the backoff needs to be reset before it has completed.
Object Safety§
This trait is not object safe.