Skip to main content

Connection

Struct Connection 

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

A blocking connection to the RMUX server that exchanges typed frames.

Implementations§

Source§

impl Connection

Source

pub fn set_buffer( &mut self, name: Option<String>, content: Vec<u8>, append: bool, new_name: Option<String>, set_clipboard: bool, ) -> Result<Response, ClientError>

Sends a set-buffer request over the detached RPC channel.

Source

pub fn show_buffer( &mut self, name: Option<String>, ) -> Result<Response, ClientError>

Sends a show-buffer request over the detached RPC channel.

Source

pub fn paste_buffer( &mut self, name: Option<String>, target: PaneTarget, delete_after: bool, separator: Option<String>, linefeed: bool, raw: bool, bracketed: bool, ) -> Result<Response, ClientError>

Sends a paste-buffer request over the detached RPC channel.

Source

pub fn list_buffers( &mut self, format: Option<String>, filter: Option<String>, sort_order: Option<String>, reversed: bool, ) -> Result<Response, ClientError>

Sends a list-buffers request over the detached RPC channel.

Source

pub fn delete_buffer( &mut self, name: Option<String>, ) -> Result<Response, ClientError>

Sends a delete-buffer request over the detached RPC channel.

Source

pub fn load_buffer( &mut self, path: String, name: Option<String>, set_clipboard: bool, ) -> Result<Response, ClientError>

Sends a load-buffer request over the detached RPC channel.

Source

pub fn save_buffer( &mut self, path: String, name: Option<String>, append: bool, ) -> Result<Response, ClientError>

Sends a save-buffer request over the detached RPC channel.

Source

pub fn capture_pane( &mut self, request: CapturePaneRequest, ) -> Result<Response, ClientError>

Sends a capture-pane request over the detached RPC channel.

Source

pub fn clear_history( &mut self, target: PaneTarget, reset_hyperlinks: bool, ) -> Result<Response, ClientError>

Sends a clear-history request over the detached RPC channel.

Source§

impl Connection

Source

pub fn set_option( &mut self, scope: ScopeSelector, option: OptionName, value: String, mode: SetOptionMode, ) -> Result<Response, ClientError>

Sends a set-option request over the detached RPC channel.

Source

pub fn set_option_by_name( &mut self, scope: OptionScopeSelector, name: String, value: Option<String>, mode: SetOptionMode, only_if_unset: bool, unset: bool, unset_pane_overrides: bool, ) -> Result<Response, ClientError>

Sends a string-keyed set-option request over the detached RPC channel.

Source

pub fn set_environment( &mut self, scope: ScopeSelector, name: String, value: String, mode: Option<SetEnvironmentMode>, hidden: bool, format: bool, ) -> Result<Response, ClientError>

Sends a set-environment request over the detached RPC channel.

Source

pub fn set_hook( &mut self, scope: ScopeSelector, hook: HookName, command: String, lifecycle: HookLifecycle, ) -> Result<Response, ClientError>

Sends a set-hook request over the detached RPC channel.

Source

pub fn set_hook_mutation( &mut self, scope: ScopeSelector, hook: HookName, command: Option<String>, lifecycle: HookLifecycle, append: bool, unset: bool, run_immediately: bool, index: Option<u32>, ) -> Result<Response, ClientError>

Sends an extended set-hook mutation over the detached RPC channel.

Source

pub fn show_options( &mut self, scope: OptionScopeSelector, name: Option<String>, value_only: bool, include_inherited: bool, ) -> Result<Response, ClientError>

Sends a show-options request over the detached RPC channel.

Source

pub fn show_environment( &mut self, scope: ScopeSelector, name: Option<String>, hidden: bool, shell_format: bool, ) -> Result<Response, ClientError>

Sends a show-environment request over the detached RPC channel.

Source

pub fn show_hooks( &mut self, scope: ScopeSelector, window: bool, pane: bool, hook: Option<HookName>, ) -> Result<Response, ClientError>

Sends a show-hooks request over the detached RPC channel.

Source

pub fn source_file( &mut self, paths: Vec<String>, quiet: bool, parse_only: bool, verbose: bool, expand_paths: bool, target: Option<PaneTarget>, stdin: Option<String>, ) -> Result<Response, ClientError>

Sends a source-file request over the detached RPC channel.

Source§

impl Connection

Source

pub fn bind_key( &mut self, request: BindKeyRequest, ) -> Result<Response, ClientError>

Sends a bind-key request over the detached RPC channel.

Source

pub fn unbind_key( &mut self, request: UnbindKeyRequest, ) -> Result<Response, ClientError>

