Remove unwrap statements and return OperationError's
parent: tbd commit: cf491a4
1 | use ; |
2 | |
3 | use ; |
4 | use OperationError; |
5 | |
6 | use crate:: |
7 | AuthenticatedInstance, AuthenticatedUser, GiteratedStack, MissingValue, StackOperationState, |
8 | ; |
9 | |
10 | |
11 | |
12 | where |
13 | // Output cannot have non-static references |
14 | Output: 'static, |
15 | |
16 | type Future: ; |
17 | |
18 | async ; |
19 | |
20 | |
21 | |
22 | elements: , |
23 | |
24 | |
25 | |
26 | |
27 | Self |
28 | elements: Default default, |
29 | |
30 | |
31 | |
32 | |
33 | |
34 | |
35 | P: Clone, |
36 | |
37 | |
38 | self.elements.push; |
39 | |
40 | pub async |
41 | &self, |
42 | parameters: P, |
43 | operation_state: StackOperationState, |
44 | |
45 | for handler in self.elements.iter |
46 | match handler |
47 | .handle |
48 | .await |
49 | |
50 | Ok => return Ok, |
51 | Err => match err |
52 | => return Err, | Internal
53 | => return Err, | Operation
54 | => continue, | Unhandled
55 | , |
56 | |
57 | |
58 | |
59 | Err |
60 | |
61 | |
62 | |
63 | |
64 | func: |
65 | dyn Fn( |
66 | P, |
67 | , |
68 | StackOperationState, |
69 | ) -> |
70 | + Send |
71 | + Sync, |
72 | >, |
73 | state: , |
74 | |
75 | |
76 | |
77 | |
78 | |
79 | F: |
80 | + Send |
81 | + Sync, |
82 | S: Send + Sync + Clone + 'static, |
83 | E: 'static, |
84 | P: 'static + Clone, |
85 | F: 'static, |
86 | O: 'static, |
87 | |
88 | let state = new; |
89 | |
90 | let handler_func = new; |
91 | let state_two = state.clone; |
92 | HandlerWrapper |
93 | func: new |
94 | move |args: P, |
95 | state: , |
96 | operation_state: StackOperationState| |
97 | let handler = handler_func.clone; |
98 | let operation_state = operation_state.clone; |
99 | let state = state. .unwrap; |
100 | let state = state.clone; |
101 | async move |
102 | let handler = handler.clone; |
103 | let operation_state = operation_state; |
104 | handler.handle .await |
105 | |
106 | .boxed_local |
107 | , |
108 | , |
109 | state: state_two, |
110 | |
111 | |
112 | |
113 | pub async |
114 | &self, |
115 | required: P, |
116 | operation_state: StackOperationState, |
117 | |
118 | .await |
119 | |
120 | |
121 | |
122 | |
123 | F: Fn(&N, &StackOperationState) -> + Clone + Send + Sync, |
124 | R: Debug + 'static, |
125 | E: + 'static, |
126 | : + 'static, |
127 | F: 'static, |
128 | N: 'static, |
129 | P: 'static, |
130 | O: 'static, |
131 | |
132 | let func = new; |
133 | let predicate = new; |
134 | HandlerWrapper |
135 | func: new |
136 | move |args: N, |
137 | state: , |
138 | operation_state: StackOperationState| |
139 | let predicate_output = predicate; |
140 | let func = func.clone; |
141 | let operation_state: StackOperationState = operation_state.clone; |
142 | async move |
143 | let predicate_output = predicate_output?; |
144 | let operation_state = operation_state; |
145 | match .await |
146 | Ok => Ok, |
147 | Err => Err, |
148 | |
149 | |
150 | .boxed_local |
151 | , |
152 | , |
153 | state: self.state, |
154 | |
155 | |
156 | |
157 | |
158 | |
159 | F: Fn( , &StackOperationState) -> |
160 | + Clone |
161 | + Send |
162 | + Sync, |
163 | O: 'static, |
164 | F: 'static, |
165 | E: 'static, |
166 | P: 'static, |
167 | |
168 | let predicate = new; |
169 | let func = self.func; |
170 | HandlerWrapper |
171 | func: new |
172 | move |args: P, |
173 | state: , |
174 | operation_state: StackOperationState| |
175 | let clone = predicate.clone; |
176 | let func = func.clone; |
177 | let _statoperation_statee = operation_state.clone; |
178 | |
179 | async move |
180 | let func = func.clone; |
181 | let clone = clone; |
182 | let operation_state = operation_state; |
183 | clone |
184 | , | .await
185 | &operation_state, |
186 | |
187 | |
188 | .boxed_local |
189 | , |
190 | , |
191 | state: self.state, |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | |
198 | type Error; |
199 | |
200 | async |
201 | required_parameters: &RequiredParameters, |
202 | operation_state: &OperationState, |
203 | ; |
204 | |
205 | |
206 | |
207 | |
208 | type Error = MissingValue; |
209 | |
210 | async |
211 | _required_parameters: &R, |
212 | operation_state: &StackOperationState, |
213 | |
214 | Ok |
215 | |
216 | |
217 | |
218 | |
219 | |
220 | type Error = MissingValue; |
221 | |
222 | async |
223 | _required_parameters: &R, |
224 | operation_state: &StackOperationState, |
225 | |
226 | operation_state.user.clone .ok_or_else |
227 | |
228 | |
229 | |
230 | |
231 | |
232 | type Error = MissingValue; |
233 | |
234 | async |
235 | _required_parameters: &R, |
236 | operation_state: &StackOperationState, |
237 | |
238 | operation_state.instance.clone .ok_or_else |
239 | |
240 | |
241 |