`giterated_cache` initial implementation
# Giterated Stack - Added the ability for dynamic substack handlers to exist for operations relevant to caching. - Added type metadata to the dynamic types. # Giterated Cache - Created - Implemented caching and fetching from cache. Hell fucking yes!!!! It works so good. Are you snooping in the commit logs because you're curious about the history of giterated? Cool that it got so big... tell me I say hi :)
parent: tbd commit: 86afeef
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 | inner: , |
457 | kind: &'static str, |
458 | |
459 | |
460 | |
461 | |
462 | Self |
463 | inner: new as _, |
464 | kind: object_name, |
465 | |
466 | |
467 | |
468 | |
469 | todo! |
470 | |
471 | |
472 | |
473 | self.kind |
474 | |
475 | |
476 | |
477 | |
478 | type Target = dyn Any + Send + Sync; |
479 | |
480 | |
481 | self.inner.as_ref |
482 | |
483 | |
484 | |
485 | |
486 | |
487 | inner: , |
488 | kind: , |
489 | |
490 | |
491 | |
492 | |
493 | Self |
494 | inner: new as _, |
495 | kind: , |
496 | |
497 | |
498 | |
499 | |
500 | _operation: , |
501 | _kind: , |
502 | |
503 | todo! |
504 | |
505 | |
506 | |
507 | self.kind |
508 | |
509 | |
510 | |
511 | |
512 | type Target = dyn Any + Send + Sync; |
513 | |
514 | |
515 | self.inner.as_ref |
516 | |
517 | |
518 | |
519 | |
520 | |
521 | inner: , |
522 | kind: , |
523 | |
524 | |
525 | |
526 | |
527 | value: V, |
528 | |
529 | Self |
530 | inner: new as _, |
531 | kind: , |
532 | |
533 | |
534 | |
535 | |
536 | todo! |
537 | |
538 | |
539 | |
540 | self.kind |
541 | |
542 | |
543 | |
544 | |
545 | type Target = dyn Any + Send + Sync; |
546 | |
547 | |
548 | self.inner.as_ref |
549 | |
550 | |
551 | |
552 | |
553 | |
554 | inner: , |
555 | kind: , |
556 | |
557 | |
558 | |
559 | |
560 | Self |
561 | inner: new as _, |
562 | kind: , |
563 | |
564 | |
565 | |
566 | |
567 | _setting: , |
568 | _kind: , |
569 | |
570 | todo! |
571 | |
572 | |
573 | |
574 | self.kind |
575 | |
576 | |
577 | |
578 | |
579 | type Target = dyn Any + Send + Sync; |
580 | |
581 | |
582 | self.inner.as_ref |
583 | |
584 | |
585 | |
586 | |
587 | ; |
588 | |
589 | |
590 | ; |
591 | |
592 | /// Should be renamed. |
593 | /// |
594 | /// Allows accepting object types that are either GiteratedObject types or |
595 | /// AnyObject. |
596 | |
597 | ; |
598 | |
599 | ; |
600 | |
601 | |
602 | |
603 | |
604 | todo! |
605 | |
606 | |
607 | |
608 | <O as GiteratedObject> object_name |
609 | |
610 | |
611 | |
612 | |
613 | |
614 | object.clone |
615 | |
616 | |
617 | |
618 | "any" |
619 | |
620 | |
621 | |
622 | |
623 | ; |
624 | ; |
625 | ; |
626 | |
627 | ; |
628 | |
629 | |
630 | |
631 | |
632 | todo! |
633 | |
634 | |
635 | |
636 | todo! |
637 | |
638 | |
639 | |
640 | todo! |
641 | |
642 | |
643 | |
644 | todo! |
645 | |
646 | |
647 | |
648 | |
649 | |
650 | "any" |
651 | |
652 | |
653 | |
654 | value.clone |
655 | |
656 | |
657 | |
658 | self |
659 | |
660 | |
661 | |
662 | todo! |
663 | |
664 | |
665 |