# server.discovery.Server.hierarchy

- **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#L266
- **Page:** https://libtmux.org/reference/rs/server-discovery-server-hierarchy/

```
server.discovery.Server.hierarchy(self) -> Result<Vec<SessionTree>, Error>
```

Fetch the whole hierarchy in three commands.

Walking down with [`Server::sessions_or_empty`], then each session's windows,
then each window's panes costs one command per object. tmux can answer
the same question with `list-sessions`, `list-windows -a`, and
`list-panes -a`, so this issues three regardless of how much is
running and stitches the result by winlink.

Use it when you want everything. Use the scoped accessors when you
want one branch: they fetch less.

The three listings are separate tmux commands, so this is not an
atomic capture. A window created between them appears in one listing
and not another, and is dropped rather than reported half-formed.

# Errors

Returns an error when any of the three listings fails.
