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

Server.over_control_mode

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

Source and package
Qualified name
libtmux::server::Server::over_control_mode
Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server.rs
#[cfg(feature = "control-mode")] pub async fn over_control_mode( &self, sender: &crate::control::ControlSender, ) -> Result<Self, Error>

Description#

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?;

Guides#

Pages that discuss over_control_mode.

Esc

Type to search.

Reference previewOpen reference