pub enum EasyRetry {
    Linear { /* private fields */ },
    Exponential { /* private fields */ },
}
Expand description

EasyRetry is an enum representing different kinds of retry strategies.

Variants§

§

Linear

Represents a linear retry strategy.

§

Exponential

Represents an exponential retry strategy.

Implementations§

source§

impl EasyRetry

source

pub fn new_linear(delay: u64, retries: u64) -> Self

Creates a new EasyRetry::Linear variant with the specified delay and number of retries.

§Arguments
  • delay - The delay between retries in seconds.
  • retries - The number of retries.
§Examples
use easy_retry::EasyRetry;

let retry_strategy = EasyRetry::new_linear(100, 5);
source

pub fn new_exponential(delay: u64, retries: u64) -> Self

Creates a new EasyRetry::Exponential variant with the specified initial delay and number of retries.

§Arguments
  • delay - The delay between retries in . The delay doubles after each retry.
  • retries - The number of retries.
§Examples
use easy_retry::EasyRetry;

let retry_strategy = EasyRetry::new_exponential(100, 5);
source

pub fn run<T>( &self, f: T ) -> Result<<T as SyncReturn>::Item, <T as SyncReturn>::Error>
where T: SyncReturn,

Runs the provided function f with a retry strategy.

This function takes a function f that implements the SyncReturn trait and runs it with a retry strategy. The SyncReturn trait is implemented for FnMut closures, which can mutate their captured variables and can be called multiple times.

The function f should return a Result with the operation’s result or error. The types of the result and error are determined by the SyncReturn trait’s associated types Item and Error.

§Errors

Will return an error if the operation fails after all retries.

Trait Implementations§

source§

impl Clone for EasyRetry

source§

fn clone(&self) -> EasyRetry

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for EasyRetry

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Copy for EasyRetry

Auto Trait Implementations§

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> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

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

§

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>,

§

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.