RetryPolicy

Trait RetryPolicy 

Source
pub trait RetryPolicy: Clone {
    // Required method
    fn next_delay(&mut self, attempt: u32) -> Option<Duration>;

    // Provided method
    fn reset(&mut self) { ... }
}
Expand description

Defines a retry policy for async operations.

Implementations determine when and how long to wait between retry attempts.

Required Methods§

Source

fn next_delay(&mut self, attempt: u32) -> Option<Duration>

Returns the delay before the next retry attempt, or None to stop retrying.

§Arguments
  • attempt - The current attempt number (0-indexed)
§Returns
  • Some(Duration) - Wait this duration before retrying
  • None - Stop retrying (max attempts reached or policy exhausted)

Provided Methods§

Source

fn reset(&mut self)

Resets the policy to its initial state.

Default implementation does nothing, suitable for stateless policies.

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§