rmux_proto/request/session.rs
1use serde::{Deserialize, Serialize};
2
3use crate::{SessionName, TerminalSize};
4
5/// Request payload for `new-session`.
6#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
7pub struct NewSessionRequest {
8 /// The exact session name to create.
9 pub session_name: SessionName,
10 /// Whether the session should remain detached after creation.
11 pub detached: bool,
12 /// The initial pane geometry, when explicitly requested.
13 pub size: Option<TerminalSize>,
14 /// Optional per-spawn environment overrides in `NAME=VALUE` form.
15 #[serde(default)]
16 pub environment: Option<Vec<String>>,
17}
18
19/// Extended request payload for `new-session`.
20#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
21pub struct NewSessionExtRequest {
22 /// The optional exact session name to create.
23 pub session_name: Option<SessionName>,
24 /// Optional tmux format-expanded start directory for the new session.
25 #[serde(default)]
26 pub working_directory: Option<String>,
27 /// Whether the session should remain detached after creation.
28 pub detached: bool,
29 /// The initial pane geometry, when explicitly requested.
30 pub size: Option<TerminalSize>,
31 /// Optional per-spawn environment overrides in `NAME=VALUE` form.
32 #[serde(default)]
33 pub environment: Option<Vec<String>>,
34 /// The optional target session or group name for grouped-session creation.
35 #[serde(default)]
36 pub group_target: Option<SessionName>,
37 /// Whether an existing target session should be attached instead of erroring.
38 #[serde(default)]
39 pub attach_if_exists: bool,
40 /// Whether other attached clients should be detached before attaching.
41 #[serde(default)]
42 pub detach_other_clients: bool,
43 /// Whether other attached clients should be detached and terminated.
44 #[serde(default)]
45 pub kill_other_clients: bool,
46 /// Optional tmux client-flag names such as `read-only` or `active-pane`.
47 #[serde(default)]
48 pub flags: Option<Vec<String>>,
49 /// The optional initial active-window name for standalone session creation.
50 #[serde(default)]
51 pub window_name: Option<String>,
52 /// Whether the created session should print formatted session information.
53 #[serde(default)]
54 pub print_session_info: bool,
55 /// The optional format template used when printing session information.
56 #[serde(default)]
57 pub print_format: Option<String>,
58 /// Optional shell command argv. A single argument is executed via `$SHELL -c`.
59 #[serde(default)]
60 pub command: Option<Vec<String>>,
61}
62
63/// Request payload for `has-session`.
64#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
65pub struct HasSessionRequest {
66 /// The exact target session name.
67 pub target: SessionName,
68}
69
70/// Request payload for `kill-session`.
71#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
72pub struct KillSessionRequest {
73 /// The exact target session name.
74 pub target: SessionName,
75 /// Whether every other session should be destroyed instead of the target session.
76 #[serde(default)]
77 pub kill_all_except_target: bool,
78 /// Whether the target session's window alert flags should be cleared instead of destroying it.
79 #[serde(default)]
80 pub clear_alerts: bool,
81}
82
83/// Request payload for `rename-session`.
84#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
85pub struct RenameSessionRequest {
86 /// The exact existing session name.
87 pub target: SessionName,
88 /// The validated destination session name.
89 pub new_name: SessionName,
90}
91
92/// Request payload for `list-sessions`.
93#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
94pub struct ListSessionsRequest {
95 /// An optional server-side format template.
96 pub format: Option<String>,
97 /// An optional server-side filter expression.
98 #[serde(default)]
99 pub filter: Option<String>,
100 /// The optional tmux sort order name.
101 #[serde(default)]
102 pub sort_order: Option<String>,
103 /// Whether the selected sort order should be reversed.
104 #[serde(default)]
105 pub reversed: bool,
106}