Recoverable
Recovery information and classification for resilience patterns.
Why
This crate provides types for classifying conditions based on their recoverability state, enabling consistent recovery behavior across different error types and resilience middleware.
Recovery Information
The recovery information describes whether recovering from an operation might help, not whether
the operation succeeded or failed. Both successful operations and permanent failures
should use RecoveryInfo::never since recovery is not necessary or desirable.
Core Types
RecoveryInfo: Classifies conditions as recoverable (transient) or non-recoverable (permanent/successful).Recovery: A trait for types that can determine their recoverability.RecoveryKind: An enum representing the kind of recovery that can be attempted.
Examples
Recovery Error
use ;
let error = ConnectionTimeout;
assert_eq!;
// For successful operations, also use never() since retry is unnecessary
let success_result: = Ok;
// If we had a wrapper type for success, it would also return RecoveryInfo::never()
Retry Delay
You can specify when to retry an operation using the delay method:
use Duration;
use ;
// Retry with a 30-second delay (e.g., from a Retry-After header)
let recovery = retry.delay;
assert_eq!;
assert_eq!;
// Immediate retry
let immediate = retry.delay;
assert_eq!;