Major refactor to handler traits
Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Squashed commit of the following: commit 62e1ecf76ee31cda0bab4602d9d00fa0dc2f9158 Author: Amber <[email protected]> Date: Wed Oct 11 09:31:11 2023 -0500 Update commit dfd2d1b0b5d81ee3bc48f0321c6aceaa677e3b8b Author: Amber <[email protected]> Date: Wed Oct 11 09:31:07 2023 -0500 Major refactor to handler traits Added `IntoGiteratedHandler`, which is the new trait for handler functions. This allows us to finally get rid of the Object and ObjectOperation bounds that resulted in hacks around the newer features of the unified stack. Removed dead and legacy code. I think... commit 57b4b398eff32e69f2f4b9700e42a1277a4d1055 Author: Amber <[email protected]> Date: Sun Oct 1 23:05:10 2023 -0500 New handler trait for giterated stack Refactor the old handler trait so it is more generic and can be used for specific kinds of handlers
parent: tbd commit: 90c4780
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 | F: 'static, |
127 | N: 'static, |
128 | P: 'static, |
129 | O: 'static, |
130 | |
131 | let func = new; |
132 | let predicate = new; |
133 | HandlerWrapper |
134 | func: new |
135 | move |args: N, |
136 | state: , |
137 | operation_state: StackOperationState| |
138 | let predicate_output = predicate; |
139 | let func = func.clone; |
140 | let operation_state: StackOperationState = operation_state.clone; |
141 | async move |
142 | let predicate_output = predicate_output?; |
143 | let operation_state = operation_state; |
144 | match .await |
145 | Ok => Ok, |
146 | Err => todo!, |
147 | |
148 | |
149 | .boxed_local |
150 | , |
151 | , |
152 | state: self.state, |
153 | |
154 | |
155 | |
156 | |
157 | |
158 | F: Fn( , &StackOperationState) -> |
159 | + Clone |
160 | + Send |
161 | + Sync, |
162 | O: 'static, |
163 | F: 'static, |
164 | E: 'static, |
165 | P: 'static, |
166 | |
167 | let predicate = new; |
168 | let func = self.func; |
169 | HandlerWrapper |
170 | func: new |
171 | move |args: P, |
172 | state: , |
173 | operation_state: StackOperationState| |
174 | let clone = predicate.clone; |
175 | let func = func.clone; |
176 | let _statoperation_statee = operation_state.clone; |
177 | |
178 | async move |
179 | let func = func.clone; |
180 | let clone = clone; |
181 | let operation_state = operation_state; |
182 | clone |
183 | , | .await
184 | &operation_state, |
185 | |
186 | |
187 | .boxed_local |
188 | , |
189 | , |
190 | state: self.state, |
191 | |
192 | |
193 | |
194 | |
195 | |
196 | |
197 | type Error; |
198 | |
199 | async |
200 | required_parameters: &RequiredParameters, |
201 | operation_state: &OperationState, |
202 | ; |
203 | |
204 | |
205 | |
206 | |
207 | type Error = MissingValue; |
208 | |
209 | async |
210 | _required_parameters: &R, |
211 | operation_state: &StackOperationState, |
212 | |
213 | Ok |
214 | |
215 | |
216 | |
217 | |
218 | |
219 | type Error = MissingValue; |
220 | |
221 | async |
222 | _required_parameters: &R, |
223 | operation_state: &StackOperationState, |
224 | |
225 | operation_state.user.clone .ok_or_else |
226 | |
227 | |
228 | |
229 | |
230 | |
231 | type Error = MissingValue; |
232 | |
233 | async |
234 | _required_parameters: &R, |
235 | operation_state: &StackOperationState, |
236 | |
237 | operation_state.instance.clone .ok_or_else |
238 | |
239 | |
240 |