Mountain/IPC/Common/MessageType/
IPCResponse.rs1use serde::{Deserialize, Serialize};
6
7#[derive(Debug, Clone, Serialize, Deserialize)]
8pub struct Struct {
9 pub CorrelationId:String,
10
11 pub Data:serde_json::Value,
12
13 pub Success:bool,
14
15 pub Error:Option<String>,
16
17 pub Timestamp:u64,
18}
19
20impl Struct {
21 pub fn Success(CorrelationId:impl Into<String>, Data:serde_json::Value) -> Self {
22 Self {
23 CorrelationId:CorrelationId.into(),
24
25 Data,
26
27 Success:true,
28
29 Error:None,
30
31 Timestamp:chrono::Utc::now().timestamp_millis() as u64,
32 }
33 }
34
35 pub fn Error(CorrelationId:impl Into<String>, Error:impl Into<String>) -> Self {
36 Self {
37 CorrelationId:CorrelationId.into(),
38
39 Data:serde_json::Value::Null,
40
41 Success:false,
42
43 Error:Some(Error.into()),
44
45 Timestamp:chrono::Utc::now().timestamp_millis() as u64,
46 }
47 }
48}