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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
use crate::Sample;
use std::collections::HashMap;
pub const OP_DELIVER_EVENT: &str = "DeliverEvent";
pub const OP_WRITE_EVENT: &str = "WriteEvent";
pub const OP_QUERY_STREAM: &str = "QueryStream";
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct Event {
    
    pub event_id: String,
    
    pub stream: String,
    #[serde(default)]
    pub values: HashMap<String, String>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct WriteResponse {
    
    pub event_id: String,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct StreamQuery {
    
    pub stream_id: String,
    
    #[serde(default)]
    pub range: Option<TimeRange>,
    
    
    pub count: u64,
}
impl Sample for StreamQuery {
    fn sample() -> Self {
        StreamQuery {
            stream_id: "stream1".to_string(),
            range: Some(TimeRange {
                min_time: 0,
                max_time: 1000,
            }),
            count: 42,
        }
    }
}
#[derive(Debug, PartialEq, Deserialize, Serialize, Clone)]
#[serde(rename_all = "camelCase")]
pub struct StreamResults {
    
    #[serde(default)]
    pub events: Vec<Event>,
}
#[derive(Debug, PartialEq, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TimeRange {
    
    pub min_time: u64,
    
    pub max_time: u64,
}