Prerelease This site documents an alpha of libtmux. Its structure, URLs and APIs are subject to change.

hooks.SparseValues

Rust
  • Python Unavailable
  • Ruby Unavailable
  • Lua Unavailable
  • TypeScript Unavailable
  • Rust
  • Go Unavailable
  • Java Unavailable
  • .NET Unavailable
  • C++ Unavailable
  • Swift Unavailable

View as Markdown

Module
hooks
Package
libtmux
Source
crates/libtmux/src/hooks.rs
struct hooks.SparseValues
structoverload [source]
structoverload [source]
struct hooks.SparseValues

The values one array option holds, by the index tmux stores them under.

Indices are sparse, and tmux means it. Setting a value without an index writes slot 0, removing one slot of several leaves the rest where they were, and nothing renumbers, so a SparseValues with two entries may hold them at 0 and 30. Iteration is by ascending index.

Examples

let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
server.set_hook("after-new-window", "display-message built").await?;
let hooks = server.hook("after-new-window").await?.expect("the hook is set");
assert_eq!(hooks.len(), 1);
assert_eq!(
hooks.first().map(|value| value.to_string_lossy().into_owned()),
Some("display-message built".to_owned()),
);
guard.shutdown().await?;

8 declared, 0 inherited

Members

  • iter method The values and the indices they are stored under, lowest first.
  • first method The value at the lowest index, which is what a write without one sets.
  • get method The value stored at one index.
  • indices method The indices that hold a value, ascending.
  • into_values method The values alone, owned, by ascending index.
  • is_empty method Whether this option holds nothing.
  • len method How many values this option holds.
  • values method The values alone, by ascending index.
Esc

Type to search.