pub struct RetryConfig {
pub status_codes: Vec<u16>,
pub max_retries: usize,
pub exponential_base: f64,
pub max_delay: Duration,
pub initial_delay: Duration,
pub on_retry: Option<RetryCallback>,
}Expand description
Configuration for automatic retry behavior.
By default, retries on 429, 5xx statuses and connection/timeout errors with up to 3 attempts using exponential backoff starting at 1 second.
Fields§
§status_codes: Vec<u16>HTTP status codes that trigger a retry.
max_retries: usizeMaximum number of retry attempts (not counting the initial request).
exponential_base: f64Exponential base for backoff (default: 2.0 → 1s, 2s, 4s, …).
max_delay: DurationMaximum delay between retries (default: 60s).
initial_delay: DurationStarting delay before first retry (default: 1s).
on_retry: Option<RetryCallback>Optional callback invoked before each retry with (attempt, error, delay).
Implementations§
Source§impl RetryConfig
impl RetryConfig
Sourcepub fn delay_for_attempt(&self, attempt: usize) -> Duration
pub fn delay_for_attempt(&self, attempt: usize) -> Duration
Compute the delay duration for a given retry attempt number (0-based).
Sourcepub fn should_retry(&self, error: &LimitlessError) -> bool
pub fn should_retry(&self, error: &LimitlessError) -> bool
Returns true if the error is retryable according to this config.
Sourcepub fn with_on_retry<F>(self, callback: F) -> Self
pub fn with_on_retry<F>(self, callback: F) -> Self
Attach a callback that fires before each retry.
Trait Implementations§
Source§impl Clone for RetryConfig
impl Clone for RetryConfig
Source§fn clone(&self) -> RetryConfig
fn clone(&self) -> RetryConfig
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for RetryConfig
impl Debug for RetryConfig
Auto Trait Implementations§
impl Freeze for RetryConfig
impl !RefUnwindSafe for RetryConfig
impl Send for RetryConfig
impl Sync for RetryConfig
impl Unpin for RetryConfig
impl UnsafeUnpin for RetryConfig
impl !UnwindSafe for RetryConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more