pub struct Retry<P = AlwaysRetry, B = ExpBackoff> {
predicate: P,
backoff: B,
}
Fields§
§predicate: P
§backoff: B
Implementations§
source§impl<P, B> Retry<P, B>where
B: Backoff,
impl<P, B> Retry<P, B>where
B: Backoff,
pub const fn new(predicate: P, backoff: B) -> Self
sourcepub fn with_predicate<P2>(self, predicate: P2) -> Retry<P2, B>
pub fn with_predicate<P2>(self, predicate: P2) -> Retry<P2, B>
Sets the predicate used to determine if an error is retryable.
If predicate.should_retry()
returns
true
for a given error, the error is retried.
Otherwise, the error is not retried.
sourcepub fn with_backoff<B2: Backoff>(self, backoff: B2) -> Retry<P, B2>
pub fn with_backoff<B2: Backoff>(self, backoff: B2) -> Retry<P, B2>
Sets the backoff policy used to determine how long to back off for between retries.
sourcepub fn with_max_retries(self, max: usize) -> Retry<WithMaxRetries<P>, B>
pub fn with_max_retries(self, max: usize) -> Retry<WithMaxRetries<P>, B>
Sets a maximum retry limit of max
retries. If an operation would be
retried more than max
times, it will fail, regardless of whether the
P
indicates it is retryable.
pub async fn retry<'op, T, E, F>( &mut self, op: impl FnMut() -> F, ) -> Result<T, E>
sourcepub async fn retry_with_input<I, T, E, F>(
&mut self,
input: I,
op: impl FnMut(I) -> F,
) -> Result<T, E>
pub async fn retry_with_input<I, T, E, F>( &mut self, input: I, op: impl FnMut(I) -> F, ) -> Result<T, E>
Retry the asynchronous operation returned by F
.
Trait Implementations§
impl<P: Copy, B: Copy> Copy for Retry<P, B>
impl<P: Eq, B: Eq> Eq for Retry<P, B>
impl<P, B> StructuralPartialEq for Retry<P, B>
Auto Trait Implementations§
impl<P, B> Freeze for Retry<P, B>
impl<P, B> RefUnwindSafe for Retry<P, B>where
P: RefUnwindSafe,
B: RefUnwindSafe,
impl<P, B> Send for Retry<P, B>
impl<P, B> Sync for Retry<P, B>
impl<P, B> Unpin for Retry<P, B>
impl<P, B> UnwindSafe for Retry<P, B>where
P: UnwindSafe,
B: 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
source§impl<T> CheckedAs for T
impl<T> CheckedAs for T
source§fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
fn checked_as<Dst>(self) -> Option<Dst>where
T: CheckedCast<Dst>,
Casts the value.
source§impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
impl<Src, Dst> CheckedCastFrom<Src> for Dstwhere
Src: CheckedCast<Dst>,
source§fn checked_cast_from(src: Src) -> Option<Dst>
fn checked_cast_from(src: Src) -> Option<Dst>
Casts the value.
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> CloneToUninit for Twhere
T: Copy,
impl<T> CloneToUninit for Twhere
T: Copy,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
source§impl<T> OverflowingAs for T
impl<T> OverflowingAs for T
source§fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
fn overflowing_as<Dst>(self) -> (Dst, bool)where
T: OverflowingCast<Dst>,
Casts the value.
source§impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
impl<Src, Dst> OverflowingCastFrom<Src> for Dstwhere
Src: OverflowingCast<Dst>,
source§fn overflowing_cast_from(src: Src) -> (Dst, bool)
fn overflowing_cast_from(src: Src) -> (Dst, bool)
Casts the value.
source§impl<T> SaturatingAs for T
impl<T> SaturatingAs for T
source§fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
fn saturating_as<Dst>(self) -> Dstwhere
T: SaturatingCast<Dst>,
Casts the value.
source§impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
impl<Src, Dst> SaturatingCastFrom<Src> for Dstwhere
Src: SaturatingCast<Dst>,
source§fn saturating_cast_from(src: Src) -> Dst
fn saturating_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> UnwrappedAs for T
impl<T> UnwrappedAs for T
source§fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
fn unwrapped_as<Dst>(self) -> Dstwhere
T: UnwrappedCast<Dst>,
Casts the value.
source§impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
impl<Src, Dst> UnwrappedCastFrom<Src> for Dstwhere
Src: UnwrappedCast<Dst>,
source§fn unwrapped_cast_from(src: Src) -> Dst
fn unwrapped_cast_from(src: Src) -> Dst
Casts the value.
source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
source§impl<T> WrappingAs for T
impl<T> WrappingAs for T
source§fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
fn wrapping_as<Dst>(self) -> Dstwhere
T: WrappingCast<Dst>,
Casts the value.
source§impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
impl<Src, Dst> WrappingCastFrom<Src> for Dstwhere
Src: WrappingCast<Dst>,
source§fn wrapping_cast_from(src: Src) -> Dst
fn wrapping_cast_from(src: Src) -> Dst
Casts the value.