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.generation

Which tmux daemon is answering on this endpoint.

Source and package
Qualified name
libtmux::server::Server::generation
Module
server
Declared in
Server
Package
libtmux
Source
crates/libtmux/src/server.rs
pub async fn generation(&self) -> Result< ServerGeneration, Error >

Description#

A socket path does not identify a daemon. tmux reuses the socket file across restarts -- it survives kill-server, and a replacement daemon binds the same inode -- so an endpoint that looks unchanged can be a different server holding different objects under the same ids. A pane handle for %0 taken before a restart addresses the replacement's %0 afterwards, which for a mutation is the wrong object rather than a missing one.

Capture this before work that must not be misapplied, and check it with Self::require_generation() before acting on a handle that has been held across time.

Errors

Returns an error when tmux cannot be reached, or answers with something that is not a pid and a start time this platform's SystemTime holds.

Examples#

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
server.new_session("work").await?;
let generation = server.generation().await?;
// Unchanged while the daemon is the same one.
server.require_generation(generation).await?;
guard.shutdown().await?;
Esc

Type to search.

Reference previewOpen reference