On this page
hooks.IndexedHooks
- Module
- hooks
- Package
- libtmux
- Source
- crates/libtmux/src/hooks.rs
- IndexedHooks : SparseValues<TmuxText>
-
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.Examples
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?;
0 declared, 0 inherited