Core Library0.xAPI Reference

Choose documentation 3

latest

Current version

latest
English

Early release libtmux is released, and its APIs may still change between releases. This site's structure and URLs may change too.

enum libtmux-rs latest

ReplaceMode

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

Source and package
Qualified name
libtmux::hooks::ReplaceMode
Module
hooks
Package
libtmux
Source
crates/libtmux/src/hooks.rs
enum hooks.ReplaceMode

Examples#

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

Variants2#

ReplaceMode variants
CasePayloadDescription
Merge No payload Leave entries at indices the write does not name.
Replace No payload Clear the hook first, so only the entries written remain.
Esc

Type to search.

Reference previewOpen reference