Server.array_option
Read every value an array option holds, by index.
Source and package
- Qualified name
-
libtmux::server:: Server:: array _option - Module
- server
- Declared in
Server- Package
- libtmux
- Source
- crates/libtmux/src/server/settings.rs
-
Description#
Some tmux options hold a numbered set rather than one value:
command-aliasandterminal-overridesare the common ones, and every hook is one too. The indices are sparse and tmux keeps the gaps, so this reports them rather than a list. An empty result means the option holds nothing.Errors
Returns an error when tmux does not recognize the option name.
Examples#
let guard = libtmux::test::TestServer::new().await?;let server = guard.server();// Written far apart on purpose: nothing renumbers, so the gap stays.server.set_array_option("command-alias", 30, "thirty=display -p 30").await?;server.set_array_option("command-alias", 35, "five=display -p 35").await?;let aliases = server.array_option("command-alias").await?;assert_eq!(aliases.get(31), None, "the gap is tmux's, and it is kept");assert_eq!(aliases.get(35).map(|value| value.to_string_lossy().into_owned()),Some("five=display -p 35".to_owned()),);server.unset_array_option("command-alias", 35).await?;assert_eq!(server.array_option("command-alias").await?.get(35), None);guard.shutdown().await?;