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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! Driver capability reporting.
/// Feature report exposed by each driver.
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub struct Capabilities {
/// Driver supports transactional operation groups.
pub transactions: bool,
/// Driver supports time-to-live expiry.
pub ttl: bool,
/// Driver supports prefix scans.
pub prefix_scan: bool,
/// Driver supports atomic increment operations.
pub atomic_increment: bool,
/// Driver supports batch writes.
pub batch_write: bool,
/// Driver exposes a raw SQL escape hatch.
pub raw_sql: bool,
/// Driver exposes a document query escape hatch.
pub document_query: bool,
/// Driver exposes JSON query behaviour.
pub json_query: bool,
/// Driver supports migration helpers.
pub migrations: bool,
/// Driver manages connection pooling.
pub connection_pooling: bool,
/// Driver supports watch or subscription behaviour.
pub watch: bool,
/// Driver supports backup helpers.
pub backup: bool,
}
impl Capabilities {
/// Minimal capability set required of every driver.
#[must_use]
pub const fn minimal() -> Self {
Self {
transactions: false,
ttl: false,
prefix_scan: false,
atomic_increment: false,
batch_write: false,
raw_sql: false,
document_query: false,
json_query: false,
migrations: false,
connection_pooling: false,
watch: false,
backup: false,
}
}
/// Capability shape for the memory driver.
#[must_use]
pub const fn memory() -> Self {
Self {
transactions: false,
ttl: true,
prefix_scan: true,
atomic_increment: false,
batch_write: true,
raw_sql: false,
document_query: false,
json_query: false,
migrations: false,
connection_pooling: false,
watch: false,
backup: false,
}
}
/// Capability shape for the SQLite driver.
#[must_use]
pub const fn sqlite() -> Self {
Self {
transactions: true,
ttl: true,
prefix_scan: true,
atomic_increment: false,
batch_write: true,
raw_sql: false,
document_query: false,
json_query: false,
migrations: true,
connection_pooling: false,
watch: false,
backup: false,
}
}
}
impl Default for Capabilities {
fn default() -> Self {
Self::minimal()
}
}