rmux_proto/request/client.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{ClientTerminalContext, SessionName, TerminalSize};
4
5/// Request payload for `attach-session`.
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub struct AttachSessionRequest {
8 /// The exact target session name.
9 pub target: SessionName,
10}
11
12/// Extended request payload for `attach-session`.
13#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
14pub struct AttachSessionExtRequest {
15 /// The optional exact target session name.
16 pub target: Option<SessionName>,
17 /// Whether other attached clients should be detached first.
18 #[serde(default)]
19 pub detach_other_clients: bool,
20 /// Whether other attached clients should be detached and terminated.
21 #[serde(default)]
22 pub kill_other_clients: bool,
23 /// Whether readonly attach mode should be enabled.
24 #[serde(default)]
25 pub read_only: bool,
26 /// Whether client environment updates should be skipped.
27 #[serde(default)]
28 pub skip_environment_update: bool,
29 /// Optional tmux client-flag names such as `read-only` or `active-pane`.
30 #[serde(default)]
31 pub flags: Option<Vec<String>>,
32}
33
34/// Further-extended request payload for `attach-session`.
35#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
36pub struct AttachSessionExt2Request {
37 /// The optional exact target session name.
38 #[serde(default)]
39 pub target: Option<SessionName>,
40 /// The optional raw tmux-style target text, including window/pane selectors.
41 #[serde(default)]
42 pub target_spec: Option<String>,
43 /// Whether other attached clients should be detached first.
44 #[serde(default)]
45 pub detach_other_clients: bool,
46 /// Whether other attached clients should be detached and terminated.
47 #[serde(default)]
48 pub kill_other_clients: bool,
49 /// Whether readonly attach mode should be enabled.
50 #[serde(default)]
51 pub read_only: bool,
52 /// Whether client environment updates should be skipped.
53 #[serde(default)]
54 pub skip_environment_update: bool,
55 /// Optional tmux client-flag names such as `read-only` or `active-pane`.
56 #[serde(default)]
57 pub flags: Option<Vec<String>>,
58 /// Optional tmux format-expanded working directory applied to the target session.
59 #[serde(default)]
60 pub working_directory: Option<String>,
61 /// Terminal/runtime hints captured from the invoking client.
62 #[serde(default)]
63 pub client_terminal: ClientTerminalContext,
64 /// The invoking client terminal size, when known.
65 #[serde(default)]
66 pub client_size: Option<TerminalSize>,
67}
68
69/// Request payload for `switch-client`.
70#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
71pub struct SwitchClientRequest {
72 /// The exact target session name.
73 pub target: SessionName,
74}
75
76/// Extended request payload for `switch-client`.
77#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
78pub struct SwitchClientExtRequest {
79 /// The optional exact target session name.
80 pub target: Option<SessionName>,
81 /// The optional key table to set for the attached client.
82 pub key_table: Option<String>,
83}
84
85/// Further-extended request payload for `switch-client`.
86#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
87pub struct SwitchClientExt2Request {
88 /// The optional exact target session name.
89 pub target: Option<SessionName>,
90 /// The optional key table to set for the attached client.
91 #[serde(default)]
92 pub key_table: Option<String>,
93 /// Whether the client's last session should be recalled.
94 #[serde(default)]
95 pub last_session: bool,
96 /// Whether the next session in order should be selected.
97 #[serde(default)]
98 pub next_session: bool,
99 /// Whether the previous session in order should be selected.
100 #[serde(default)]
101 pub previous_session: bool,
102 /// Whether readonly mode should be toggled for the addressed client.
103 #[serde(default)]
104 pub toggle_read_only: bool,
105 /// Reserved legacy field kept for wire compatibility; `switch-client` does not support `-f`.
106 #[serde(default)]
107 pub flags: Option<Vec<String>>,
108 /// Optional tmux list-sorting token used by `-n` and `-p`.
109 #[serde(default)]
110 pub sort_order: Option<String>,
111 /// Whether client environment updates should be skipped.
112 #[serde(default)]
113 pub skip_environment_update: bool,
114}
115
116/// Further-extended request payload for `switch-client`.
117#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
118pub struct SwitchClientExt3Request {
119 /// The optional target-client identifier or `=`.
120 #[serde(default)]
121 pub target_client: Option<String>,
122 /// The optional tmux target string, including pane or window targets.
123 #[serde(default)]
124 pub target: Option<String>,
125 /// The optional key table to set for the attached client.
126 #[serde(default)]
127 pub key_table: Option<String>,
128 /// Whether the client's last session should be recalled.
129 #[serde(default)]
130 pub last_session: bool,
131 /// Whether the next session in order should be selected.
132 #[serde(default)]
133 pub next_session: bool,
134 /// Whether the previous session in order should be selected.
135 #[serde(default)]
136 pub previous_session: bool,
137 /// Whether readonly mode should be toggled for the addressed client.
138 #[serde(default)]
139 pub toggle_read_only: bool,
140 /// Optional tmux list-sorting token used by `-n` and `-p`.
141 #[serde(default)]
142 pub sort_order: Option<String>,
143 /// Whether client environment updates should be skipped.
144 #[serde(default)]
145 pub skip_environment_update: bool,
146 /// Whether zoom should be preserved when switching panes.
147 #[serde(default)]
148 pub zoom: bool,
149}
150
151/// Request payload for `detach-client`.
152#[derive(Debug, Clone, Copy, Default, PartialEq, Eq, Serialize, Deserialize)]
153pub struct DetachClientRequest;
154
155/// Extended request payload for `detach-client`.
156#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
157pub struct DetachClientExtRequest {
158 /// The optional target-client identifier or `=`.
159 #[serde(default)]
160 pub target_client: Option<String>,
161 /// Whether all other clients should be detached instead.
162 #[serde(default)]
163 pub all_other_clients: bool,
164 /// The optional target session whose clients should all be detached.
165 #[serde(default)]
166 pub target_session: Option<SessionName>,
167 /// Whether targeted clients should be killed after detach.
168 #[serde(default)]
169 pub kill_on_detach: bool,
170 /// Optional client-local shell command to run before detaching.
171 #[serde(default)]
172 pub exec_command: Option<String>,
173}
174
175/// Request payload for `refresh-client`.
176#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
177pub struct RefreshClientRequest {
178 /// The optional target-client identifier or `=`.
179 #[serde(default)]
180 pub target_client: Option<String>,
181 /// Optional pan adjustment used with `-L`, `-R`, `-U`, or `-D`.
182 #[serde(default)]
183 pub adjustment: Option<u32>,
184 /// Whether client panning should be cleared.
185 #[serde(default)]
186 pub clear_pan: bool,
187 /// Whether the client view should pan left.
188 #[serde(default)]
189 pub pan_left: bool,
190 /// Whether the client view should pan right.
191 #[serde(default)]
192 pub pan_right: bool,
193 /// Whether the client view should pan up.
194 #[serde(default)]
195 pub pan_up: bool,
196 /// Whether the client view should pan down.
197 #[serde(default)]
198 pub pan_down: bool,
199 /// Whether only the status line should be redrawn.
200 #[serde(default)]
201 pub status_only: bool,
202 /// Whether the client clipboard should be queried.
203 #[serde(default)]
204 pub clipboard_query: bool,
205 /// Optional client-flag string from `-f`.
206 #[serde(default)]
207 pub flags: Option<String>,
208 /// Optional client-flag string from `-F`, which tmux treats as an alias for `-f`.
209 #[serde(default)]
210 pub flags_alias: Option<String>,
211 /// Optional control-mode subscription updates from `-A`.
212 #[serde(default)]
213 pub subscriptions: Vec<String>,
214 /// Optional control-mode subscription definitions from `-B`.
215 #[serde(default)]
216 pub subscriptions_format: Vec<String>,
217 /// Optional control-mode size string from `-C`.
218 #[serde(default)]
219 pub control_size: Option<String>,
220 /// Optional control-mode colour report request from `-r`.
221 #[serde(default)]
222 pub colour_report: Option<String>,
223}
224
225/// Request payload for `list-clients`.
226#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
227pub struct ListClientsRequest {
228 /// Optional custom output format.
229 #[serde(default)]
230 pub format: Option<String>,
231 /// Optional filter expression.
232 #[serde(default)]
233 pub filter: Option<String>,
234 /// Optional sort-order token.
235 #[serde(default)]
236 pub sort_order: Option<String>,
237 /// Whether the listing should be reversed.
238 #[serde(default)]
239 pub reversed: bool,
240 /// Optional session filter.
241 #[serde(default)]
242 pub target_session: Option<SessionName>,
243}
244
245/// Request payload for `suspend-client`.
246#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
247pub struct SuspendClientRequest {
248 /// The optional target-client identifier or `=`.
249 #[serde(default)]
250 pub target_client: Option<String>,
251}