pub async fn retry_if<T, C>(
        &self,
        task: T,
        condition: C,
    ) -> Result<T::Item, T::Error>
    where
        T: Task,
        C: Condition<T::Error>,
    {
        let mut backoffs = self.backoffs();
        let mut task = task;
        let mut condition = condition;
        loop {
            match task.call().await {
                Ok(result) => return Ok(result),
                Err(err) => {
                    if condition.is_retryable(&err) {
                        if let Some(delay) = backoffs.next() {
                            #[cfg(feature = "log")]
                            {
                                log::trace!(
                                    "task failed with error {:?}. will try again in {:?}",
                                    err,
                                    delay
                                );
                            }
                            let _ = Delay::new(delay).await;
                            continue;
                        }
                    }
                    return Err(err);
                }
            }
        }
    }
/// Retries a fallible `Future` with this policy's configuration under certain provided conditions
Retries a fallible `Future` with this policy's configuration under certain provided conditions
Retries a fallible ` Future ` with this policy ' s configuration under certain provided conditions
pub async fn retry_if<T, C>(
        &self,
        task: T,
        condition: C,
    ) -> Result<T::Item, T::Error>
    where
        T: Task,
        C: Condition<T::Error>,
    {
        let mut backoffs = self.backoffs();
        let mut task = task;
        let mut condition = condition;
        loop {
            match task.call().await {
                Ok(result) => return Ok(result),
                Err(err) => {
                    if condition.is_retryable(&err) {
                        if let Some(delay) = backoffs.next() {
                            #[cfg(feature = "log")]
                            {
                                log::trace!(
                                    "task failed with error {:?}. will try again in {:?}",
                                    err,
                                    delay
                                );
                            }
                            let _ = Delay::new(delay).await;
                            continue;
                        }
                    }
                    return Err(err);
                }
            }
        }
    }
pub async fn retry_if < T , C > ( & self , task : T , condition : C , ) -> Result < T :: Item , T :: Error > where T : Task , C : Condition < T :: Error > , { let mut backoffs = self . backoffs ( ) ; let mut task = task ; let mut condition = condition ; loop { match task . call ( ) . await { Ok ( result ) => return Ok ( result ) , Err ( err ) => { if condition . is_retryable ( & err ) { if let Some ( delay ) = backoffs . next ( ) { # [ cfg ( feature " " ) ] { log :: trace ! ( " " err delay ) ; } let _ = Delay :: new ( delay ) . await ; continue ; } } return Err ( err ) ; } } } }
Retries a fallible `Future` with this policy's configuration under certain provided conditions
Retries a fallible ` Future ` with this policy ' s configuration under certain provided conditions
&self
task
T
condition
C
&self
task
T
condition
C