devimint::util

Function poll_with_timeout

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

Retry until f succeeds or 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