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 |
5 | , | GiteratedObject
6 | , | GiteratedOperation
7 | , | Setting
8 | , |
9 | ; |
10 | use Value; |
11 | use trace; |
12 | |
13 | use crate:: |
14 | AnyFailure, AnyObject, AnyOperation, AnySetting, AnySuccess, AnyValue, GiteratedStack, |
15 | ObjectOperationPair, ObjectSettingPair, ObjectValuePair, StackOperationState, |
16 | ; |
17 | |
18 | /// Stores runtime metadata for all in-use Giterated protocol types. |
19 | |
20 | |
21 | pub objects: , |
22 | pub operations: , |
23 | pub values: , |
24 | pub settings: , |
25 | |
26 | |
27 | |
28 | |
29 | let object_name = object_name .to_string; |
30 | |
31 | let object_meta = ; |
32 | |
33 | if self.objects.insert .is_some |
34 | trace! |
35 | "Registration of object {} overwrote previous registration.", |
36 | object_name |
37 | ; |
38 | else |
39 | trace! |
40 | |
41 | |
42 | |
43 | |
44 | &mut self, |
45 | |
46 | let _object_name = object_name .to_string; |
47 | let _operation_name = operation_name .to_string; |
48 | |
49 | if self |
50 | .operations |
51 | .insert |
52 | , |
53 | , |
54 | |
55 | .is_some |
56 | |
57 | trace! |
58 | "Registration of object operation {}<{}> overwrote previous registration.", |
59 | , | operation_name
60 | object_name |
61 | ; |
62 | else |
63 | trace! |
64 | "Registration of object operation {}<{}>.", |
65 | , | operation_name
66 | object_name |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | O: GiteratedObject + 'static, |
73 | V: + 'static, |
74 | > |
75 | &mut self, |
76 | |
77 | let _object_name = object_name .to_string; |
78 | let _value_name = value_name .to_string; |
79 | |
80 | if self |
81 | .values |
82 | .insert |
83 | .is_some |
84 | |
85 | trace! |
86 | "Registration of value <{}>::{} overwrote previous registration.", |
87 | , | object_name
88 | value_name |
89 | ; |
90 | else |
91 | trace! |
92 | "Registration of value <{}>::{}.", |
93 | , | object_name
94 | value_name |
95 | ; |
96 | |
97 | |
98 | |
99 | |
100 | if self |
101 | .settings |
102 | .insert |
103 | , |
104 | , |
105 | |
106 | .is_some |
107 | |
108 | trace! |
109 | "Registration of setting {} overwrote previous registration.", |
110 | name |
111 | ; |
112 | else |
113 | trace!; |
114 | |
115 | |
116 | |
117 | |
118 | self.objects.extend; |
119 | self.operations.extend; |
120 | self.values.extend; |
121 | self.settings.extend; |
122 | |
123 | |
124 | |
125 | |
126 | pub name: String, |
127 | pub deserialize: fn , |
128 | pub serialize: fn , |
129 | pub typed_get: fn , |
130 | pub is_get_value_typed: fn , |
131 | |
132 | |
133 | |
134 | ; |
135 | ; |
136 | ; |
137 | ; |
138 | ; |
139 | |
140 | |
141 | |
142 | |
143 | to_string | value_name .
144 | |
145 | |
146 | |
147 | Ok |
148 | |
149 | |
150 | |
151 | let value = value.0. .unwrap; |
152 | |
153 | to_vec |
154 | |
155 | |
156 | |
157 | Box new |
158 | ty: Default default, |
159 | |
160 | |
161 | |
162 | |
163 | typed_get_value.0. |
164 | |
165 | |
166 | |
167 | |
168 | |
169 | Self |
170 | name: name, |
171 | deserialize: deserialize, |
172 | serialize: serialize, |
173 | typed_get: typed_get, |
174 | is_get_value_typed: is_get_value_typed, |
175 | |
176 | |
177 | |
178 | |
179 | |
180 | pub name: String, |
181 | pub object_kind: String, |
182 | pub deserialize: fn , |
183 | pub any_is_same: fn , |
184 | pub serialize_success: fn , |
185 | pub serialize_error: fn , |
186 | |
187 | |
188 | |
189 | ; |
190 | ; |
191 | ; |
192 | ; |
193 | ; |
194 | |
195 | |
196 | |
197 | |
198 | : 'static, | Failure
199 | : 'static, | Success
200 | O: GiteratedObject, |
201 | D: + 'static, |
202 | |
203 | |
204 | to_string | operation_name .
205 | |
206 | |
207 | |
208 | Ok |
209 | as | new
210 | |
211 | |
212 | |
213 | |
214 | let to_serialize = success.0. .unwrap; |
215 | to_vec |
216 | |
217 | |
218 | |
219 | let to_serialize = failure.0. .unwrap; |
220 | to_vec |
221 | |
222 | |
223 | |
224 | other. |
225 | |
226 | |
227 | |
228 | |
229 | |
230 | Self |
231 | name: name, |
232 | deserialize: deserialize, |
233 | serialize_success: serialize_success, |
234 | serialize_error: serialize_failure, |
235 | object_kind: object_name .to_string, |
236 | any_is_same: any_is_same, |
237 | |
238 | |
239 | |
240 | |
241 | |
242 | pub name: String, |
243 | pub from_str: , |
244 | pub any_is_same: fn , |
245 | |
246 | |
247 | |
248 | ; |
249 | ; |
250 | |
251 | |
252 | |
253 | |
254 | to_string | object_name .
255 | |
256 | |
257 | |
258 | other. |
259 | |
260 | |
261 | |
262 | |
263 | |
264 | Self |
265 | name: name, |
266 | from_str: Box new |
267 | let object = from_str .map_err?; |
268 | |
269 | Ok |
270 | , |
271 | any_is_same: any_is_same, |
272 | |
273 | |
274 | |
275 | |
276 | |
277 | pub name: String, |
278 | pub deserialize: fn , |
279 | pub serialize: fn , |
280 | pub setting_updated: fn |
281 | AnyObject, |
282 | AnySetting, |
283 | , |
284 | &StackOperationState, |
285 | , |
286 | |
287 | |
288 | |
289 | ; |
290 | ; |
291 | ; |
292 | |
293 | object: AnyObject, |
294 | setting: AnySetting, |
295 | stack: , |
296 | operation_state: &StackOperationState, |
297 | ; |
298 | |
299 | |
300 | |
301 | |
302 | to_string | name .
303 | |
304 | |
305 | |
306 | Ok |
307 | |
308 | |
309 | |
310 | to_value |
311 | |
312 | |
313 | |
314 | object: AnyObject, |
315 | setting: AnySetting, |
316 | stack: , |
317 | operation_state: &StackOperationState, |
318 | |
319 | async move |
320 | stack |
321 | .setting_update |
322 | object.0. .unwrap .clone, |
323 | setting.0. .unwrap .clone, |
324 | operation_state, |
325 | |
326 | .await |
327 | |
328 | .boxed_local |
329 | |
330 | |
331 | |
332 | |
333 | |
334 | Self |
335 | name: name, |
336 | deserialize: deserialize, |
337 | serialize: serialize, |
338 | setting_updated: setting_updated, |
339 | |
340 | |
341 | |
342 |