Recoverable
Recovery information and classification for resilience patterns.
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 describes whether retrying 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 provide their own recovery information.RecoveryKind: An enum representing the kind of recovery that can be attempted.
Examples
Classifying Errors
use ;
let error = ConnectionTimeout;
assert_eq!;
// Successful operations also use never() since retry is unnecessary
let success_result: = Ok;
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!;