Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

function libtmux-rs latest

retry_until

Poll until a condition holds, or the deadline passes.

Source and package
Qualified name
libtmux::test::retry_until
Module
test
Package
libtmux
Source
crates/libtmux/src/test.rs
pub async fn retry_until( within: Duration, mut condition: impl AsyncFnMut() -> bool, ) -> Result<(), RetryTimeout>

Description#

tmux applies most changes asynchronously, so a test that reads straight back can observe the state before the change. This waits for the state the test is about rather than sleeping a fixed amount, which is both faster and not tied to how loaded the machine is.

Errors

Returns RetryTimeout when the condition did not hold before the deadline. The condition's own errors are its business; return false to keep waiting.

Examples#

use std::time::Duration;
use libtmux::test::retry_until;
let mut polls = 0;
retry_until(Duration::from_secs(5), async || {
polls += 1;
polls >= 3
})
.await?;
assert_eq!(polls, 3);
Parameters

Guides#

Pages that discuss retry_until.

Esc

Type to search.

Reference previewOpen reference