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
use coll::options::{CursorType, FindOptions};
bitflags! {
pub struct OpReplyFlags: i32 {
const CURSOR_NOT_FOUND = 0b00000001;
const QUERY_FAILURE = 0b00000010;
const AWAIT_CAPABLE = 0b00001000;
}
}
bitflags! {
pub struct OpUpdateFlags: i32 {
const UPSERT = 0b00000001;
const MULTI_UPDATE = 0b00000010;
}
}
bitflags! {
pub struct OpInsertFlags: i32 {
const CONTINUE_ON_ERROR = 0b00000001;
}
}
bitflags! {
pub struct OpQueryFlags: i32 {
const TAILABLE_CURSOR = 0b00000010;
const SLAVE_OK = 0b00000100;
const OPLOG_RELAY = 0b00001000;
const NO_CURSOR_TIMEOUT = 0b00010000;
const AWAIT_DATA = 0b00100000;
const EXHAUST = 0b01000000;
const PARTIAL = 0b10000000;
}
}
impl OpQueryFlags {
pub fn with_find_options(options: &FindOptions) -> OpQueryFlags {
let mut flags = OpQueryFlags::empty();
if options.cursor_type != CursorType::NonTailable {
flags.insert(Self::TAILABLE_CURSOR);
}
if options.oplog_replay {
flags.insert(Self::OPLOG_RELAY);
}
if options.no_cursor_timeout {
flags.insert(Self::NO_CURSOR_TIMEOUT);
}
if options.cursor_type == CursorType::TailableAwait {
flags.insert(Self::AWAIT_DATA);
}
if options.allow_partial_results {
flags.insert(Self::PARTIAL);
}
flags
}
}