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
-
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
RetryTimeoutwhen 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);
Guides#
Pages that discuss retry_until.