Progress on refactor
parent: tbd commit: c9f076f
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , |
7 | , |
8 | , |
9 | ; |
10 | |
11 | use DatabaseBackend; |
12 | |
13 | |
14 | |
15 | O: GiteratedObject, |
16 | D: GiteratedOperation<O>, |
17 | S: Send + Sync + Clone, |
18 | > |
19 | |
20 | ; |
21 | ; |
22 | |
23 | async |
24 | &self, |
25 | object: &O, |
26 | operation: D, |
27 | state: S, |
28 | ; |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | F: FnMut( |
35 | &O, |
36 | D, |
37 | S, |
38 | ) -> |
39 | , |
40 | > + Send |
41 | + Sync |
42 | + Clone, |
43 | O: GiteratedObject + Send + Sync, |
44 | D: + 'static, |
45 | : Send, | Failure
46 | S: Send + Sync + Clone + 'static, |
47 | |
48 | |
49 | operation_name |
50 | |
51 | |
52 | |
53 | object_name |
54 | |
55 | |
56 | async |
57 | &self, |
58 | object: &O, |
59 | operation: D, |
60 | state: S, |
61 | |
62 | self.clone .await |
63 | |
64 | |
65 | |
66 | |
67 | |
68 | dyn Fn( |
69 | AnyObject, |
70 | AnyOperation, |
71 | S, |
72 | ) |
73 | |
74 | + Send |
75 | + Sync, |
76 | >, |
77 | ); |
78 | |
79 | |
80 | |
81 | O: GiteratedObject + Send + Sync, |
82 | D: + 'static, |
83 | F: + Send + Sync + 'static + Clone, |
84 | > |
85 | handler: F, |
86 | |
87 | let handler = new; |
88 | Self |
89 | let handler = handler.clone; |
90 | async move |
91 | let handler = handler.clone; |
92 | let object: O = from_object_str .unwrap; |
93 | let operation: D = from_value .unwrap; |
94 | |
95 | let result = handler.handle .await; |
96 | result |
97 | .map |
98 | .map_err |
99 | => | Operation
100 | Operation |
101 | |
102 | => Internal, | Internal
103 | => Unhandled, | Unhandled
104 | |
105 | |
106 | .boxed |
107 | |
108 | |
109 | |
110 | async |
111 | &mut self, |
112 | object: AnyObject, |
113 | operation: AnyOperation, |
114 | state: S, |
115 | |
116 | self.0 .await |
117 | |
118 | |
119 | |
120 | |
121 | _object: &User, |
122 | _operation: , |
123 | _state: , |
124 | |
125 | todo! |
126 | |
127 | |
128 | |
129 | |
130 | |
131 | object: &User, |
132 | operation: , |
133 | state: DatabaseBackend, |
134 | |
135 | let object = object.clone; |
136 | |
137 | async move |
138 | let mut user_backend = state.user_backend.lock .await; |
139 | let value = user_backend |
140 | .get_value |
141 | .await |
142 | .map_err?; |
143 | |
144 | Ok |
145 | |
146 | .boxed |
147 | |
148 | |
149 | |
150 | _object: &User, |
151 | _operation: , |
152 | _state: DatabaseBackend, |
153 | |
154 | todo! |
155 | |
156 | |
157 | |
158 | _object: &User, |
159 | _operation: , |
160 | _state: DatabaseBackend, |
161 | |
162 | todo! |
163 | |
164 | |
165 | |
166 | _object: &Repository, |
167 | _operation: , |
168 | _state: DatabaseBackend, |
169 | |
170 | todo! |
171 | |
172 | |
173 | |
174 | _object: &Repository, |
175 | _operation: , |
176 | _state: DatabaseBackend, |
177 | |
178 | todo! |
179 | |
180 | |
181 | |
182 | _object: &Repository, |
183 | _operation: , |
184 | _state: DatabaseBackend, |
185 | |
186 | todo! |
187 | |
188 | |
189 | |
190 | operations: , |
191 | |
192 | |
193 | |
194 | |
195 | Self |
196 | operations: new, |
197 | |
198 | |
199 | |
200 | |
201 | |
202 | |
203 | O: GiteratedObject + Send + Sync, |
204 | D: + 'static, |
205 | H: + Send + Sync + 'static + Clone, |
206 | > |
207 | &mut self, |
208 | handler: H, |
209 | |
210 | let operation_name = handler.operation_name .to_string; |
211 | |
212 | let wrapped = new; |
213 | |
214 | self.operations.insert; |
215 | |
216 | self |
217 | |
218 | |
219 | pub async |
220 | &mut self, |
221 | object: &O, |
222 | operation_name: &str, |
223 | operation: AnyOperation, |
224 | state: S, |
225 | |
226 | if let Some = self.operations.get_mut |
227 | handler |
228 | .handle |
229 | AnyObject, |
230 | operation, |
231 | state, |
232 | |
233 | .await |
234 | else |
235 | panic! |
236 | |
237 | |
238 | |
239 |