pub fn execute_when_ready_timeout<T>(
    &mut self,
    func: impl FnOnce(&mut Metriful) -> T,
    timeout: Option<Duration>,
  ) -> Result<T> {
    let start = Instant::now();

    loop {
      if self.is_ready()? {
        return Ok(func(self));
      }

      if let Some(timeout) = timeout {
        if start.elapsed() > timeout {
          return Err(MetrifulError::ReadyTimeoutExceeded)
        } else {
          thread::sleep(Duration::from_millis(READY_POLL_INTERVAL));
        }
      }
    }
  }
/// Waits for `Metriful::is_ready()` to become true and executes the given
/// function. If the timeout is exceeded, an error is returned.
Waits for `Metriful::is_ready()` to become true and executes the given
function. If the timeout is exceeded, an error is returned.
Waits for ` Metriful :: is_ready () ` to become true and executes the given function . If the timeout is exceeded an error is returned .
pub fn execute_when_ready_timeout<T>(
    &mut self,
    func: impl FnOnce(&mut Metriful) -> T,
    timeout: Option<Duration>,
  ) -> Result<T> {
    let start = Instant::now();
    loop {
      if self.is_ready()? {
        return Ok(func(self));
      }
      if let Some(timeout) = timeout {
        if start.elapsed() > timeout {
          return Err(MetrifulError::ReadyTimeoutExceeded)
        } else {
          thread::sleep(Duration::from_millis(READY_POLL_INTERVAL));
        }
      }
    }
  }
pub fn execute_when_ready_timeout < T > ( & mut self , func : impl FnOnce ( & mut Metriful ) -> T , timeout : Option < Duration > , ) -> Result < T > { let start = Instant :: now ( ) ; loop { if self . is_ready ( ) ? { return Ok ( func ( self ) ) ; } if let Some ( timeout ) = timeout { if start . elapsed ( ) > timeout { return Err ( MetrifulError :: ReadyTimeoutExceeded ) } else { thread :: sleep ( Duration :: from_millis ( READY_POLL_INTERVAL ) ) ; } } } }
Waits for `Metriful::is_ready()` to become true and executes the given
function.
Waits for ` Metriful :: is_ready () ` to become true and executes the given function .
&mut self
func
impl FnOnce(&mut Metriful) -> T
timeout
Option<Duration>
&mut self
func
impl FnOnce(&mut Metriful) -> T
timeout
Option<Duration>