# test.retry_until

- **Module:** test
- **Package:** libtmux
- **Language:** Rust
- **Kind:** function
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/test.rs#L959
- **Page:** https://libtmux.org/reference/rs/test-retry_until/

```
test.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; return `false` to
keep waiting.

## Example

```rust
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);
```