Sends an unbind-key request over the detached RPC channel.

Source

pub fn list_keys( &mut self, request: ListKeysRequest, ) -> Result<Response, ClientError>

Sends a list-keys request over the detached RPC channel.

Source§

impl Connection

Source

pub fn swap_pane( &mut self, source: PaneTarget, target: PaneTarget, detached: bool, preserve_zoom: bool, ) -> Result<Response, ClientError>

Sends a swap-pane request over the detached RPC channel.

Source

pub fn swap_pane_with_next( &mut self, target: PaneTarget, detached: bool, preserve_zoom: bool, ) -> Result<Response, ClientError>

Sends swap-pane -D over the detached RPC channel.

Source

pub fn swap_pane_with_previous( &mut self, target: PaneTarget, detached: bool, preserve_zoom: bool, ) -> Result<Response, ClientError>

Sends swap-pane -U over the detached RPC channel.

Source

pub fn last_pane( &mut self, target: WindowTarget, ) -> Result<Response, ClientError>

Sends a last-pane request over the detached RPC channel.

Source

pub fn join_pane( &mut self, request: JoinPaneRequest, ) -> Result<Response, ClientError>

Sends a join-pane request over the detached RPC channel.

Source

pub fn move_pane( &mut self, request: MovePaneRequest, ) -> Result<Response, ClientError>

Sends a move-pane request over the detached RPC channel.

Source

pub fn break_pane( &mut self, request: BreakPaneRequest, ) -> Result<Response, ClientError>

Sends a break-pane request over the detached RPC channel.

Source

pub fn resize_pane( &mut self, target: PaneTarget, adjustment: ResizePaneAdjustment, ) -> Result<Response, ClientError>

Sends a resize-pane request over the detached RPC channel.

Source

pub fn display_panes( &mut self, target: SessionName, duration_ms: Option<u64>, non_blocking: bool, no_command: bool, template: Option<String>, ) -> Result<Response, ClientError>

Sends a display-panes request over the detached RPC channel.

Source

pub fn pipe_pane( &mut self, target: PaneTarget, stdin: bool, stdout: bool, once: bool, command: Option<String>, ) -> Result<Response, ClientError>

Sends a pipe-pane request over the detached RPC channel.

Source

pub fn respawn_pane( &mut self, request: RespawnPaneRequest, ) -> Result<Response, ClientError>

Sends a respawn-pane request over the detached RPC channel.

Source

pub fn select_pane( &mut self, target: PaneTarget, ) -> Result<Response, ClientError>

Sends a select-pane request over the detached RPC channel.

Source

pub fn select_pane_with_title( &mut self, target: PaneTarget, title: Option<String>, ) -> Result<Response, ClientError>

Sends a select-pane request with an optional title over the detached RPC channel.

Source

pub fn select_pane_adjacent( &mut self, target: PaneTarget, direction: SelectPaneDirection, ) -> Result<Response, ClientError>

Sends a directional select-pane request over the detached RPC channel.

Source

pub fn select_pane_mark( &mut self, target: PaneTarget, clear: bool, ) -> Result<Response, ClientError>

Sends select-pane -m or select-pane -M over the detached RPC channel.

Source

pub fn select_pane_mark_with_title( &mut self, target: PaneTarget, clear: bool, title: Option<String>, ) -> Result<Response, ClientError>

Sends select-pane -m/-M with an optional title over the detached RPC channel.

Source

pub fn kill_pane(&mut self, target: PaneTarget) -> Result<Response, ClientError>

Sends a kill-pane request over the detached RPC channel.

Source

pub fn kill_pane_with_options( &mut self, target: PaneTarget, kill_all_except: bool, ) -> Result<Response, ClientError>

Sends a kill-pane request with extended tmux flags.

Source

pub fn send_keys( &mut self, target: PaneTarget, keys: Vec<String>, ) -> Result<Response, ClientError>

Sends a send-keys request over the detached RPC channel.

Source

pub fn send_keys_extended( &mut self, request: SendKeysExtRequest, ) -> Result<Response, ClientError>

Sends an extended send-keys request over the detached RPC channel.

Source

pub fn send_prefix( &mut self, target: Option<PaneTarget>, secondary: bool, ) -> Result<Response, ClientError>

Sends a send-prefix request over the detached RPC channel.

Source

pub fn copy_mode( &mut self, request: CopyModeRequest, ) -> Result<Response, ClientError>

Sends a copy-mode request over the detached RPC channel.

Source

