forked from ashleygwilliams/changes-stream-rust
-
Notifications
You must be signed in to change notification settings - Fork 1
/
event.rs
35 lines (29 loc) · 836 Bytes
/
event.rs
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
use serde_derive::{Deserialize, Serialize};
use serde_json::Value;
#[derive(Serialize, Deserialize, Debug)]
pub enum Event {
Change(ChangeEvent),
Finished(FinishedEvent),
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ChangeEvent {
pub seq: Value,
pub id: String,
pub changes: Vec<Change>,
#[serde(default)]
pub deleted: bool,
#[serde(default)]
#[cfg(feature = "raw_value_doc")]
pub doc: Option<Box<serde_json::value::RawValue>>,
#[cfg(not(feature = "raw_value_doc"))]
pub doc: Option<serde_json::Map<String, Value>>,
}
#[derive(Serialize, Deserialize, Debug)]
pub struct FinishedEvent {
pub last_seq: Value,
pub pending: Option<u64>, // not available on CouchDB 1.0
}
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct Change {
pub rev: String,
}