devimint::util

Function poll

Source
pub async fn poll<Fut, R>(name: &str, f: impl Fn() -> Fut) -> Result<R>
where Fut: Future<Output = Result<R, ControlFlow<Error, Error>>>,
Expand description

Retry until f succeeds or default timeout is reached

  • if f return Ok(val), this returns with Ok(val).
  • if f return Err(Control::Break(err)), this returns Err(err)
  • if f return Err(ControlFlow::Continue(err)), retries until timeout reached