# server.Server.generation

- **Module:** server.Server
- **Package:** libtmux
- **Language:** Rust
- **Kind:** method
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/server.rs#L1351
- **Page:** https://libtmux.org/reference/rs/server-server-generation/

```
server.Server.generation(self) -> Result<ServerGeneration, Error>
```

Which tmux daemon is answering on this endpoint.

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.

## Example

```rust
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?;
```
