backon

Struct BlockingRetryWithContext

Source
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>
where B: Backoff, F: FnMut(Ctx) -> (Ctx, Result<T, E>), SF: MaybeBlockingSleeper, RF: FnMut(&E) -> bool, NF: FnMut(&E, Duration),

Source

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.

Source

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.

Source

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.

Source

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>
where B: Backoff, F: FnMut(Ctx) -> (Ctx, Result<T, E>), SF: BlockingSleeper, RF: FnMut(&E) -> bool, NF: FnMut(&E, Duration),

Source

pub fn call(self) -> (Ctx, Result<T, E>)

Call the retried function.

TODO: implement FnOnce after it stable.

Auto Trait Implementations§

§

impl<B, T, E, Ctx, F, SF, RF, NF> Freeze for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
where B: Freeze, RF: Freeze, NF: Freeze, F: Freeze, SF: Freeze, Ctx: Freeze,

§

impl<B, T, E, Ctx, F, SF, RF, NF> RefUnwindSafe for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>

§

impl<B, T, E, Ctx, F, SF, RF, NF> Send for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
where RF: Send, NF: Send, F: Send, SF: Send, Ctx: Send,

§

impl<B, T, E, Ctx, F, SF, RF, NF> Sync for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
where RF: Sync, NF: Sync, F: Sync, SF: Sync, Ctx: Sync,

§

impl<B, T, E, Ctx, F, SF, RF, NF> Unpin for BlockingRetryWithContext<B, T, E, Ctx, F, SF, RF, NF>
where RF: Unpin, NF: Unpin, F: Unpin, SF: Unpin, Ctx: Unpin,

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.