pub struct RetryPolicy { /* private fields */ }Expand description
Retry policy for transient CLI failures.
Configure max attempts, backoff strategy, and which errors to retry.
§Example
use claude_wrapper::RetryPolicy;
use std::time::Duration;
let policy = RetryPolicy::new()
.max_attempts(3)
.initial_backoff(Duration::from_secs(1))
.exponential()
.retry_on_timeout(true)
.retry_on_exit_codes([1, 2]);Implementations§
Source§impl RetryPolicy
impl RetryPolicy
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new retry policy with default settings (3 attempts, 1s fixed backoff).
Sourcepub fn max_attempts(self, n: u32) -> Self
pub fn max_attempts(self, n: u32) -> Self
Set the maximum number of attempts (including the initial attempt).
A value of 1 means no retries.
Sourcepub fn initial_backoff(self, duration: Duration) -> Self
pub fn initial_backoff(self, duration: Duration) -> Self
Set the initial delay before the first retry.
Sourcepub fn max_backoff(self, duration: Duration) -> Self
pub fn max_backoff(self, duration: Duration) -> Self
Set the maximum delay between retries (caps exponential growth).
Sourcepub fn exponential(self) -> Self
pub fn exponential(self) -> Self
Use exponential backoff (delay doubles each attempt, capped by max_backoff).
Sourcepub fn retry_on_timeout(self, retry: bool) -> Self
pub fn retry_on_timeout(self, retry: bool) -> Self
Retry on timeout errors.
Sourcepub fn retry_on_exit_codes(self, codes: impl IntoIterator<Item = i32>) -> Self
pub fn retry_on_exit_codes(self, codes: impl IntoIterator<Item = i32>) -> Self
Retry on specific non-zero exit codes.
Trait Implementations§
Source§impl Clone for RetryPolicy
impl Clone for RetryPolicy
Source§fn clone(&self) -> RetryPolicy
fn clone(&self) -> RetryPolicy
Returns a duplicate of the value. Read more
1.0.0 · 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 RetryPolicy
impl Debug for RetryPolicy
Auto Trait Implementations§
impl Freeze for RetryPolicy
impl RefUnwindSafe for RetryPolicy
impl Send for RetryPolicy
impl Sync for RetryPolicy
impl Unpin for RetryPolicy
impl UnsafeUnpin for RetryPolicy
impl UnwindSafe for RetryPolicy
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