Trait tryhard::OnRetry

source ·
pub trait OnRetry<E> {
    type Future: Future<Output = ()> + Send + 'static;

    // Required method
    fn on_retry(
        &mut self,
        attempt: u32,
        next_delay: Option<Duration>,
        previous_error: &E
    ) -> Self::Future;
}
Expand description

Trait allowing you to run some future when a retry occurs. Could for example to be used for logging or other kinds of telemetry.

You wont have to implement this trait manually. It is implemented for functions with the right signature. See RetryFuture::on_retry for more details.

Required Associated Types§

source

type Future: Future<Output = ()> + Send + 'static

The type of the future you want to run.

Required Methods§

source

fn on_retry( &mut self, attempt: u32, next_delay: Option<Duration>, previous_error: &E ) -> Self::Future

Create another future to run.

If next_delay is None then your future is out of retries and wont be called again.

Implementors§

source§

impl<E> OnRetry<E> for NoOnRetry

§

type Future = Ready<()>

source§

impl<F, E, FutureT> OnRetry<E> for Fwhere F: Fn(u32, Option<Duration>, &E) -> FutureT, FutureT: Future<Output = ()> + Send + 'static, FutureT::Output: Send + 'static,

§

type Future = FutureT