Mountain/IPC/Common/MessageType/
IPCCommand.rs1use std::collections::HashMap;
6
7use serde::{Deserialize, Serialize};
8
9use crate::IPC::Common::MessageType::MessagePriority;
10
11#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Struct {
13 pub Command:String,
14
15 pub Args:Vec<String>,
16
17 pub Params:HashMap<String, serde_json::Value>,
18
19 pub Priority:MessagePriority::Enum,
20}
21
22impl Struct {
23 pub fn new(Command:impl Into<String>) -> Self {
24 Self {
25 Command:Command.into(),
26
27 Args:Vec::new(),
28
29 Params:HashMap::new(),
30
31 Priority:MessagePriority::Enum::Normal,
32 }
33 }
34
35 pub fn WithArg(mut self, Arg:impl Into<String>) -> Self {
36 self.Args.push(Arg.into());
37
38 self
39 }
40
41 pub fn WithParam(mut self, Key:impl Into<String>, Value:serde_json::Value) -> Self {
42 self.Params.insert(Key.into(), Value);
43
44 self
45 }
46
47 pub fn WithPriority(mut self, Priority:MessagePriority::Enum) -> Self {
48 self.Priority = Priority;
49
50 self
51 }
52}