# hooks.IndexedHooks

- **Module:** hooks
- **Package:** libtmux
- **Language:** Rust
- **Kind:** typealias
- **Source:** https://github.com/libtmux/libtmux-rs/blob/8a648c0894dfffc9303583f753b6c8ae01f2fe76/crates/libtmux/src/hooks.rs#L90
- **Page:** https://libtmux.org/reference/rs/hooks-indexedhooks/

The commands one hook name holds.

A hook is an array option whose values are tmux commands, so this is the
[`SparseValues`] of that shape rather than a type of its own.

## Example

```rust
use libtmux::{IndexedHooks, ReplaceMode, TmuxText};
use std::collections::BTreeMap;

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

// The indices are tmux's own and are sparse: removing one does not renumber
// the rest, so the map is keyed rather than positional.
let mut entries = BTreeMap::new();
entries.insert(0, TmuxText::from("display-message first"));
entries.insert(4, TmuxText::from("display-message fifth"));
server
    .set_hooks("after-new-window", &IndexedHooks::from(entries), ReplaceMode::Replace)
    .await?;

let hooks: IndexedHooks = server.hook("after-new-window").await?.expect("just written");
assert_eq!(hooks.len(), 2);
assert_eq!(hooks.indices().copied().collect::<Vec<_>>(), vec![0, 4]);

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