pub fn clock_mode( &mut self, target: Option<PaneTarget>, ) -> Result<Response, ClientError>

Sends a clock-mode request over the detached RPC channel.

Source§

impl Connection

Source

pub fn run_shell( &mut self, command: String, background: bool, as_commands: bool, show_stderr: bool, delay_seconds: Option<f64>, start_directory: Option<PathBuf>, target: Option<PaneTarget>, ) -> Result<Response, ClientError>

Sends a run-shell request over the detached RPC channel without a response read timeout.

Source

pub fn if_shell( &mut self, condition: String, format_mode: bool, then_command: String, else_command: Option<String>, target: Option<Target>, background: bool, ) -> Result<Response, ClientError>

Sends an if-shell request over the detached RPC channel without a response read timeout.

Source

pub fn wait_for( &mut self, channel: String, mode: WaitForMode, ) -> Result<Response, ClientError>

Sends a wait-for request over the detached RPC channel without a response read timeout.

Source§

impl Connection

Source

pub fn start_server( socket_path: &Path, no_start_server: bool, config: AutoStartConfig, ) -> Result<Self, StartServerError>

Ensures the server is available, honouring top-level no-start-server behavior.

Source

pub fn kill_server(&mut self) -> Result<Response, ClientError>

Sends a kill-server request over the detached RPC channel.

Source

pub fn daemon_status(&mut self) -> Result<Response, ClientError>

Sends an internal daemon status request over the detached RPC channel.

Source

pub fn shutdown_if_idle(&mut self) -> Result<Response, ClientError>

Sends an internal idle-only daemon shutdown request.

Source

pub fn lock_server(&mut self) -> Result<Response, ClientError>

Sends a lock-server request over the detached RPC channel.

Source

pub fn lock_session( &mut self, target: SessionName, ) -> Result<Response, ClientError>

Sends a lock-session request over the detached RPC channel.

Source

pub fn lock_client( &mut self, target_client: String, ) -> Result<Response, ClientError>

Sends a lock-client request over the detached RPC channel.

Source

pub fn server_access( &mut self, request: ServerAccessRequest, ) -> Result<Response, ClientError>

Sends a server-access request over the detached RPC channel.

Source§

impl Connection

Source

pub fn new_session( &mut self, session_name: SessionName, detached: bool, size: Option<TerminalSize>, ) -> Result<Response, ClientError>

Sends a new-session request over the detached RPC channel.

Source

