On this page
server.Server.with_session
- Module
- server
- Declared in
- Server
- Package
- libtmux
- Source
- crates/libtmux/src/server.rs
- with_session ( self , options : impl Into<NewSessionOptions> , operation : impl AsyncFnOnce(&Session) -> Result<T, E> ) Result<T, E>
-
Create a session, 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 session whose creation yields a handle is killed while the Tokio runtime remains active. Ordinary handle
Dropremains 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 asError::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 session could not be created or could not be killed after creation.
0 declared, 0 inherited