# control.PaneOutput.snapshot

- **Module:** control.PaneOutput
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/control.rs#L1192
- **Page:** https://libtmux.org/reference/rs/control-paneoutput-snapshot/

```
control.PaneOutput.snapshot(mut, on_output: impl FnMut(&[u8])) -> Result<Vec<TmuxText>, Error>
```

Capture the pane's visible screen at an ordered point in this stream.

`on_output` receives every unread chunk tmux ordered before the capture
block. The callback owns any retention policy, so libtmux does not
retain those chunks. It runs synchronously and should return promptly.

Each chunk passed to `on_output` is consumed from this stream and is
not repeated by [`Self::next_chunk`]. That remains true when this
future is cancelled or returns an error: caller-owned storage keeps
the prefix it already accepted.

The visible screen and preceding output may overlap: the screen is
tmux's rendered grid, while the callback receives the raw terminal
byte stream that reached that grid.

# Errors

Returns an error when the connection closes, the command deadline
elapses, or tmux refuses the capture, including when the pane vanished.

## Example

```rust
let mut output = pane.stream_output().await?;
let mut preceding = Vec::new();
let visible = output
    .snapshot(|chunk| preceding.extend_from_slice(chunk))
    .await?;

println!("{} visible lines after {} raw bytes", visible.len(), preceding.len());
output.shutdown().await
```
