pub trait RecoveryStrategy<T, E>: Send + Sync{
// Required methods
fn name(&self) -> String;
fn description(&self) -> String;
fn attempt<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
error: &'life1 E,
context: &'life2 RecoveryContext,
op: RecoveryOperation<T, E>,
cancel: &'life3 CancelCheckpoint,
) -> Pin<Box<dyn Future<Output = StrategyOutcome<T, E>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait;
// Provided method
fn on_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 RecoveryContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
}Expand description
Bock spec:
trait RecoveryStrategy[E, T] {
fn name(self) -> String
fn description(self) -> String
fn attempt(self, error: E, context: RecoveryContext)
-> Result[T, E] | Cancelled
fn on_cancel(self, context: RecoveryContext) -> Void = {}
}Required Methods§
Sourcefn description(&self) -> String
fn description(&self) -> String
Human-readable description shown to the provider when selecting.
Sourcefn attempt<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
error: &'life1 E,
context: &'life2 RecoveryContext,
op: RecoveryOperation<T, E>,
cancel: &'life3 CancelCheckpoint,
) -> Pin<Box<dyn Future<Output = StrategyOutcome<T, E>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn attempt<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
error: &'life1 E,
context: &'life2 RecoveryContext,
op: RecoveryOperation<T, E>,
cancel: &'life3 CancelCheckpoint,
) -> Pin<Box<dyn Future<Output = StrategyOutcome<T, E>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Attempt recovery. op is the caller-provided effect operation
that originally failed; strategies invoke it as needed (retries,
single-shot fallbacks, or not at all).
Provided Methods§
Sourcefn on_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 RecoveryContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn on_cancel<'life0, 'life1, 'async_trait>(
&'life0 self,
_context: &'life1 RecoveryContext,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Cleanup hook fired when attempt returns
StrategyOutcome::Cancelled. Default is a no-op.