-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand.rs
More file actions
55 lines (51 loc) · 1.79 KB
/
Copy pathcommand.rs
File metadata and controls
55 lines (51 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
/// Top-level IPC command sent from `appclictl` to `appclid`.
///
/// Commands are serialised with [`encode`](crate::protocol::encode) and deserialised with
/// [`decode`](crate::protocol::decode).
///
/// # Example
///
/// ```
/// use appcli::protocol::{Command, decode, encode};
///
/// let cmd = Command::Ping;
/// let json = encode(&cmd).expect("encode should succeed");
/// assert_eq!(decode(&json).expect("decode should succeed"), cmd);
/// ```
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case", tag = "command")]
pub enum Command {
/// Check whether the daemon is alive. Returns [`crate::protocol::ResponseBody::Pong`].
Ping,
/// Ask the daemon to shut down gracefully.
Shutdown,
/// A config sub-command (show / reload).
Config(ConfigAction),
}
/// Config-related sub-commands that can be sent to the daemon.
///
/// # Example
///
/// ```
/// use appcli::protocol::{Command, ConfigAction, decode, encode};
///
/// let cmd = Command::Config(ConfigAction::Reload {
/// path: Some("/etc/appcli/config.yaml".into()),
/// });
/// let json = encode(&cmd).expect("encode should succeed");
/// assert_eq!(decode(&json).expect("decode should succeed"), cmd);
/// ```
#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize)]
#[serde(rename_all = "snake_case", tag = "action")]
pub enum ConfigAction {
/// Request a dump of the daemon's current runtime configuration.
Show,
/// Hot-reload the daemon's configuration.
///
/// If `path` is [`Some`], reload from that file; otherwise re-read the
/// original config file (or return an error if none was loaded).
Reload {
/// Path to load the new configuration from, or `None` to reuse the current path.
path: Option<String>,
},
}