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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
use crate::{
error::Error,
future::BoxFuture,
protect::{PassKey, StoreKeyMethod},
storage::{Entry, EntryKind, EntryOperation, EntryTag, Scan, TagFilter},
};
pub trait Backend: Send + Sync {
type Session: QueryBackend;
fn create_profile(&self, name: Option<String>) -> BoxFuture<'_, Result<String, Error>>;
fn get_profile_name(&self) -> &str;
fn remove_profile(&self, name: String) -> BoxFuture<'_, Result<bool, Error>>;
fn scan(
&self,
profile: Option<String>,
kind: EntryKind,
category: String,
tag_filter: Option<TagFilter>,
offset: Option<i64>,
limit: Option<i64>,
) -> BoxFuture<'_, Result<Scan<'static, Entry>, Error>>;
fn session(&self, profile: Option<String>, transaction: bool) -> Result<Self::Session, Error>;
fn rekey_backend(
&mut self,
method: StoreKeyMethod,
key: PassKey<'_>,
) -> BoxFuture<'_, Result<(), Error>>;
fn close(&self) -> BoxFuture<'_, Result<(), Error>>;
}
pub trait ManageBackend<'a> {
type Store;
fn open_backend(
self,
method: Option<StoreKeyMethod>,
pass_key: PassKey<'a>,
profile: Option<&'a str>,
) -> BoxFuture<'a, Result<Self::Store, Error>>;
fn provision_backend(
self,
method: StoreKeyMethod,
pass_key: PassKey<'a>,
profile: Option<&'a str>,
recreate: bool,
) -> BoxFuture<'a, Result<Self::Store, Error>>;
fn remove_backend(self) -> BoxFuture<'a, Result<bool, Error>>;
}
pub trait QueryBackend: Send {
fn count<'q>(
&'q mut self,
kind: EntryKind,
category: &'q str,
tag_filter: Option<TagFilter>,
) -> BoxFuture<'q, Result<i64, Error>>;
fn fetch<'q>(
&'q mut self,
kind: EntryKind,
category: &'q str,
name: &'q str,
for_update: bool,
) -> BoxFuture<'q, Result<Option<Entry>, Error>>;
fn fetch_all<'q>(
&'q mut self,
kind: EntryKind,
category: &'q str,
tag_filter: Option<TagFilter>,
limit: Option<i64>,
for_update: bool,
) -> BoxFuture<'q, Result<Vec<Entry>, Error>>;
fn remove_all<'q>(
&'q mut self,
kind: EntryKind,
category: &'q str,
tag_filter: Option<TagFilter>,
) -> BoxFuture<'q, Result<i64, Error>>;
fn update<'q>(
&'q mut self,
kind: EntryKind,
operation: EntryOperation,
category: &'q str,
name: &'q str,
value: Option<&'q [u8]>,
tags: Option<&'q [EntryTag]>,
expiry_ms: Option<i64>,
) -> BoxFuture<'q, Result<(), Error>>;
fn close(self, commit: bool) -> BoxFuture<'static, Result<(), Error>>;
}