pub struct BlockingRetryWithContext<B: Backoff, T, E, Ctx, F: FnMut(Ctx) -> (Ctx, Result<T, E>), SF: MaybeBlockingSleeper = DefaultBlockingSleeper, RF = fn(_: &E) -> bool, NF = fn(_: &E, _: Duration)> { /* private fields */ }
Expand description
Retry structure generated by BlockingRetryableWithContext
.
Implementations§
Source§impl<B, T, E, Ctx, F, SF, RF, NF> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
Sourcepub fn context(
self,
context: Ctx,
) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
pub fn context( self, context: Ctx, ) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
Set the context for retrying.
Context is used to capture ownership manually to prevent lifetime issues.
Sourcepub fn sleep<SN: BlockingSleeper>(
self,
sleep_fn: SN,
) -> BlockingRetryWithContext<B, T, E, Ctx, F, SN, RF, NF>
pub fn sleep<SN: BlockingSleeper>( self, sleep_fn: SN, ) -> BlockingRetryWithContext<B, T, E, Ctx, F, SN, RF, NF>
Set the sleeper for retrying.
The sleeper should implement the BlockingSleeper
trait. The simplest way is to use a closure like Fn(Duration)
.
If not specified, we use the DefaultBlockingSleeper
.
Sourcepub fn when<RN: FnMut(&E) -> bool>(
self,
retryable: RN,
) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RN, NF>
pub fn when<RN: FnMut(&E) -> bool>( self, retryable: RN, ) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RN, NF>
Set the conditions for retrying.
If not specified, all errors are considered retryable.
Sourcepub fn notify<NN: FnMut(&E, Duration)>(
self,
notify: NN,
) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NN>
pub fn notify<NN: FnMut(&E, Duration)>( self, notify: NN, ) -> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NN>
Set to notify for all retry attempts.
When a retry happens, the input function will be invoked with the error and the sleep duration before pausing.
If not specified, this operation does nothing.
Source§impl<B, T, E, Ctx, F, SF, RF, NF> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
Auto Trait Implementations§
impl<B, T, E, Ctx, F, SF, RF, NF> Freeze for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> RefUnwindSafe for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>where
B: RefUnwindSafe,
RF: RefUnwindSafe,
NF: RefUnwindSafe,
F: RefUnwindSafe,
SF: RefUnwindSafe,
Ctx: RefUnwindSafe,
impl<B, T, E, Ctx, F, SF, RF, NF> Send for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> Sync for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> Unpin for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
impl<B, T, E, Ctx, F, SF, RF, NF> UnwindSafe for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>where
B: UnwindSafe,
RF: UnwindSafe,
NF: UnwindSafe,
F: UnwindSafe,
SF: UnwindSafe,
Ctx: 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