pub struct RetryResult<T, E> {
pub result: Result<T, ComposableError<E>>,
pub attempts: u32,
pub total_wait_time: Duration,
}Expand description
Result of a retry operation with metadata about attempts.
This struct provides detailed information about a retry operation, including the final result and statistics about the retry process.
§Type Parameters
T- The success type of the operationE- The error type of the operation
§Example
ⓘ
use error_rail::async_ext::{retry_with_metadata, ExponentialBackoff, RetryResult};
let retry_result: RetryResult<Data, ApiError> = retry_with_metadata(
|| fetch_data(),
ExponentialBackoff::default(),
|d| tokio::time::sleep(d),
).await;
if retry_result.attempts > 1 {
log::warn!(
"Operation succeeded after {} attempts (waited {:?})",
retry_result.attempts,
retry_result.total_wait_time
);
}Fields§
§result: Result<T, ComposableError<E>>The final result of the operation.
Contains Ok(T) if the operation eventually succeeded, or
Err(ComposableError<E>) if all retry attempts were exhausted
or a permanent error occurred.
attempts: u32Total number of attempts made.
This is always at least 1 (the initial attempt). A value greater than 1 indicates that retries occurred.
total_wait_time: DurationTotal time spent waiting between retries.
This does not include the time spent executing the operation itself,
only the delays between retry attempts. A value of Duration::ZERO
indicates either immediate success or immediate permanent failure.
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl<T, E> Freeze for RetryResult<T, E>
impl<T, E> RefUnwindSafe for RetryResult<T, E>where
T: RefUnwindSafe,
E: RefUnwindSafe,
impl<T, E> Send for RetryResult<T, E>
impl<T, E> Sync for RetryResult<T, E>
impl<T, E> Unpin for RetryResult<T, E>
impl<T, E> UnwindSafe for RetryResult<T, E>where
T: UnwindSafe,
E: UnwindSafe,
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