Skip to main content

Module blocking

Module blocking 

Source
Available on crate feature blocking only.
Expand description

Running the async API without writing an async program.

Most tmux code is a script, a test fixture, or a small tool. Requiring #[tokio::main] and .await for that is a tax with nothing bought: the transport is a subprocess, so there is no concurrency to gain at that scale.

This is a runtime, not a mirror of the API. Mirroring would mean a second copy of every method to keep in step, and a caller who reaches past its edge would have two servers and no way to combine them. A runtime covers every method that exists now and every one added later.

use libtmux::blocking::Runtime;

let runtime = Runtime::new()?;
let server = libtmux::Server::new()?;

let sessions = runtime.run(server.sessions())?;
for session in &sessions {
    println!("{}", session.id());
}

runtime.run(server.shutdown())?;

Structs§

Runtime
A runtime for calling this crate’s async methods from ordinary code.