Git repository hosting, collaboration, and discovery for the Fediverse.
Error handling fixes
parent: tbd commit: 5eaea71
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , |
6 | , | OperationError
7 | , |
8 | , | GiteratedMessage
9 | , |
10 | , | ObjectBackend
11 | , | GiteratedOperation
12 | ; |
13 | use DeserializeOwned; |
14 | use Message; |
15 | |
16 | use crate::; |
17 | |
18 | |
19 | |
20 | authentication: , |
21 | |
22 | |
23 | |
24 | |
25 | Self |
26 | authentication: vec!, |
27 | |
28 | |
29 | |
30 | |
31 | &mut self, |
32 | source: S, |
33 | |
34 | self.authentication.push |
35 | |
36 | |
37 | |
38 | |
39 | |
40 | async |
41 | &self, |
42 | object: O, |
43 | operation: &str, |
44 | payload: D, |
45 | operation_state: &NetworkOperationState, |
46 | |
47 | let message = GiteratedMessage |
48 | object, |
49 | operation: operation.to_string, |
50 | payload, |
51 | ; |
52 | |
53 | let mut connection = self.0.get .await.map_err |
54 | Internal |
55 | ?; |
56 | |
57 | let mut authenticated = new; |
58 | for authentication in &operation_state.authentication |
59 | authenticated.append_authentication; |
60 | |
61 | |
62 | send_expect .await |
63 | |
64 | |
65 | async |
66 | &self, |
67 | object_str: &str, |
68 | operation_state: &NetworkOperationState, |
69 | |
70 | let operation = ObjectRequest; |
71 | info!; |
72 | let message = GiteratedMessage |
73 | object: self.0.manager .target_instance.clone, |
74 | operation: operation_name .to_string, |
75 | payload: operation, |
76 | ; |
77 | |
78 | let mut connection = self.0.get .await.map_err |
79 | Internal |
80 | ?; |
81 | |
82 | let mut authenticated = new; |
83 | for authentication in &operation_state.authentication |
84 | authenticated.append_authentication; |
85 | |
86 | |
87 | let object_raw: ObjectResponse = send_expect .await?; |
88 | |
89 | if let Ok = from_str |
90 | Ok |
91 | else |
92 | panic! |
93 | |
94 | |
95 | |
96 | |
97 | async |
98 | O: GiteratedObject, |
99 | D: , |
100 | B: DeserializeOwned, |
101 | R: DeserializeOwned, |
102 | > |
103 | socket: &mut Socket, |
104 | message: , |
105 | |
106 | let payload = serialize .unwrap; |
107 | |
108 | socket |
109 | .send |
110 | .await |
111 | .as_internal_error?; |
112 | |
113 | while let Some = socket.next .await |
114 | let payload = match message.as_internal_error? |
115 | => payload, | Binary
116 | _ => |
117 | continue; |
118 | |
119 | ; |
120 | |
121 | let raw_result = |
122 | |
123 | .map_err?; |
124 | |
125 | // Map ok |
126 | let raw_result = match raw_result |
127 | Ok => Ok |
128 | .map_err?, |
129 | Err => Err |
130 | => Operation | Operation
131 | from_slice |
132 | .map_err?, |
133 | , |
134 | => | Internal
135 | Internal |
136 | |
137 | => Unhandled, | Unhandled
138 | , |
139 | ; |
140 | |
141 | return raw_result; |
142 | |
143 | |
144 | panic! |
145 | |
146 | |
147 | |
148 | |
149 | ; |
150 | |
151 | |
152 | |
153 | ; |
154 |