Core LibraryalphaConcepts

Choose documentation 3

latest

Current version

latest
English

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

Edit this page on GitHub

Try a standard-library core and Tokio adapter

This runnable prototype splits pane values and capture requests into a dependency-free core, with live handles in a separate Tokio package. It supports pane listing and capture. It is an experiment, not a replacement for the published client.

PackageWhat belongs there
libtmuxPane IDs, detached snapshots, capture requests, and captured bytes. No dependencies.
libtmux-tokioConcrete server and pane handles, plus asynchronous execution.

Run it without Tokio

Use Rust 1.97.1, the repository’s pinned toolchain; the manifests require Rust 1.97 or newer. The live example requires Unix and tmux 3.2a or newer on PATH. The check script also requires Bash.

Clone the repository:

Terminal window
$ git clone https://github.com/libtmux/libtmux-rs.git

Check out the revision used by the linked programs:

Terminal window
$ git -C libtmux-rs checkout --detach d7541fbace16d6a45882cd0af0ea6880f9c21748

Enter its standalone Cargo workspace:

Terminal window
$ cd libtmux-rs/experiments/standard-library-core

Build a capture request and decode captured bytes without starting tmux:

Terminal window
$ cargo run --locked -p split-demo --bin offline

The offline program uses only the core. Its dependency graph is small enough to inspect directly:

Terminal window
$ cargo tree --locked -p split-demo

Capture a live pane

With tmux 3.2a or newer on PATH, enable the adapter:

Terminal window
$ cargo run --locked -p split-demo --features live --bin live

The live program starts an isolated server, prints a message in a pane, then captures it through the Tokio adapter. It also reads a detached snapshot after shutting down the runtime. It kills its own server and removes its socket under /tmp/libtmux-rs-dev/ when finished.

Set LIBTMUX_TEST_TMUX to choose a different tmux executable. Both programs print human-readable output to stdout, report errors to stderr, and exit zero on success and nonzero on failure.

The offline consumer builds a capture request synchronously. The live consumer passes that same core type to the adapter and receives captured bytes. Both links contain complete programs. Server and pane handles have concrete types; a runtime type parameter does not spread through the API.

What the experiment decides

A strict core can own useful values and requests while the adapter owns I/O. The core has no optional, build, target, or test dependencies either. The workspace’s check script verifies the dependency graph and runs both programs:

Terminal window
$ bash check.sh

The adapter bounds each output pipe to 2 MiB and gives each command five seconds. It handles direct child processes only. A full migration must retain the published client’s supervision, cancellation, process-group cleanup, and control-mode behaviour; this small adapter does not establish that parity.

Quinn and Tokio Tungstenite show how protocol logic and runtime adapters can live in separate packages. Their cores still have external dependencies. Zero dependencies is a stronger requirement: regex matching would need a companion package, and Serde would need wrappers or wire types for core values because of Rust’s orphan rules. Those integrations remain outside this prototype.

Esc

Type to search.

Reference preview Open reference