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.

method libtmux-rs latest

Client.attached_session

The session this client is attached to.

Source and package
Qualified name
libtmux::client::Client::attached_session
Module
client
Declared in
Client
Package
libtmux
Source
crates/libtmux/src/client.rs
Other languages
Perlmethod Erlang PowerShell Julia Elixir Haskell Common Lisp Python RubyLuaTypeScriptGoJavaC#C++ Swift KotlinScalaOCamlfunction F# Clojure
pub async fn attached_session(&self) -> Result< Option<crate::Session>, Error >

Description#

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

In other ports#

The session a client is attached to

Equivalents of The session a client is attached to in other languages
Language Equivalent
Python client_session is a session name, not a Session object
Ruby LibTmux::ClientSnapshot#session
Lua libtmux.SnapshotClient.session
Haskell No public Haskell equivalent is implemented; the current modules expose scalar values and version parsing.
TypeScript client.Client.session
Go tmux.Client.AttachedSession
Java io.github.libtmux.Client.session
Kotlin io.github.libtmux.kotlin.Client.session
Scala io.github.libtmux.scaladsl.Client.session
C# LibTmux.Client.GetAttachedSessionAsync
C++ libtmux::Client::session
Swift the relationship is resolved through Snapshot.session(of:)
OCaml Libtmux.Client_observation.session Returns the captured session when the attached client had one.
Perl LibTmux::Client::session Captured nullable relation; unloaded data remains an error.

No equivalent is recorded in PowerShell, Julia, Erlang, Elixir, Common Lisp, Clojure or F#.

Esc

Type to search.

Reference previewOpen reference