Pane.stream_output
Watch what this pane writes, as it writes it.
Source and package
- Qualified name
-
libtmux::pane:: Pane:: stream _output - Module
- pane
- Declared in
Pane- Package
- libtmux
- Source
- crates/libtmux/src/pane/observe.rs
- #[cfg(feature = "control-mode")] pub async fn stream_output(&self) -> Result< crate::
control:: , Error >Pane Output -
Description#
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()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::ObjectGonewhen 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.
Examples#
let mut output = pane.stream_output().await?;while let Some(chunk) = output.next_chunk().await {println!("{} bytes", chunk.len());}output.shutdown().await