# pane.Pane.stream_output

- **Module:** pane.Pane
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/pane/observe.rs#L61
- **Page:** https://libtmux.org/en/rs/latest/reference/pane-pane-stream_output/

```
pane.Pane.stream_output(self) -> Result<crate::control::PaneOutput, Error>
```

Watch what this pane writes, as it writes it.

[`Pane::capture`] reads what is on screen now; this reports every byte
the pane produces from here on, including what scrolls away. It opens a
control-mode connection to the session holding the pane and keeps it,
so there is no polling and no sampling interval to get wrong. Where the
pane lives is resolved here rather than taken from this handle.

The bytes are the pane's own, terminal escapes included. tmux reports
them in whatever sized chunks it has, so a caller wanting lines has to
buffer.

Keep reading, or the pane stops. Events are handed over with
backpressure rather than dropped, so a stream left unread stops the
connection reading from tmux, and tmux stops the pane that is filling
it. A caller who wants to stop watching calls
[`PaneOutput::shutdown`](crate::control::PaneOutput::shutdown) rather
than leaving the handle idle.

tmux discards what a pane has buffered when the pane exits, so a
command that writes and returns immediately may be reported as nothing
at all.

# Errors

Returns [`Error::ObjectGone`] when the pane no longer exists, a listing
error when tmux could not be read, or an error when the control-mode
connection cannot be opened.

# Cancel safety

Nothing is left held: a dropped call closes the connection it opened,
and the mutes it set end with that connection.

## Example

```rust
let mut output = pane.stream_output().await?;

while let Some(chunk) = output.next_chunk().await {
    println!("{} bytes", chunk.len());
}

output.shutdown().await
```
