Skip to main content

OwnedSession

Struct OwnedSession 

Source
pub struct OwnedSession { /* private fields */ }
Expand description

A session whose lifetime is owned by the SDK caller.

Implementations§

Source§

impl OwnedSession

Source

pub const fn cleanup_policy(&self) -> CleanupPolicy

Returns the configured cleanup policy.

Source

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.

Source

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.

Source

pub fn lease_state(&self) -> LeaseState

Returns the current daemon-side lease state.

Source

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.

Source

pub async fn cleanup(&mut self) -> Result<bool>

Explicitly kills the owned session when the policy is not CleanupPolicy::Preserve.

Source

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.

Source

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.

Source

pub async fn preserve(self) -> Result<Self>

Switches this owner to preserve mode after confirming lease release.

Source

pub async fn detach_owned(self) -> Result<Session>

Detaches the guard and returns the underlying persistent session.

Source

pub fn try_session(&self) -> Option<&Session>

Returns the underlying session handle if the owner still has one.

Source

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>§

Source

pub fn name(&self) -> &SessionName

Returns the exact protocol-owned session name addressed by this handle.

Source

pub fn endpoint(&self) -> &RmuxEndpoint

Returns the endpoint that was resolved when this handle was created.

Source

pub fn configured_default_timeout(&self) -> Option<Duration>

Returns the default timeout configured on the parent facade.

Source

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.

Source

pub fn creation_tags(&self) -> Option<&[String]>

Returns caller-supplied creation tag intent, preserving explicit empty tag sets.

Source

pub async fn exists(&self) -> Result<bool>

Checks the live daemon for this session.

Source

pub async fn is_listed(&self) -> Result<bool>

Checks whether this session appears in the daemon’s list-sessions projection.

Source

pub async fn list_session_names(&self) -> Result<Vec<SessionName>>

Lists exact session names currently reported by the daemon.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub fn share(&self) -> WebShareBuilder<'_>

Starts a web-share builder for this session.

Trait Implementations§

Source§

impl Debug for OwnedSession

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Deref for OwnedSession

Source§

type Target = Session

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.
Source§

impl Drop for OwnedSession

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.