pub struct OwnedSession { /* private fields */ }Expand description
A session whose lifetime is owned by the SDK caller.
Implementations§
Source§impl OwnedSession
impl OwnedSession
Sourcepub const fn cleanup_policy(&self) -> CleanupPolicy
pub const fn cleanup_policy(&self) -> CleanupPolicy
Returns the configured cleanup policy.
Sourcepub const fn is_active(&self) -> bool
pub const fn is_active(&self) -> bool
Returns true while this owner still contains a live session handle.
This becomes false after a successful Self::cleanup or after
Self::detach_owned consumes the owner.
Sourcepub fn lease_lost(&self) -> bool
pub fn lease_lost(&self) -> bool
Returns true once the daemon-side owner lease renewal task has observed a terminal lease loss.
This is only meaningful for CleanupPolicy::KillOnOwnerExit. A true
value means the daemon may reap the session after the configured TTL.
Sourcepub fn lease_state(&self) -> LeaseState
pub fn lease_state(&self) -> LeaseState
Returns the current daemon-side lease state.
Sourcepub fn lease_state_receiver(&self) -> Option<Receiver<LeaseState>>
pub fn lease_state_receiver(&self) -> Option<Receiver<LeaseState>>
Subscribes to daemon-side lease state changes.
Returns None for sessions that were not created with
CleanupPolicy::KillOnOwnerExit.
Sourcepub async fn cleanup(&mut self) -> Result<bool>
pub async fn cleanup(&mut self) -> Result<bool>
Explicitly kills the owned session when the policy is not
CleanupPolicy::Preserve.
Sourcepub async fn shutdown_now(&mut self) -> Result<bool>
pub async fn shutdown_now(&mut self) -> Result<bool>
Immediately runs the same cleanup path as Self::cleanup.
This is a naming convenience for apps that already own their signal or cancellation handling and want an explicit shutdown hook.
Sourcepub fn install_default_signal_handlers(
&self,
) -> Result<OwnedSessionSignalHandlers>
pub fn install_default_signal_handlers( &self, ) -> Result<OwnedSessionSignalHandlers>
Installs opt-in process signal handling for this owned session.
The SDK never installs signal handlers by default. This helper listens for Ctrl-C on every platform, and for SIGTERM/SIGHUP on Unix, then asks the daemon to kill the session. Dropping the returned guard aborts the background listener. Only one guard may be installed at a time; a second call returns an error until the first guard is dropped.
Sourcepub async fn preserve(self) -> Result<Self>
pub async fn preserve(self) -> Result<Self>
Switches this owner to preserve mode after confirming lease release.
Sourcepub async fn detach_owned(self) -> Result<Session>
pub async fn detach_owned(self) -> Result<Session>
Detaches the guard and returns the underlying persistent session.
Sourcepub fn try_session(&self) -> Option<&Session>
pub fn try_session(&self) -> Option<&Session>
Returns the underlying session handle if the owner still has one.
Sourcepub fn session(&self) -> &Session
pub fn session(&self) -> &Session
Returns the underlying session handle.
Panics after successful Self::cleanup because there is no longer an
owned session handle. Use Self::try_session or Self::is_active
when the owner may have been cleaned up already.
Methods from Deref<Target = Session>§
Sourcepub fn name(&self) -> &SessionName
pub fn name(&self) -> &SessionName
Returns the exact protocol-owned session name addressed by this handle.
Sourcepub fn endpoint(&self) -> &RmuxEndpoint
pub fn endpoint(&self) -> &RmuxEndpoint
Returns the endpoint that was resolved when this handle was created.
Sourcepub fn configured_default_timeout(&self) -> Option<Duration>
pub fn configured_default_timeout(&self) -> Option<Duration>
Returns the default timeout configured on the parent facade.
Sourcepub fn was_created(&self) -> bool
pub fn was_created(&self) -> bool
Returns whether the ensure operation created the session.
false means the handle was bound to a session that already existed
before the ensure request completed.
Returns caller-supplied creation tag intent, preserving explicit empty tag sets.
Sourcepub async fn is_listed(&self) -> Result<bool>
pub async fn is_listed(&self) -> Result<bool>
Checks whether this session appears in the daemon’s list-sessions
projection.
Sourcepub async fn list_session_names(&self) -> Result<Vec<SessionName>>
pub async fn list_session_names(&self) -> Result<Vec<SessionName>>
Lists exact session names currently reported by the daemon.
Sourcepub fn window(&self, window_index: u32) -> Window
pub fn window(&self, window_index: u32) -> Window
Returns a handle for a window slot in this session.
The handle is intentionally lazy: it records the exact target and
verifies liveness only when an operation such as split, panes,
info, or close is invoked. Linked windows and grouped sessions are
still resolved by the daemon on each operation rather than cached by the
handle.
Sourcepub fn pane(&self, window_index: u32, pane_index: u32) -> Pane
pub fn pane(&self, window_index: u32, pane_index: u32) -> Pane
Returns a handle for one pane slot inside a window of this session.
The handle records the exact (session, window, pane) triple and
resolves it through the daemon on every operation, so linked windows
and grouped sessions keep returning the same stable pane identity
across sibling views.
Sourcepub async fn pane_by_id(&self, pane_id: PaneId) -> Result<Pane>
pub async fn pane_by_id(&self, pane_id: PaneId) -> Result<Pane>
Returns a pane handle addressed by stable pane id.
The returned Pane has the same public type as a slot-based pane,
but input, resize, lifecycle, title, and snapshot operations use the
daemon’s stable pane-id targeting path. PaneId is stable only for
one daemon lifetime; callers that persist ids across reconnects must
re-validate them.
Sourcepub async fn new_window(&self) -> Result<Window>
pub async fn new_window(&self) -> Result<Window>
Creates a new window in this session and returns a live window handle.
This is an eager daemon mutation. Use Self::window when you only
need a lazy handle for an existing or future window slot.
Sourcepub fn new_window_with(&self) -> NewWindowBuilder<'_>
pub fn new_window_with(&self) -> NewWindowBuilder<'_>
Starts building a configurable new-window request for this session.
The default builder behavior matches tmux new-window: the created
window becomes active unless NewWindowBuilder::detached is set.
Sourcepub fn layout(&self) -> SessionLayoutBuilder<'_>
pub fn layout(&self) -> SessionLayoutBuilder<'_>
Starts a declarative SDK layout builder for this session.
Layouts are SDK-side composition over the existing pane split, spawn, title, and daemon spread-layout primitives. They do not add a daemon-native transaction; if an intermediate split or spawn fails, already-created panes remain visible for inspection and cleanup by the caller.
Sourcepub async fn kill(&self) -> Result<bool>
pub async fn kill(&self) -> Result<bool>
Destroys this session through the daemon.
The returned boolean mirrors the daemon response: true means a
session existed and was removed.
Starts a web-share builder for this session.