Skip to main content

WaitProgress

Struct WaitProgress 

Source
pub struct WaitProgress { /* private fields */ }
Expand description

Tracks one poll-until-ready loop: owns the clock, counts probes, and emits a throttled heartbeat line.

Construct it just before the loop, then per iteration use timed_out for the bound and tick to count the probe and print a heartbeat when due:

let mut progress = WaitProgress::new("vikunja", "systemctl + healthcheck", timeout)
    .with_prefix(format!("[{test_name}]     "));
loop {
    if ready { return Ok(()); }
    if failed { bail!("..."); }
    if progress.timed_out() { bail!("not ready after {}s", timeout.as_secs()); }
    progress.tick();
    tokio::time::sleep(interval).await;
}

Implementations§

Source§

impl WaitProgress

Source

pub fn new( label: impl Into<String>, method: impl Into<String>, timeout: Duration, ) -> Self

label is what we’re waiting for; method describes how readiness is probed; the loop is bounded by timeout. Defaults to a two-space prefix and a 5s heartbeat cadence — override with with_prefix / with_heartbeat.

Source

pub fn with_prefix(self, prefix: impl Into<String>) -> Self

Set the line prefix so the heartbeat aligns with the surrounding output (e.g. "[my-test] "). Defaults to two spaces.

Source

pub fn with_heartbeat(self, every: Duration) -> Self

Override how often a heartbeat prints. Defaults to 5s — right for the short service/port waits; long VM boot/SSH waits set this to 30s so they don’t flood the log.

Source

pub fn elapsed(&self) -> Duration

Time since the loop started.

Source

pub fn timed_out(&self) -> bool

Whether the loop has run past its timeout.

Source

pub fn tick(&mut self)

Record one probe attempt and print a heartbeat line if the cadence is due. Call once per loop iteration.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V