libtmux Reference MCP Search
On this page

session.Session.with_window

View as Markdown

Module
session
Declared in
Session
Package
libtmux
Source
crates/libtmux/src/session.rs
with_window ( self , options : impl Into<NewWindowOptions> , operation : impl AsyncFnOnce(&Window) -> Result<T, E> ) Result<T, E>
method [source]
method [source]
with_window

Create a window, run an operation with it, then kill it.

Once this future is polled, the scope owns creation and cleanup. Cancellation or unwinding can let an in-flight creation finish, but a window whose creation yields a handle is killed while the Tokio runtime remains active. Ordinary handle Drop remains non-destructive.

Setup and teardown failures convert into the operation's own error type, so a caller writes one ? rather than unwrapping twice. When both the operation and cleanup fail, the cleanup error is returned as Error::AfterEffect , because tmux had already accepted the scope's creation; the operation error is discarded. When the operation fails and cleanup succeeds, its generic error is returned unchanged: the scope cannot certify replay safety for arbitrary callback work. A canceled caller cannot receive a cleanup error, so tracing is its only report.

Errors

Returns the operation's error, or a converted [Error] when the window could not be created or could not be killed after creation.

0 declared, 0 inherited

Esc

Type to search.