Begin new protocol refactor
parent: tbd commit: 26651b1
1 | use ; |
2 | |
3 | use |
4 | , | OperationError
5 | , |
6 | , |
7 | ; |
8 | use PgPool; |
9 | use Debug; |
10 | use Mutex; |
11 | |
12 | use crate; |
13 | |
14 | |
15 | |
16 | |
17 | |
18 | |
19 | async |
20 | &self, |
21 | _object: O, |
22 | _operation: D, |
23 | |
24 | // We don't handle operations with this backend |
25 | Err |
26 | |
27 | |
28 | async |
29 | &self, |
30 | _object_str: &str, |
31 | |
32 | todo! |
33 | |
34 | |
35 | |
36 | /// A backend implementation which attempts to resolve data from the instance's database. |
37 | |
38 | |
39 | our_instance: , |
40 | user_backend: , |
41 | repository_backend: , |
42 | pool: PgPool, |
43 | |
44 | |
45 | |
46 | |
47 | f.debug_struct .finish |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | async |
54 | &self, |
55 | _object: O, |
56 | _operation: D, |
57 | |
58 | // We don't handle operations with this backend |
59 | Err |
60 | |
61 | |
62 | async |
63 | &self, |
64 | object_str: &str, |
65 | |
66 | if let Ok = from_str |
67 | let mut user_backend = self.user_backend.lock .await; |
68 | |
69 | if user_backend |
70 | .exists |
71 | .await |
72 | .map_err? |
73 | |
74 | Ok |
75 | new_unchecked |
76 | from_object_str |
77 | .map_err?, |
78 | self.clone, |
79 | |
80 | |
81 | else |
82 | return Err; |
83 | |
84 | else if let Ok = from_str |
85 | let mut repository_backend = self.repository_backend.lock .await; |
86 | |
87 | if repository_backend |
88 | .exists |
89 | .await |
90 | .map_err? |
91 | |
92 | Ok |
93 | new_unchecked |
94 | from_object_str |
95 | .map_err?, |
96 | self.clone, |
97 | |
98 | |
99 | else |
100 | return Err; |
101 | |
102 | else if from_str .is_ok |
103 | return Err; |
104 | else |
105 | // Invalid object type |
106 | return Err; |
107 | |
108 | |
109 | |
110 |