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:: , ) -> Result<Self, Error>Control Sender -
Description#
Every typed call on the returned server --
sessions(),send_keys,capture, the option and hook accessors -- is written tosenderas one control-mode line and answered from its%begin/%endblock, rather than spawningtmux. 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-foror a foregroundrun-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'sdefault_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 withControlSender::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 -Vis 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?;- Parameters
Guides#
Pages that discuss over_control_mode.