Create `NetworkedSubstack`.
# giterated-protocol - Create `NetworkedSubstack` which will handle all networked operations giterated needs - Add support for `NetworkedSubstack` for both the daemon and client - Pipe everything through but leave APIs temp # `giterated-daemon` - Remove a bunch of random old code, dead code, and files that aren't needed. - Moved all connection handling to `client.rs`, simplified connection logic with new types
parent: tbd commit: 202bb12
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 | // Temp pub use to figure out what's important |
16 | |
17 | pub use Error; |
18 | pub use ; |
19 | pub use GiteratedObject; |
20 | pub use GiteratedOperation; |
21 | |
22 | |
23 | use ; |
24 | |
25 | use Debug; |
26 | use |
27 | , |
28 | |
29 | AuthenticationTokenRequest, Instance, RegisterAccountRequest, RepositoryCreateRequest, |
30 | , |
31 | , | GiteratedObject
32 | , | ObjectBackend
33 | , | GiteratedOperation
34 | , |
35 | , |
36 | , | User
37 | , |
38 | ; |
39 | |
40 | |
41 | |
42 | pub object_name: &'a str, |
43 | pub operation_name: &'a str, |
44 | |
45 | |
46 | |
47 | |
48 | |
49 | Self |
50 | object_name: object_name, |
51 | operation_name: operation_name, |
52 | |
53 | |
54 | |
55 | |
56 | |
57 | |
58 | pub object_kind: &'a str, |
59 | pub value_kind: &'a str, |
60 | |
61 | |
62 | |
63 | |
64 | Self |
65 | object_kind: object_name, |
66 | value_kind: value_name, |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | |
73 | pub object_kind: &'a str, |
74 | pub setting_name: &'a str, |
75 | |
76 | |
77 | |
78 | |
79 | Self |
80 | object_kind: object_name, |
81 | setting_name: name, |
82 | |
83 | |
84 | |
85 | |
86 | |
87 | |
88 | type Error: ; |
89 | |
90 | async |
91 | object: &O, |
92 | operation: &D, |
93 | state: &StackOperationState, |
94 | ; |
95 | |
96 | |
97 | |
98 | |
99 | for StackOperationState |
100 | |
101 | type Error = Infallible; |
102 | |
103 | async |
104 | _object: &O, |
105 | _operation: &D, |
106 | state: &StackOperationState, |
107 | |
108 | Ok |
109 | |
110 | |
111 | |
112 | |
113 | |
114 | ; |
115 | |
116 | |
117 | |
118 | for AuthenticatedUser |
119 | |
120 | type Error = MissingValue; |
121 | |
122 | async |
123 | _object: &O, |
124 | _operation: &D, |
125 | state: &StackOperationState, |
126 | |
127 | state.user.clone .ok_or |
128 | |
129 | |
130 | |
131 | |
132 | |
133 | for AuthenticatedInstance |
134 | |
135 | type Error = MissingValue; |
136 | |
137 | async |
138 | _object: &O, |
139 | _operation: &D, |
140 | state: &StackOperationState, |
141 | |
142 | state.instance.clone .ok_or |
143 | |
144 | |
145 | |
146 | |
147 | |
148 | T: + Send + Sync, |
149 | O: GiteratedObject + Sync, |
150 | D: + Send + Sync, |
151 | > |
152 | |
153 | type Error = Infallible; |
154 | |
155 | async |
156 | object: &O, |
157 | operation: &D, |
158 | state: &StackOperationState, |
159 | |
160 | Ok |
161 | |
162 | |
163 | |
164 | |
165 | ; |
166 | |
167 | |
168 | ; |
169 | |
170 | |
171 | |
172 | type Error: ; |
173 | |
174 | async |
175 | &self, |
176 | authorize_for: &O, |
177 | state: &StackOperationState, |
178 | ; |
179 | |
180 | |
181 | |
182 | |
183 | type Error = Error; |
184 | |
185 | async |
186 | &self, |
187 | authorize_for: &O, |
188 | operation_state: &StackOperationState, |
189 | |
190 | Ok |
191 | .runtime |
192 | . |
193 | .await |
194 | .is_ok |
195 | |
196 | |
197 | |
198 | |
199 | |
200 | type Error = MissingValue; |
201 | |
202 | async |
203 | &self, |
204 | authorize_for: &User, |
205 | operation_state: &StackOperationState, |
206 | |
207 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
208 | |
209 | Ok |
210 | |
211 | |
212 | |
213 | |
214 | |
215 | type Error = MissingValue; |
216 | |
217 | async |
218 | &self, |
219 | authorize_for: &User, |
220 | operation_state: &StackOperationState, |
221 | |
222 | let authenticated_user = operation_state.user.as_ref .ok_or?; |
223 | |
224 | Ok |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | type Error = Error; |
231 | |
232 | async |
233 | &self, |
234 | authorize_for: &Repository, |
235 | operation_state: &StackOperationState, |
236 | |
237 | let authenticated_user = operation_state |
238 | .user |
239 | .as_ref |
240 | .ok_or_else?; |
241 | |
242 | let mut object = operation_state |
243 | .runtime |
244 | . |
245 | .await |
246 | .map_err?; |
247 | |
248 | let access_list = object |
249 | . |
250 | .await |
251 | .map_err?; |
252 | |
253 | if access_list |
254 | .0 |
255 | .iter |
256 | .any |
257 | |
258 | Ok |
259 | else |
260 | Ok |
261 | |
262 | |
263 | |
264 | |
265 | |
266 | |
267 | type Error = Error; |
268 | |
269 | async |
270 | &self, |
271 | authorize_for: &Repository, |
272 | operation_state: &StackOperationState, |
273 | |
274 | let authenticated_user = operation_state |
275 | .user |
276 | .as_ref |
277 | .ok_or_else?; |
278 | |
279 | let mut object = operation_state |
280 | .runtime |
281 | . |
282 | .await |
283 | .map_err?; |
284 | |
285 | let access_list = object |
286 | . |
287 | .await |
288 | .map_err?; |
289 | |
290 | if access_list |
291 | .0 |
292 | .iter |
293 | .any |
294 | |
295 | Ok |
296 | else |
297 | Ok |
298 | |
299 | |
300 | |
301 | |
302 | |
303 | |
304 | type Error = Infallible; |
305 | |
306 | async |
307 | &self, |
308 | authorize_for: &Instance, |
309 | state: &StackOperationState, |
310 | |
311 | if state.our_instance == *authorize_for |
312 | Ok |
313 | else |
314 | Ok |
315 | |
316 | |
317 | |
318 | |
319 | |
320 | |
321 | type Error = Infallible; |
322 | |
323 | async |
324 | &self, |
325 | authorize_for: &Instance, |
326 | state: &StackOperationState, |
327 | |
328 | if state.our_instance == *authorize_for |
329 | Ok |
330 | else |
331 | Ok |
332 | |
333 | |
334 | |
335 | |
336 | |
337 | |
338 | type Error = Infallible; |
339 | |
340 | async |
341 | &self, |
342 | authorize_for: &Instance, |
343 | state: &StackOperationState, |
344 | |
345 | if state.our_instance == *authorize_for |
346 | Ok |
347 | else |
348 | Ok |
349 | |
350 | |
351 | |
352 | |
353 | |
354 | |
355 | type Error = UnauthorizedError; |
356 | |
357 | async |
358 | object: &User, |
359 | operation: &A, |
360 | state: &StackOperationState, |
361 | |
362 | // TODO |
363 | let authenticated = from_state |
364 | .await |
365 | .map_err?; |
366 | |
367 | match operation.authorize .await |
368 | Ok => |
369 | assert!; |
370 | |
371 | Err => return Err, |
372 | ; |
373 | |
374 | Ok |
375 | |
376 | |
377 | |
378 | |
379 | |
380 | for AuthorizedInstance |
381 | |
382 | type Error = UnauthorizedError; |
383 | |
384 | async |
385 | object: &Instance, |
386 | operation: &A, |
387 | state: &StackOperationState, |
388 | |
389 | //TODO |
390 | let authenticated = from_state |
391 | .await |
392 | .map_err?; |
393 | |
394 | match operation.authorize .await |
395 | Ok => |
396 | assert!; |
397 | |
398 | Err => return Err, |
399 | ; |
400 | |
401 | Ok |
402 | |
403 | |
404 | |
405 | |
406 | |
407 | pub our_instance: Instance, |
408 | pub runtime: , |
409 | pub instance: , |
410 | pub user: , |
411 | |
412 | |
413 | |
414 | ; |
415 | |
416 | |
417 | |
418 | AuthenticatedInstance |
419 | |
420 | |
421 | |
422 | |
423 | type Target = Instance; |
424 | |
425 | |
426 | &self.0 |
427 | |
428 | |
429 | |
430 | |
431 | ; |
432 | |
433 | |
434 | |
435 | AuthenticatedUser |
436 | |
437 | |
438 | |
439 | |
440 | type Target = User; |
441 | |
442 | |
443 | &self.0 |
444 | |
445 | |
446 | |
447 | |
448 | |
449 | |
450 | ; |
451 | |
452 | |
453 | |
454 | O: GiteratedObject, |
455 | S: Setting + Serialize + DeserializeOwned, |
456 | |
457 | type Success = ; |
458 | |
459 | type Failure = ; |
460 | |
461 | |
462 | |
463 | |
464 | inner: , |
465 | kind: &'static str, |
466 | |
467 | |
468 | |
469 | |
470 | Self |
471 | inner: new as _, |
472 | kind: object_name, |
473 | |
474 | |
475 | |
476 | |
477 | todo! |
478 | |
479 | |
480 | |
481 | self.kind |
482 | |
483 | |
484 | |
485 | |
486 | type Target = dyn Any + Send + Sync; |
487 | |
488 | |
489 | self.inner.as_ref |
490 | |
491 | |
492 | |
493 | |
494 | |
495 | inner: , |
496 | kind: , |
497 | |
498 | |
499 | |
500 | |
501 | Self |
502 | inner: new as _, |
503 | kind: , |
504 | |
505 | |
506 | |
507 | |
508 | _operation: , |
509 | _kind: , |
510 | |
511 | todo! |
512 | |
513 | |
514 | |
515 | self.kind |
516 | |
517 | |
518 | |
519 | |
520 | type Target = dyn Any + Send + Sync; |
521 | |
522 | |
523 | self.inner.as_ref |
524 | |
525 | |
526 | |
527 | |
528 | |
529 | inner: , |
530 | kind: , |
531 | |
532 | |
533 | |
534 | |
535 | value: V, |
536 | |
537 | Self |
538 | inner: new as _, |
539 | kind: , |
540 | |
541 | |
542 | |
543 | |
544 | todo! |
545 | |
546 | |
547 | |
548 | self.kind |
549 | |
550 | |
551 | |
552 | |
553 | type Target = dyn Any + Send + Sync; |
554 | |
555 | |
556 | self.inner.as_ref |
557 | |
558 | |
559 | |
560 | |
561 | |
562 | inner: , |
563 | kind: , |
564 | |
565 | |
566 | |
567 | |
568 | Self |
569 | inner: new as _, |
570 | kind: , |
571 | |
572 | |
573 | |
574 | |
575 | _setting: , |
576 | _kind: , |
577 | |
578 | todo! |
579 | |
580 | |
581 | |
582 | self.kind |
583 | |
584 | |
585 | |
586 | |
587 | type Target = dyn Any + Send + Sync; |
588 | |
589 | |
590 | self.inner.as_ref |
591 | |
592 | |
593 | |
594 | |
595 | ; |
596 | |
597 | |
598 | ; |
599 | |
600 | /// Should be renamed. |
601 | /// |
602 | /// Allows accepting object types that are either GiteratedObject types or |
603 | /// AnyObject. |
604 | |
605 | ; |
606 | |
607 | ; |
608 | |
609 | |
610 | |
611 | |
612 | todo! |
613 | |
614 | |
615 | |
616 | <O as GiteratedObject> object_name |
617 | |
618 | |
619 | |
620 | |
621 | |
622 | object.clone |
623 | |
624 | |
625 | |
626 | "any" |
627 | |
628 | |
629 | |
630 | |
631 | ; |
632 | ; |
633 | ; |
634 | |
635 | ; |
636 | |
637 | |
638 | |
639 | |
640 | todo! |
641 | |
642 | |
643 | |
644 | todo! |
645 | |
646 | |
647 | |
648 | todo! |
649 | |
650 | |
651 | |
652 | todo! |
653 | |
654 | |
655 | |
656 | |
657 | |
658 | "any" |
659 | |
660 | |
661 | |
662 | value.clone |
663 | |
664 | |
665 | |
666 | self |
667 | |
668 | |
669 | |
670 | todo! |
671 | |
672 | |
673 |