# hooks.ReplaceMode

- **Module:** hooks
- **Package:** libtmux
- **Language:** Rust
- **Kind:** enum
- **Source:** https://github.com/libtmux/libtmux-rs/blob/f0e37052c232636b61d095817046e6bfc8f2ca40/crates/libtmux/src/hooks.rs#L208
- **Page:** https://libtmux.org/en/rs/latest/reference/hooks-replacemode/

Whether writing a hook keeps the entries it does not name.

## Example

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

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

let mut first = BTreeMap::new();
first.insert(0, TmuxText::from("display-message one"));
first.insert(1, TmuxText::from("display-message two"));
server
    .set_hooks("after-new-window", &IndexedHooks::from(first), ReplaceMode::Replace)
    .await?;

// `Merge` writes the indices it names and leaves the rest alone.
let mut second = BTreeMap::new();
second.insert(1, TmuxText::from("display-message replaced"));
server
    .set_hooks("after-new-window", &IndexedHooks::from(second), ReplaceMode::Merge)
    .await?;

let hooks = server.hook("after-new-window").await?.expect("just written");
assert_eq!(hooks.len(), 2);

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

## Members

- `Replace` (constant): Clear the hook first, so only the entries written remain.
- `Merge` (constant): Leave entries at indices the write does not name.
