pub async fn collect<T, C, S>(
        &self,
        task: T,
        condition: C,
        start_value: S,
    ) -> Result<Vec<T::Item>, T::Error>
    where
        T: TaskWithParameter<S>,
        C: SuccessCondition<T::Item, S>,
    {
        let mut backoffs = self.backoffs();
        let mut condition = condition;
        let mut task = task;
        let mut results = vec![];
        let mut input = start_value;

        loop {
            match task.call(input).await {
                Ok(result) => {
                    let maybe_new_input = condition.retry_with(&result);
                    results.push(result);

                    if let Some(new_input) = maybe_new_input {
                        if let Some(delay) = backoffs.next() {
                            #[cfg(feature = "log")]
                            {
                                log::trace!(
                                    "task succeeded and condition is met. will run again in {:?}",
                                    delay
                                );
                            }
                            let _ = Delay::new(delay).await;
                            input = new_input;
                            continue;
                        }
                    }

                    return Ok(results);
                }
                Err(err) => return Err(err),
            }
        }
    }
/// Reruns and collects the results of a successful `Future` with this policy's
/// configuration under a certain provided condition
Reruns and collects the results of a successful `Future` with this policy's
configuration under a certain provided condition
Reruns and collects the results of a successful ` Future ` with this policy ' s configuration under a certain provided condition
pub async fn collect<T, C, S>(
        &self,
        task: T,
        condition: C,
        start_value: S,
    ) -> Result<Vec<T::Item>, T::Error>
    where
        T: TaskWithParameter<S>,
        C: SuccessCondition<T::Item, S>,
    {
        let mut backoffs = self.backoffs();
        let mut condition = condition;
        let mut task = task;
        let mut results = vec![];
        let mut input = start_value;
        loop {
            match task.call(input).await {
                Ok(result) => {
                    let maybe_new_input = condition.retry_with(&result);
                    results.push(result);
                    if let Some(new_input) = maybe_new_input {
                        if let Some(delay) = backoffs.next() {
                            #[cfg(feature = "log")]
                            {
                                log::trace!(
                                    "task succeeded and condition is met. will run again in {:?}",
                                    delay
                                );
                            }
                            let _ = Delay::new(delay).await;
                            input = new_input;
                            continue;
                        }
                    }
                    return Ok(results);
                }
                Err(err) => return Err(err),
            }
        }
    }
pub async fn collect < T , C , S > ( & self , task : T , condition : C , start_value : S , ) -> Result < Vec < T :: Item > , T :: Error > where T : TaskWithParameter < S > , C : SuccessCondition < T :: Item , S > , { let mut backoffs = self . backoffs ( ) ; let mut condition = condition ; let mut task = task ; let mut results = vec ! [ ] ; let mut input = start_value ; loop { match task . call ( input ) . await { Ok ( result ) => { let maybe_new_input = condition . retry_with ( & result ) ; results . push ( result ) ; if let Some ( new_input ) = maybe_new_input { if let Some ( delay ) = backoffs . next ( ) { # [ cfg ( feature " " ) ] { log :: trace ! ( " " delay ) ; } let _ = Delay :: new ( delay ) . await ; input = new_input ; continue ; } } return Ok ( results ) ; } Err ( err ) => return Err ( err ) , } } }
Reruns and collects the results of a successful `Future` with this policy's
configuration under a certain provided condition
Reruns and collects the results of a successful ` Future ` with this policy ' s configuration under a certain provided condition
&self
task
T
condition
C
start_value
S
&self
task
T
condition
C
start_value
S