acts/store/db/mem/impl/
message.rs

1use crate::{
2    Result,
3    store::{Message, db::mem::DbDocument},
4};
5use serde_json::{Value as JsonValue, json};
6use std::collections::HashMap;
7
8impl DbDocument for Message {
9    fn id(&self) -> &str {
10        &self.id
11    }
12
13    fn doc(&self) -> Result<HashMap<String, JsonValue>> {
14        let mut map = HashMap::new();
15        map.insert("id".to_string(), json!(self.id.clone()));
16        map.insert("name".to_string(), json!(self.name.clone()));
17        map.insert("tid".to_string(), json!(self.tid.clone()));
18        map.insert("state".to_string(), json!(self.state.clone()));
19        map.insert("type".to_string(), json!(self.r#type.clone()));
20        map.insert("model".to_string(), json!(self.model.clone()));
21        map.insert("pid".to_string(), json!(self.pid.clone()));
22        map.insert("nid".to_string(), json!(self.nid.clone()));
23        map.insert("mid".to_string(), json!(self.mid.clone()));
24        map.insert("key".to_string(), json!(self.key.clone()));
25        map.insert("uses".to_string(), json!(self.uses.clone()));
26        map.insert("inputs".to_string(), json!(self.inputs.clone()));
27        map.insert("outputs".to_string(), json!(self.outputs.clone()));
28        map.insert("tag".to_string(), json!(self.tag.clone()));
29        map.insert("start_time".to_string(), json!(self.start_time));
30        map.insert("end_time".to_string(), json!(self.end_time));
31        map.insert("chan_id".to_string(), json!(self.chan_id.clone()));
32        map.insert("chan_pattern".to_string(), json!(self.chan_pattern));
33        map.insert("create_time".to_string(), json!(self.create_time));
34        map.insert("update_time".to_string(), json!(self.update_time));
35        map.insert("status".to_string(), json!(self.status));
36        map.insert("retry_times".to_string(), json!(self.retry_times));
37        map.insert("timestamp".to_string(), json!(self.timestamp));
38        Ok(map)
39    }
40}