Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

Rust API

Rust documentation

server.Server.over_control_mode

Rust
  • Python Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server.rs
over_control_mode ( self , sender : &crate::control::ControlSender ) → Result<Self, Error>
method [source]
method [source]
over_control_mode

Return a handle whose commands run over an open control connection.

Every typed call on the returned server -- sessions , send_keys, capture , the option and hook accessors -- is written to sender as one control-mode line and answered from its %begin/%end block, rather than spawning tmux. Handles reached through it inherit the route, because they carry the same connection.

The original server is unchanged and still dispatches processes. Use it for the two things a connection is wrong for: a command that answers at once and then parks the client's queue, such as wait-for or a foreground run-shell, and a command whose arguments are not valid UTF-8, which a text protocol cannot carry.

Commands wait for the sender's own reply_timeout, not this server's default_timeout . They are not the same budget: one bounds a round trip on an open connection, the other bounds forking tmux.

Draining events

The connection stops reading tmux once a caller is far enough behind on ControlEvents , and refuses commands past that. Either keep reading events, drop the watching half, or narrow what tmux reports with ControlSender::watch_only .

Errors

Returns an error when the sender reaches a different server, or when the tmux version cannot be detected. Detection runs here, once, through this server's process transport, because tmux -V is a client flag and has no control-mode spelling; the returned handle never probes.

Examples

use libtmux::control::ControlMode;
use libtmux::test::TestServer;
let guard = TestServer::new().await?;
let session = guard.server().new_session("routed").await?;
let (sender, events) = ControlMode::attach(guard.server(), session.id())
.await?
.split();
let routed = guard.server().over_control_mode(&sender).await?;
// One line on the connection, not a process.
assert_eq!(routed.sessions().await?.len(), 1);
// And a handle it found keeps the route.
let pane = routed.panes().await?.remove(0);
pane.send_line("true").await?;
events.shutdown().await?;
guard.shutdown().await?;

0 declared, 0 inherited

Esc

Type to search.