vitium_api/cmd.rs
1use serde::{Deserialize, Serialize};
2
3/// A line of command to be sent and executed by the server.
4#[derive(Clone, Serialize, Deserialize)]
5#[cfg_attr(target_family = "wasm", derive(tsify_next::Tsify))]
6#[cfg_attr(
7 target_family = "wasm",
8 tsify(
9 into_wasm_abi,
10 from_wasm_abi,
11 missing_as_null,
12 large_number_types_as_bigints
13 )
14)]
15pub struct CommandLine {
16 /// The user who issued this command.
17 ///
18 /// A value of [`None`] indicates that the command is directly executed from the server console.
19 pub user: Option<String>,
20 /// The complete line of command to execute, including the name of command and space seperated arguments.
21 pub line: String,
22}
23
24/// Denotes the exit status of a command.
25///
26/// An [`Ok`] indicates that the command exits with no error, with a payload of the command output.
27/// An [`Err`] indicates that the command exits with error, or is not executed
28/// (e.g. the command issuer does not have sufficient permission), with a payload of the formatted error message.
29///
30/// # Payload
31/// The payload would be a string that might contain [ANSI Escape Color Codes](https://en.wikipedia.org/wiki/ANSI_escape_code).
32/// Therefore, it is recommended to perform corresponding checks before printing the message.
33#[cfg_attr(target_family = "wasm", tsify_next::declare)]
34pub type CommandStatus = Result<String, String>;