Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

method libtmux-rs latest

Session.with_window

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

Source and package
Qualified name
libtmux::session::Session::with_window
Module
session
Declared in
Session
Package
libtmux
Source
crates/libtmux/src/session.rs
pub async fn with_window<T, E>( &self, options: impl Into<NewWindowOptions>, operation: impl AsyncFnOnce(&Window) -> Result<T, E>, ) -> Result<T, crate::ScopeError<T, E>>

Description#

crate::ScopeError retains creation, operation and cleanup failures separately. If operation and cleanup both fail, both original errors are returned. Cleanup errors carry Error::AfterEffect because creation succeeded.

Errors

Returns crate::ScopeError when creation, the operation, or cleanup fails. The operation's error needs no conversion into Error.

Cancel safety

Nothing is left behind. Once polled, creation and cleanup run in tasks of their own, so the window is killed even if this future is dropped or the operation panics, while the Tokio runtime is alive. A cleanup failure then has no caller to reach; the tracing feature records it.

Type parameters
Parameters
Esc

Type to search.

Reference previewOpen reference