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

client.Client.attached_session

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

View as Markdown

Module
client
Declared in
Client
Package
libtmux
Source
crates/libtmux/src/client.rs
attached_session ( self ) → Result<Option<crate::Session>, Error>
method [source]
method [source]
attached_session

The session this client is attached to.

None when the client is attached to nothing, which is an ordinary state rather than a failure.

Resolved through #{session_id} rather than #{client_session}. The latter is what tmux calls the attachment, but it is a *name*, and a name is not a handle: tmux will create a session called a:b and then refuse to address it, because : separates a session from a window in a target. The ID is unambiguous by construction.

Costs one tmux command. tmux fills a client's session into the same format tree it fills the client's own fields into, so the whole session snapshot comes back with the id rather than needing a listing after it.

Errors

Returns an error when tmux cannot be reached, or answers with an ID this crate cannot parse.

Examples

Terminal window
$ cargo test --package libtmux --all-features --test command_budget \
asking_a_client
let guard = libtmux::test::TestServer::new().await?;
let server = guard.server();
let session = server.new_session("work").await?;
// A control-mode connection is a client, so the server has one to find.
let control = libtmux::control::ControlMode::attach(server, session.id()).await?;
let client = server.clients().await?.into_iter().next().expect("one client");
let attached = client.attached_session().await?.expect("it is attached");
assert_eq!(attached.id(), session.id());
control.shutdown().await?;
guard.shutdown().await?;

0 declared, 0 inherited

Esc

Type to search.