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