pub fn new_session_with_environment( &mut self, session_name: SessionName, detached: bool, size: Option<TerminalSize>, environment: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a new-session request with explicit spawn environment overrides.

Source

pub fn new_session_extended( &mut self, request: NewSessionExtRequest, ) -> Result<Response, ClientError>

Sends an extended new-session request with grouped-session and attach-if-exists semantics.

Source

pub fn has_session( &mut self, target: SessionName, ) -> Result<Response, ClientError>

Sends a has-session request over the detached RPC channel.

Source

pub fn kill_session( &mut self, request: KillSessionRequest, ) -> Result<Response, ClientError>

Sends a kill-session request over the detached RPC channel.

Source

pub fn rename_session( &mut self, target: SessionName, new_name: SessionName, ) -> Result<Response, ClientError>

Sends a rename-session request over the detached RPC channel.

Source

pub fn list_sessions( &mut self, request: ListSessionsRequest, ) -> Result<Response, ClientError>

Sends a list-sessions request over the detached RPC channel.

Source

pub fn list_panes( &mut self, target: SessionName, format: Option<String>, ) -> Result<Response, ClientError>

Sends a list-panes request over the detached RPC channel.

Source

pub fn list_panes_in_window( &mut self, target: SessionName, target_window_index: Option<u32>, format: Option<String>, ) -> Result<Response, ClientError>

Sends a list-panes request scoped to an optional window index.

Source

pub fn switch_client( &mut self, target: SessionName, ) -> Result<Response, ClientError>

Sends a switch-client request over the detached RPC channel.

Source

pub fn switch_client_extended( &mut self, target: Option<SessionName>, key_table: Option<String>, ) -> Result<Response, ClientError>

Sends an extended switch-client request over the detached RPC channel.

Source

pub fn switch_client_with_session_flags( &mut self, request: SwitchClientExt2Request, ) -> Result<Response, ClientError>

Sends a further-extended switch-client request over the detached RPC channel.

Source

pub fn switch_client_with_target_selector( &mut self, request: SwitchClientExt3Request, ) -> Result<Response, ClientError>

Sends the most recent switch-client request shape over the detached RPC channel.

Source

pub fn detach_client(&mut self) -> Result<Response, ClientError>

Sends a detach-client request over the detached RPC channel.

Source

pub fn detach_client_extended( &mut self, request: DetachClientExtRequest, ) -> Result<Response, ClientError>

Sends an extended detach-client request over the detached RPC channel.

Source

pub fn refresh_client( &mut self, request: RefreshClientRequest, ) -> Result<Response, ClientError>

Sends a refresh-client request over the detached RPC channel.

Source

pub fn list_clients( &mut self, request: ListClientsRequest, ) -> Result<Response, ClientError>

Sends a list-clients request over the detached RPC channel.

Source

pub fn suspend_client( &mut self, request: SuspendClientRequest, ) -> Result<Response, ClientError>

Sends a suspend-client request over the detached RPC channel.

Source

pub fn begin_attach( self, target: SessionName, ) -> Result<AttachTransition, ClientError>

Requests an attach upgrade and, on success, yields the raw Unix stream.

Once this method returns AttachTransition::Upgraded, the detached framing codec is no longer in the data path for the connection.

Source

pub fn begin_attach_extended( self, request: AttachSessionExtRequest, ) -> Result<AttachTransition, ClientError>

Requests an extended attach upgrade and, on success, yields the raw Unix stream.

Source

pub fn begin_attach_with_target_spec( self, request: AttachSessionExt2Request, ) -> Result<AttachTransition, ClientError>

Sends the most recent attach-session request shape over the detached RPC channel.

Source

pub fn attach_session_with_target_spec_detached( &mut self, request: AttachSessionExt2Request, ) -> Result<Response, ClientError>

Sends the most recent attach-session request shape over the detached RPC channel.

Source§

impl Connection

Source

pub fn display_message( &mut self, target: Option<Target>, print: bool, message: Option<String>, ) -> Result<Response, ClientError>

Sends a display-message request over the detached RPC channel.

Source

pub fn show_messages( &mut self, jobs: bool, terminals: bool, target_client: Option<String>, ) -> Result<Response, ClientError>

Sends a show-messages request over the detached RPC channel.

Source§

impl Connection

Source

pub fn resolve_target( &mut self, target: Option<String>, target_type: ResolveTargetType, window_index: bool, prefer_unattached: bool, ) -> Result<Response, ClientError>

Resolves tmux-style raw target text against live server state.

Source§

impl Connection

Source

pub fn new_window( &mut self, target: SessionName, name: Option<String>, detached: bool, ) -> Result<Response, ClientError>

Sends a new-window request over the detached RPC channel.

Source

pub fn new_window_with_environment( &mut self, target: SessionName, name: Option<String>, detached: bool, environment: Option<Vec<String>>, start_directory: Option<PathBuf>, command: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a new-window request with explicit spawn environment overrides.

Source

pub fn new_window_at_with_environment( &mut self, target: SessionName, target_window_index: Option<u32>, name: Option<String>, detached: bool, environment: Option<Vec<String>>, start_directory: Option<PathBuf>, command: Option<Vec<String>>, insert_at_target: bool, ) -> Result<Response, ClientError>

Sends a new-window request with an optional destination index.

Source

pub fn kill_window( &mut self, target: WindowTarget, kill_others: bool, ) -> Result<Response, ClientError>

Sends a kill-window request over the detached RPC channel.

Source

pub fn select_window( &mut self, target: WindowTarget, ) -> Result<Response, ClientError>

Sends a select-window request over the detached RPC channel.

Source

pub fn rename_window( &mut self, target: WindowTarget, new_name: String, ) -> Result<Response, ClientError>

Sends a rename-window request over the detached RPC channel.

Source

pub fn next_window( &mut self, target: SessionName, alerts_only: bool, ) -> Result<Response, ClientError>

Sends a next-window request over the detached RPC channel.

Source

pub fn previous_window( &mut self, target: SessionName, alerts_only: bool, ) -> Result<Response, ClientError>

Sends a previous-window request over the detached RPC channel.

Source

pub fn last_window( &mut self, target: SessionName, ) -> Result<Response, ClientError>

Sends a last-window request over the detached RPC channel.

Source

pub fn list_windows( &mut self, target: SessionName, format: Option<String>, ) -> Result<Response, ClientError>

Sends a list-windows request over the detached RPC channel.

Sends a link-window request over the detached RPC channel.

Source

pub fn move_window( &mut self, source: Option<WindowTarget>, target: MoveWindowTarget, renumber: bool, kill_destination: bool, detached: bool, ) -> Result<Response, ClientError>

Sends a move-window request over the detached RPC channel.

Source

pub fn swap_window( &mut self, source: WindowTarget, target: WindowTarget, detached: bool, ) -> Result<Response, ClientError>

Sends a swap-window request over the detached RPC channel.

Source

pub fn rotate_window( &mut self, target: WindowTarget, direction: RotateWindowDirection, ) -> Result<Response, ClientError>

Sends a rotate-window request over the detached RPC channel.

Source

pub fn rotate_window_with_zoom( &mut self, target: WindowTarget, direction: RotateWindowDirection, restore_zoom: bool, ) -> Result<Response, ClientError>

Sends a rotate-window request with zoom save/restore over the detached RPC channel.

Source

pub fn resize_window( &mut self, target: WindowTarget, width: Option<u16>, height: Option<u16>, adjustment: Option<ResizeWindowAdjustment>, ) -> Result<Response, ClientError>

Sends a resize-window request over the detached RPC channel.

Sends an unlink-window request over the detached RPC channel.

Source

pub fn respawn_window( &mut self, target: WindowTarget, kill: bool, ) -> Result<Response, ClientError>

Sends a respawn-window request over the detached RPC channel.

Source

pub fn respawn_window_with_environment( &mut self, target: WindowTarget, kill: bool, environment: Option<Vec<String>>, start_directory: Option<PathBuf>, command: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a respawn-window request with explicit spawn environment overrides.

Source

pub fn split_window( &mut self, target: SplitWindowTarget, ) -> Result<Response, ClientError>

Sends a split-window request over the detached RPC channel.

Source

pub fn split_window_with_direction( &mut self, target: SplitWindowTarget, direction: SplitDirection, ) -> Result<Response, ClientError>

Sends a split-window request with an explicit direction over the detached RPC channel.

Source

pub fn split_window_with_direction_and_environment( &mut self, target: SplitWindowTarget, direction: SplitDirection, environment: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a split-window request with explicit spawn environment overrides.

Source

pub fn split_window_with_spawn( &mut self, target: SplitWindowTarget, direction: SplitDirection, environment: Option<Vec<String>>, command: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a split-window request with explicit spawn options.

New pane is inserted after the target. To insert before (tmux -b), use Connection::split_window_with_options.

Source

pub fn split_window_with_start_directory( &mut self, target: SplitWindowTarget, direction: SplitDirection, environment: Option<Vec<String>>, start_directory: Option<PathBuf>, command: Option<Vec<String>>, ) -> Result<Response, ClientError>

Sends a split-window request with an optional working-directory override.

New pane is inserted after the target. To insert before (tmux -b), use Connection::split_window_with_options without a start directory.

Source

pub fn split_window_with_options( &mut self, options: SplitWindowOptions, ) -> Result<Response, ClientError>

Sends a split-window request with full options including before.

Source

pub fn select_layout( &mut self, target: SelectLayoutTarget, layout: LayoutName, ) -> Result<Response, ClientError>

Sends a select-layout request over the detached RPC channel.

Source

pub fn select_custom_layout( &mut self, target: SelectLayoutTarget, layout: String, ) -> Result<Response, ClientError>

Sends a select-layout custom layout request over the detached RPC channel.

Source

pub fn next_layout( &mut self, target: WindowTarget, ) -> Result<Response, ClientError>

Sends a next-layout request over the detached RPC channel.

Source

pub fn previous_layout( &mut self, target: WindowTarget, ) -> Result<Response, ClientError>

Sends a previous-layout request over the detached RPC channel.

Source§

impl Connection

Source

pub fn roundtrip(&mut self, request: &Request) -> Result<Response, ClientError>

Sends a request and reads the server’s response.

Server-side Response::Error payloads are returned as-is in the Ok variant so callers can pattern-match on them. Only transport and framing failures produce Err.

Source

pub fn supports_capability( &mut self, capability: &str, ) -> Result<bool, ClientError>

Returns whether the connected daemon advertises a protocol capability.

Optional client behavior uses this as a soft gate: older daemons that do not answer the handshake shape or report an error are treated as not supporting the capability, leaving the connection usable for legacy requests.

Source§

impl Connection

Source

pub fn begin_control_mode( self, mode: ControlMode, client_terminal: ClientTerminalContext, ) -> Result<ControlTransition, ClientError>

Requests a control-mode upgrade and, on success, yields the raw local stream for tmux-compatible text control traffic.

Trait Implementations§

Source§

impl Debug for Connection

Source§

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

Formats the value using the given formatter. 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more