# server.discovery.Server.sessions_or_empty

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

```
server.discovery.Server.sessions_or_empty(self) -> Vec<Session>
```

List every session on the server, in tmux's own order.

This is the lenient form: a server that is not running, or any other
failure of the underlying list operation, yields an empty `Vec`. Use
[`Server::sessions`] when the reason matters.

## Example

```rust
let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();

// A fixture starts with no sessions. The lenient form reports that as
// an empty listing rather than as the failure it also collapses.
assert!(server.sessions_or_empty().await.is_empty());

guard.session("work").await?;

let sessions = server.sessions_or_empty().await;
assert_eq!(sessions.len(), 1);
assert_eq!(sessions[0].name().as_bytes(), b"work");

guard.shutdown().await?;
```
