# pane.observe.Pane.wait_for_text

- **Module:** pane.observe.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/pane/observe.rs#L254
- **Page:** https://libtmux.org/reference/rs/pane-observe-pane-wait_for_text/

```
pane.observe.Pane.wait_for_text(self, needle: impl AsRef<[u8]>, within: Duration) -> Result<PaneWait, Error>
```

Wait until this pane's output contains `needle`.

Polls rather than streams, so it needs no feature: a caller who
dispatches a command needs to know when it finished, and
[`Pane::send_keys`] without that is half an operation. A control-mode
subscription would answer sooner and is not available in a default
build.

Each look reads the scrollback rather than the visible screen, and
joins lines tmux wrapped. Both matter for correctness rather than
completeness: text that scrolled off before the look would otherwise
be missed and reported as absent, and a line wider than the pane
arrives split, so a needle spanning the wrap point would never match.

A pane whose process ends answers [`PaneWait::Dead`] rather than
running to the deadline, because waiting longer cannot change it.

# Errors

Returns an error when tmux cannot be reached or refuses a capture.
Running out of time is [`PaneWait::TimedOut`], not an error.

## Example

```rust
use libtmux::PaneWait;
use std::time::Duration;

pane.send_line("printf 'ready\\n'").await?;

let seen = pane.wait_for_text("ready", Duration::from_secs(10)).await?;
assert_eq!(seen, PaneWait::Arrived);
```
