Major refactor to handler traits
Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Squashed commit of the following: commit 62e1ecf76ee31cda0bab4602d9d00fa0dc2f9158 Author: Amber <[email protected]> Date: Wed Oct 11 09:31:11 2023 -0500 Update commit dfd2d1b0b5d81ee3bc48f0321c6aceaa677e3b8b Author: Amber <[email protected]> Date: Wed Oct 11 09:31:07 2023 -0500 Major refactor to handler traits Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Removed dead and legacy code. I think... commit 57b4b398eff32e69f2f4b9700e42a1277a4d1055 Author: Amber <[email protected]> Date: Sun Oct 1 23:05:10 2023 -0500 New handler trait for giterated stack Refactor the old handler trait so it is more generic and can be used for specific kinds of handlers
parent: tbd commit: 90c4780
1 | |
2 | pub use *; |
3 | |
4 | pub use *; |
5 | |
6 | |
7 | pub use *; |
8 | |
9 | use ; |
10 | pub use *; |
11 | pub use *; |
12 | |
13 | |
14 | |
15 | use ; |
16 | |
17 | use Debug; |
18 | use |
19 | , |
20 | |
21 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
22 | , |
23 | , | GiteratedObject
24 | , | ObjectBackend
25 | , | GiteratedOperation
26 | , |
27 | , |
28 | , | User
29 | , |
30 | ; |
31 | |
32 | |
33 | |
34 | pub object_name: &'a str, |
35 | pub operation_name: &'a str, |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | Self |
42 | object_name: object_name, |
43 | operation_name: operation_name, |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | |
50 | pub object_kind: &'a str, |
51 | pub value_kind: &'a str, |
52 | |
53 | |
54 | |
55 | |
56 | Self |
57 | object_kind: object_name, |
58 | value_kind: value_name, |
59 | |
60 | |
61 | |
62 | |
63 | |
64 | |
65 | pub object_kind: &'a str, |
66 | pub setting_name: &'a str, |
67 | |
68 | |
69 | |
70 | |
71 | Self |
72 | object_kind: object_name, |
73 | setting_name: name, |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | |
80 | type Error: ; |
81 | |
82 | async |
83 | object: &O, |
84 | operation: &D, |
85 | state: &StackOperationState, |
86 | ; |
87 | |
88 | |
89 | |
90 | |
91 | for StackOperationState |
92 | |
93 | type Error = Infallible; |
94 | |
95 | async |
96 | _object: &O, |
97 | _operation: &D, |
98 | state: &StackOperationState, |
99 | |
100 | Ok |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | ; |
107 | |
108 | |
109 | |
110 | for AuthenticatedUser |
111 | |
112 | type Error = MissingValue; |
113 | |
114 | async |
115 | _object: &O, |
116 | _operation: &D, |
117 | state: &StackOperationState, |
118 | |
119 | state.user.clone .ok_or |
120 | |
121 | |
122 | |
123 | |
124 | |
125 | for AuthenticatedInstance |
126 | |
127 | type Error = MissingValue; |
128 | |
129 | async |
130 | _object: &O, |
131 | _operation: &D, |
132 | state: &StackOperationState, |
133 | |
134 | state.instance.clone .ok_or |
135 | |
136 | |
137 | |
138 | |
139 | |
140 | T: + Send + Sync, |
141 | O: GiteratedObject + Sync, |
142 | D: + Send + Sync, |
143 | > |
144 | |
145 | type Error = Infallible; |
146 | |
147 | async |
148 | object: &O, |
149 | operation: &D, |
150 | state: &StackOperationState, |
151 | |
152 | Ok |
153 | |
154 | |
155 | |
156 | |
157 | ; |
158 | |
159 | |
160 | ; |
161 | |
162 | |
163 | |
164 | type Error: ; |
165 | |
166 | async |
167 | &self, |
168 | authorize_for: &O, |
169 | state: &StackOperationState, |
170 | ; |
171 | |
172 | |
173 | |
174 | |
175 | type Error = Error; |
176 | |
177 | async |
178 | &self, |
179 | authorize_for: &O, |
180 | operation_state: &StackOperationState, |
181 | |
182 | Ok |
183 | .runtime |
184 | . |
185 | .await |
186 | .is_ok |
187 | |
188 | |
189 | |
190 | |
191 | |
192 | type Error = MissingValue; |
193 | |
194 | async |
195 | &self, |
196 | authorize_for: &User, |
197 | operation_state: &StackOperationState, |
198 | |
199 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
200 | |
201 | Ok |
202 | |
203 | |
204 | |
205 | |
206 | |
207 | type Error = MissingValue; |
208 | |
209 | async |
210 | &self, |
211 | authorize_for: &User, |
212 | operation_state: &StackOperationState, |
213 | |
214 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
215 | |
216 | Ok |
217 | |
218 | |
219 | |
220 | |
221 | |
222 | type Error = Error; |
223 | |
224 | async |
225 | &self, |
226 | authorize_for: &Repository, |
227 | operation_state: &StackOperationState, |
228 | |
229 | let authenticated_user = operation_state |
230 | .user |
231 | .as_ref |
232 | .ok_or_else?; |
233 | |
234 | let mut object = operation_state |
235 | .runtime |
236 | . |
237 | .await |
238 | .map_err?; |
239 | |
240 | let access_list = object |
241 | . |
242 | .await |
243 | .map_err?; |
244 | |
245 | if access_list |
246 | .0 |
247 | .iter |
248 | .any |
249 | |
250 | Ok |
251 | else |
252 | Ok |
253 | |
254 | |
255 | |
256 | |
257 | |
258 | |
259 | type Error = Error; |
260 | |
261 | async |
262 | &self, |
263 | authorize_for: &Repository, |
264 | operation_state: &StackOperationState, |
265 | |
266 | let authenticated_user = operation_state |
267 | .user |
268 | .as_ref |
269 | .ok_or_else?; |
270 | |
271 | let mut object = operation_state |
272 | .runtime |
273 | . |
274 | .await |
275 | .map_err?; |
276 | |
277 | let access_list = object |
278 | . |
279 | .await |
280 | .map_err?; |
281 | |
282 | if access_list |
283 | .0 |
284 | .iter |
285 | .any |
286 | |
287 | Ok |
288 | else |
289 | Ok |
290 | |
291 | |
292 | |
293 | |
294 | |
295 | |
296 | type Error = Infallible; |
297 | |
298 | async |
299 | &self, |
300 | authorize_for: &Instance, |
301 | state: &StackOperationState, |
302 | |
303 | if state.our_instance == *authorize_for |
304 | Ok |
305 | else |
306 | Ok |
307 | |
308 | |
309 | |
310 | |
311 | |
312 | |
313 | type Error = Infallible; |
314 | |
315 | async |
316 | &self, |
317 | authorize_for: &Instance, |
318 | state: &StackOperationState, |
319 | |
320 | if state.our_instance == *authorize_for |
321 | Ok |
322 | else |
323 | Ok |
324 | |
325 | |
326 | |
327 | |
328 | |
329 | |
330 | type Error = Infallible; |
331 | |
332 | async |
333 | &self, |
334 | authorize_for: &Instance, |
335 | state: &StackOperationState, |
336 | |
337 | if state.our_instance == *authorize_for |
338 | Ok |
339 | else |
340 | Ok |
341 | |
342 | |
343 | |
344 | |
345 | |
346 | |
347 | type Error = UnauthorizedError; |
348 | |
349 | async |
350 | object: &User, |
351 | operation: &A, |
352 | state: &StackOperationState, |
353 | |
354 | // TODO |
355 | let authenticated = from_state |
356 | .await |
357 | .map_err?; |
358 | |
359 | match operation.authorize .await |
360 | Ok => |
361 | assert!; |
362 | |
363 | Err => return Err, |
364 | ; |
365 | |
366 | Ok |
367 | |
368 | |
369 | |
370 | |
371 | |
372 | for AuthorizedInstance |
373 | |
374 | type Error = UnauthorizedError; |
375 | |
376 | async |
377 | object: &Instance, |
378 | operation: &A, |
379 | state: &StackOperationState, |
380 | |
381 | //TODO |
382 | let authenticated = from_state |
383 | .await |
384 | .map_err?; |
385 | |
386 | match operation.authorize .await |
387 | Ok => |
388 | assert!; |
389 | |
390 | Err => return Err, |
391 | ; |
392 | |
393 | Ok |
394 | |
395 | |
396 | |
397 | |
398 | |
399 | pub our_instance: Instance, |
400 | pub runtime: , |
401 | pub instance: , |
402 | pub user: , |
403 | |
404 | |
405 | |
406 | ; |
407 | |
408 | |
409 | |
410 | AuthenticatedInstance |
411 | |
412 | |
413 | |
414 | |
415 | type Target = Instance; |
416 | |
417 | |
418 | &self.0 |
419 | |
420 | |
421 | |
422 | |
423 | ; |
424 | |
425 | |
426 | |
427 | AuthenticatedUser |
428 | |
429 | |
430 | |
431 | |
432 | type Target = User; |
433 | |
434 | |
435 | &self.0 |
436 | |
437 | |
438 | |
439 | |
440 | |
441 | |
442 | ; |
443 | |
444 | |
445 | |
446 | O: GiteratedObject, |
447 | S: Setting + Serialize + DeserializeOwned, |
448 | |
449 | type Success = ; |
450 | |
451 | type Failure = ; |
452 | |
453 | |
454 | |
455 | ; |
456 | |
457 | |
458 | ; |
459 | |
460 | |
461 | ; |
462 | |
463 | |
464 | ; |
465 | |
466 | |
467 | ; |
468 | |
469 | |
470 | ; |
471 |