Skip to main content

Crate tmuxctl

Crate tmuxctl 

Source
Expand description

tmuxctl — a bidirectional tmux control-mode (tmux -C) client.

This crate is the wire between a Rust front-end and a tmux server: it spawns tmux -C, parses the %-prefixed notification stream into typed Notifications, correlates command replies by command-number, octal-decodes pane output to raw bytes, and models tmux’s layout tree (Layout).

It is a protocol layer only — no terminal emulation, no rendering, no UI. Those are the consumer’s job (see hangar).

The protocol contract lives in docs/spec/overview.md; a map of the tmux C source that backs each wire detail lives in docs/reference/tmux-source-map.md.

§Status

Early. The value types (PaneId, Notification, Layout), the pure helpers (decode_output, layout::checksum, Layout::parse), and the synchronous line Parser (framing + %begin/%end reply blocks) are in place and tested. The async Client (spawn tmux -C, drive the parser over tokio pipes, correlate replies to futures) is the next slice.

Re-exports§

pub use layout::Layout;
pub use parser::Event;
pub use parser::Parser;
pub use parser::Reply;

Modules§

layout
tmux window-layout strings: the typed tree, the checksum, and parse/render.
parser
Incremental line parser for the tmux control-mode stream.

Structs§

Client
A blocking tmux control-mode client.
CommandId
An opaque handle correlating a sent command to its eventual reply. A driver tags each outstanding command with the id from Engine::register_command and matches it against Incoming::Reply.
CommandOutput
A command’s %end reply: its (possibly empty) output lines.
Engine
The sans-IO protocol core: parser + outstanding-command FIFO + framing buffer.
PaneId
A tmux pane id — %<n> on the wire.
SessionId
A tmux session id — $<n> on the wire.
SpawnOpts
How to spawn the tmux -C control client. Default runs tmux -C new-session -A (attach-or-create the default session) on the default server.
WindowFlags
tmux’s window flags, the raw-flags field of %layout-change (window_printable_flags in tmux window.c). Each known flag is a named field; any character tmux adds that we don’t model yet is retained in unknown, so the set is forward-compatible and nothing is dropped.
WindowId
A tmux window id — @<n> on the wire.

Enums§

CommandError
Why a command did not return successful output.
Error
Errors from the pure core. Two failure kinds live in their own types rather than here: a command’s %error reply is crate::CommandError, and session teardown is crate::Notification::Exit — drivers own their own std::io errors. So the core’s only fallible operation is layout parsing. #[non_exhaustive] keeps adding a future variant non-breaking.
Incoming
A correlated outcome the engine surfaces from one input line.
Notification
A parsed tmux control-mode notification.

Functions§

decode_output
Decode a tmux %output / %extended-output payload back to raw bytes.

Type Aliases§

Result
Crate-wide result alias.