Progress on refactor
parent: tbd commit: c9f076f
1 | |
2 | |
3 | use ; |
4 | |
5 | use TryFutureExt; |
6 | use |
7 | , | OperationError
8 | , |
9 | , |
10 | ; |
11 | use Debug; |
12 | use Mutex; |
13 | |
14 | use crate; |
15 | |
16 | use |
17 | repository_get_setting, repository_get_value, repository_set_setting, user_get_setting, |
18 | user_get_value, user_set_setting, OperationHandlers, |
19 | ; |
20 | |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | async |
27 | &self, |
28 | _object: O, |
29 | _operation: D, |
30 | |
31 | // We don't handle operations with this backend |
32 | Err |
33 | |
34 | |
35 | async |
36 | &self, |
37 | _object_str: &str, |
38 | |
39 | Err |
40 | |
41 | |
42 | |
43 | /// A backend implementation which attempts to resolve data from the instance's database. |
44 | |
45 | |
46 | pub(self) our_instance: Instance, |
47 | pub(self) user_backend: , |
48 | pub(self) repository_backend: , |
49 | |
50 | |
51 | |
52 | |
53 | f.debug_struct .finish |
54 | |
55 | |
56 | |
57 | |
58 | |
59 | async |
60 | &self, |
61 | object: O, |
62 | operation: D, |
63 | |
64 | let serialized = |
65 | map_err?; | to_value .
66 | let object_name = object.to_string; |
67 | |
68 | if let Ok = from_str |
69 | let mut handler = default; |
70 | |
71 | handler |
72 | .insert |
73 | .insert |
74 | .insert; |
75 | |
76 | match handler |
77 | .handle |
78 | &user, |
79 | , | operation_name
80 | unwrap, | from_value .
81 | self.clone, |
82 | |
83 | .await |
84 | |
85 | Ok => Ok |
86 | .map_err?, |
87 | Err => match err |
88 | => Err, | Internal
89 | => Err, | Unhandled
90 | => Err | Operation
91 | from_slice |
92 | .map_err?, |
93 | , |
94 | , |
95 | |
96 | else if let Ok = from_str |
97 | let mut handler = default; |
98 | |
99 | handler |
100 | .insert |
101 | .insert |
102 | .insert; |
103 | |
104 | // handler.handle(&repository, D::operation_name(), bincode::deserialize(&serialized).unwrap(), DatabaseBackendState).await; |
105 | todo! |
106 | else if from_str .is_ok |
107 | Err |
108 | else |
109 | Err |
110 | |
111 | |
112 | |
113 | async |
114 | &self, |
115 | object_str: &str, |
116 | |
117 | if let Ok = from_str |
118 | let mut user_backend = self.user_backend.lock .await; |
119 | |
120 | if user_backend |
121 | .exists |
122 | .await |
123 | .map_err? |
124 | |
125 | Ok |
126 | new_unchecked |
127 | from_object_str |
128 | .map_err?, |
129 | self.clone, |
130 | |
131 | |
132 | else |
133 | return Err; |
134 | |
135 | else if let Ok = from_str |
136 | let mut repository_backend = self.repository_backend.lock .await; |
137 | |
138 | if repository_backend |
139 | .exists |
140 | .await |
141 | .map_err? |
142 | |
143 | Ok |
144 | new_unchecked |
145 | from_object_str |
146 | .map_err?, |
147 | self.clone, |
148 | |
149 | |
150 | else |
151 | return Err; |
152 | |
153 | else if from_str .is_ok |
154 | return Err; |
155 | else |
156 | // Invalid object type |
157 | return Err; |
158 | |
159 | |
160 | |
161 | |
162 | |
163 | use ; |
164 | |
165 | use Error; |
166 | use |
167 | |
168 | , | UserAuthenticationToken
169 | , | Instance
170 | , |
171 | , | AnySetting
172 | , | User
173 | , |
174 | |
175 | |
176 | AuthenticationTokenRequest, RegisterAccountRequest, RepositoryCreateRequest, |
177 | , |
178 | , | RepositoryFileInspectRequest
179 | GiteratedObjectValue, ObjectBackend, |
180 | , |
181 | , |
182 | ; |
183 | use Value; |
184 | use Mutex; |
185 | |
186 | use crate; |
187 | |
188 | use DatabaseBackend; |
189 | ; |
190 | |
191 | |
192 | |
193 | async |
194 | assert_eq!; |
195 | |
196 | Ok |
197 | & to_vec .unwrap, |
198 | |
199 | .unwrap |
200 | |
201 | async |
202 | todo! |
203 | |
204 | async |
205 | &mut self, |
206 | _user: &User, |
207 | _name: &str, |
208 | _setting: &Value, |
209 | |
210 | todo! |
211 | |
212 | async |
213 | Ok |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | async |
220 | &mut self, |
221 | _request: RegisterAccountRequest, |
222 | |
223 | todo! |
224 | |
225 | |
226 | async |
227 | &mut self, |
228 | _source: &Instance, |
229 | _request: AuthenticationTokenRequest, |
230 | |
231 | todo! |
232 | |
233 | |
234 | |
235 | ; |
236 | |
237 | |
238 | |
239 | async |
240 | &mut self, |
241 | _user: &User, |
242 | _request: &RepositoryCreateRequest, |
243 | |
244 | todo! |
245 | |
246 | async |
247 | &mut self, |
248 | _requester: , |
249 | _request: &RepositoryFileInspectRequest, |
250 | |
251 | todo! |
252 | |
253 | async |
254 | &mut self, |
255 | _requester: , |
256 | _user: &User, |
257 | |
258 | todo! |
259 | |
260 | async |
261 | todo! |
262 | |
263 | |
264 | |
265 | |
266 | DatabaseBackend |
267 | our_instance: from_str .unwrap, |
268 | user_backend: new as _, |
269 | repository_backend: new as _, |
270 | |
271 | |
272 | |
273 | |
274 | async |
275 | let backend = test_backend; |
276 | |
277 | let mut user = backend |
278 | . |
279 | .await |
280 | .expect; |
281 | |
282 | user. |
283 | .await |
284 | .expect; |
285 | |
286 | |
287 |