On this page
test.retry_until
- Module
- test
- Package
- libtmux
- Source
- crates/libtmux/src/test.rs
- retry_until ( within : Duration , condition : impl AsyncFnMut() -> bool ) Result<(), RetryTimeout>
-
Poll until a condition holds, or the deadline passes.
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; returnfalseto 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);Discussed in Waiting and retrying
0 declared, 0 inherited