Enum easy_retry::EasyRetry
source · pub enum EasyRetry {
Linear { /* private fields */ },
Exponential { /* private fields */ },
}
Expand description
EasyRetry
is an enum representing different kinds of retry strategies.
Variants§
Implementations§
source§impl EasyRetry
impl EasyRetry
sourcepub fn new_linear(delay: u64, retries: u64) -> Self
pub fn new_linear(delay: u64, retries: u64) -> Self
sourcepub fn new_exponential(delay: u64, retries: u64) -> Self
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);
sourcepub fn run<T>(
&self,
f: T
) -> Result<<T as SyncReturn>::Item, <T as SyncReturn>::Error>where
T: SyncReturn,
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§
Auto Trait Implementations§
impl RefUnwindSafe for EasyRetry
impl Send for EasyRetry
impl Sync for EasyRetry
impl Unpin for EasyRetry
impl UnwindSafe for EasyRetry
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