Fixes
parent: tbd commit: b87f0a3
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , |
7 | , |
8 | , |
9 | , |
10 | , |
11 | , |
12 | ; |
13 | |
14 | use DatabaseBackend; |
15 | |
16 | |
17 | |
18 | O: GiteratedObject, |
19 | D: GiteratedOperation<O>, |
20 | S: Send + Sync + Clone, |
21 | > |
22 | |
23 | ; |
24 | ; |
25 | |
26 | async |
27 | &self, |
28 | object: &O, |
29 | operation: D, |
30 | state: S, |
31 | ; |
32 | |
33 | |
34 | |
35 | |
36 | |
37 | F: FnMut( |
38 | &O, |
39 | D, |
40 | S, |
41 | ) -> |
42 | , |
43 | > + Send |
44 | + Sync |
45 | + Clone, |
46 | O: GiteratedObject + Send + Sync, |
47 | D: + 'static, |
48 | : Send, | Failure
49 | S: Send + Sync + Clone + 'static, |
50 | |
51 | |
52 | operation_name |
53 | |
54 | |
55 | |
56 | object_name |
57 | |
58 | |
59 | async |
60 | &self, |
61 | object: &O, |
62 | operation: D, |
63 | state: S, |
64 | |
65 | self.clone .await |
66 | |
67 | |
68 | |
69 | |
70 | |
71 | dyn Fn( |
72 | AnyObject, |
73 | AnyOperation, |
74 | S, |
75 | ) |
76 | |
77 | + Send |
78 | + Sync, |
79 | >, |
80 | ); |
81 | |
82 | |
83 | |
84 | O: GiteratedObject + Send + Sync, |
85 | D: + 'static, |
86 | F: + Send + Sync + 'static + Clone, |
87 | > |
88 | handler: F, |
89 | |
90 | let handler = new; |
91 | Self |
92 | let handler = handler.clone; |
93 | async move |
94 | let handler = handler.clone; |
95 | let object: O = from_object_str .unwrap; |
96 | let operation: D = from_value .unwrap; |
97 | |
98 | let result = handler.handle .await; |
99 | result |
100 | .map |
101 | .map_err |
102 | => | Operation
103 | Operation |
104 | |
105 | => Internal, | Internal
106 | => Unhandled, | Unhandled
107 | |
108 | |
109 | .boxed |
110 | |
111 | |
112 | |
113 | async |
114 | &mut self, |
115 | object: AnyObject, |
116 | operation: AnyOperation, |
117 | state: S, |
118 | |
119 | self.0 .await |
120 | |
121 | |
122 | |
123 | |
124 | object: &User, |
125 | operation: UserRepositoriesRequest, |
126 | state: DatabaseBackend, |
127 | |
128 | let object = object.clone; |
129 | |
130 | async move |
131 | let mut repositories_backend = state.repository_backend.lock .await; |
132 | let repositories = repositories_backend |
133 | .repositories_for_user |
134 | .await |
135 | .map_err?; |
136 | |
137 | Ok |
138 | |
139 | .boxed |
140 | |
141 | |
142 | |
143 | object: &User, |
144 | operation: , |
145 | state: DatabaseBackend, |
146 | |
147 | let object = object.clone; |
148 | |
149 | async move |
150 | let mut user_backend = state.user_backend.lock .await; |
151 | let value = user_backend |
152 | .get_value |
153 | .await |
154 | .map_err?; |
155 | |
156 | Ok |
157 | |
158 | .boxed |
159 | |
160 | |
161 | |
162 | object: &User, |
163 | operation: , |
164 | state: DatabaseBackend, |
165 | |
166 | let object = object.clone; |
167 | |
168 | async move |
169 | let mut user_backend = state.user_backend.lock .await; |
170 | let value = user_backend |
171 | .get_setting |
172 | .await |
173 | .map_err?; |
174 | |
175 | Ok |
176 | |
177 | .boxed |
178 | |
179 | |
180 | |
181 | object: &User, |
182 | operation: , |
183 | state: DatabaseBackend, |
184 | |
185 | let object = object.clone; |
186 | |
187 | async move |
188 | let mut user_backend = state.user_backend.lock .await; |
189 | let value = user_backend |
190 | .write_setting |
191 | .await |
192 | .map_err?; |
193 | |
194 | Ok |
195 | |
196 | .boxed |
197 | |
198 | |
199 | |
200 | object: &Repository, |
201 | operation: , |
202 | state: DatabaseBackend, |
203 | |
204 | let object = object.clone; |
205 | |
206 | async move |
207 | let mut repository_backend = state.repository_backend.lock .await; |
208 | let value = repository_backend |
209 | .get_value |
210 | .await |
211 | .map_err?; |
212 | |
213 | Ok |
214 | |
215 | .boxed |
216 | |
217 | |
218 | |
219 | object: &Repository, |
220 | operation: , |
221 | state: DatabaseBackend, |
222 | |
223 | let object = object.clone; |
224 | |
225 | async move |
226 | let mut repository_backend = state.repository_backend.lock .await; |
227 | let value = repository_backend |
228 | .get_setting |
229 | .await |
230 | .map_err?; |
231 | |
232 | Ok |
233 | |
234 | .boxed |
235 | |
236 | |
237 | |
238 | object: &Repository, |
239 | operation: , |
240 | state: DatabaseBackend, |
241 | |
242 | let object = object.clone; |
243 | |
244 | async move |
245 | let mut repository_backend = state.repository_backend.lock .await; |
246 | let value = repository_backend |
247 | .write_setting |
248 | .await |
249 | .map_err?; |
250 | |
251 | Ok |
252 | |
253 | .boxed |
254 | |
255 | |
256 | |
257 | operations: , |
258 | |
259 | |
260 | |
261 | |
262 | Self |
263 | operations: new, |
264 | |
265 | |
266 | |
267 | |
268 | |
269 | |
270 | O: GiteratedObject + Send + Sync, |
271 | D: + 'static, |
272 | H: + Send + Sync + 'static + Clone, |
273 | > |
274 | &mut self, |
275 | handler: H, |
276 | |
277 | let operation_name = handler.operation_name .to_string; |
278 | |
279 | let wrapped = new; |
280 | |
281 | self.operations.insert; |
282 | |
283 | self |
284 | |
285 | |
286 | pub async |
287 | &mut self, |
288 | object: &O, |
289 | operation_name: &str, |
290 | operation: AnyOperation, |
291 | state: S, |
292 | |
293 | if let Some = self.operations.get_mut |
294 | handler |
295 | .handle |
296 | .await |
297 | else |
298 | Err |
299 | "unknown operation: {}" |
300 | operation_name |
301 | ) |
302 | |
303 | |
304 | |
305 |