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


pub type CommandResult = Result<CommandOk, CommandError>;

#[derive(Debug)]
pub struct CommandOk {
    pub result: String,
}

impl CommandOk {
    pub fn new<TResult: Into<String>>(result: TResult) -> Self { Self { result: result.into() } }
}

impl Default for CommandOk {
    fn default() -> Self {
        Self { result: "accepted".to_string() }
    }
}

#[derive(Debug)]
pub struct CommandError {
    /// Причина ошибки
    pub reason: String,

    /// Сообщение которое будет показано пользователю (TODO: проверить что оно реально показывается)
    pub status_message: String,
}

impl CommandError {
    pub fn new(reason: String, status_message: String) -> Self { Self { reason, status_message } }
}