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 | use |
3 | , | GiteratedObject
4 | , |
5 | , |
6 | ; |
7 | |
8 | use crate StackOperationState; |
9 | |
10 | |
11 | |
12 | async |
13 | &mut self, |
14 | object: O, |
15 | value_name: String, |
16 | value: V, |
17 | operation_state: &StackOperationState, |
18 | ; |
19 | |
20 | |
21 | |
22 | |
23 | |
24 | F: Fn(O, String, V, &StackOperationState) -> + Send + Sync, |
25 | O: GiteratedObject + Send + Sync + 'static, |
26 | V: + Send + Sync + 'static, |
27 | |
28 | async |
29 | &mut self, |
30 | object: O, |
31 | value_name: String, |
32 | value: V, |
33 | operation_state: &StackOperationState, |
34 | |
35 | self .await |
36 | |
37 | |
38 | |
39 | |
40 | |
41 | async |
42 | &mut self, |
43 | object: O, |
44 | setting_name: String, |
45 | setting: S, |
46 | operation_state: &StackOperationState, |
47 | ; |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | F: Fn(O, String, S, &StackOperationState) -> + Send + Sync, |
54 | O: GiteratedObject + Send + Sync + 'static, |
55 | S: Setting + Send + Sync + 'static, |
56 | |
57 | async |
58 | &mut self, |
59 | object: O, |
60 | setting_name: String, |
61 | setting: S, |
62 | operation_state: &StackOperationState, |
63 | |
64 | self .await |
65 | |
66 | |
67 | |
68 | |
69 | |
70 | async ; |
71 | |
72 | |
73 | |
74 | |
75 | async ; |
76 | |
77 | |
78 | |
79 | |
80 | pub object_kind: String, |
81 | pub value_name: String, |
82 | |
83 | |
84 | |
85 | |
86 | pub object_kind: String, |
87 | pub setting_name: String, |
88 | |
89 | |
90 | |
91 | pub target: SettingUpdateKind, |
92 | pub function: |
93 | dyn FnOnce( |
94 | String, |
95 | String, |
96 | AnySetting, |
97 | StackOperationState, |
98 | ) -> |
99 | + Send |
100 | + Sync, |
101 | >, |
102 | |
103 | |
104 | |
105 | |
106 | S: Setting + Send + Sync, |
107 | T: + 'static + Clone + Send + Sync, |
108 | O: GiteratedObject + Send + Sync, |
109 | > |
110 | handler: T, |
111 | setting_name: &str, |
112 | |
113 | Self |
114 | target: SettingUpdateKind |
115 | object_kind: object_name .to_string, |
116 | setting_name: setting_name.to_string, |
117 | , |
118 | |
119 | function: Box new |
120 | async move |
121 | let _handler = handler; |
122 | |
123 | let _object = match from_str |
124 | Ok => object, |
125 | Err => return Err, |
126 | ; |
127 | |
128 | // let setting: S = serde_json::from_value( |
129 | // let _ = handler |
130 | // .handle_setting_update(object, setting_name, setting, &state) |
131 | // .await;value.0).unwrap(); |
132 | |
133 | Ok |
134 | |
135 | .boxed |
136 | , |
137 | |
138 | |
139 | |
140 | |
141 | |
142 | pub target: ValueUpdateKind, |
143 | pub function: |
144 | dyn FnOnce( |
145 | String, |
146 | String, |
147 | AnySetting, |
148 | StackOperationState, |
149 | ) -> |
150 | + Send |
151 | + Sync, |
152 | >, |
153 | |
154 | |
155 | |
156 | |
157 | V: + Send + Sync, |
158 | T: + 'static + Clone + Send + Sync, |
159 | O: GiteratedObject + Send + Sync, |
160 | > |
161 | handler: T, |
162 | value_name: &str, |
163 | |
164 | Self |
165 | target: ValueUpdateKind |
166 | object_kind: object_name .to_string, |
167 | value_name: value_name.to_string, |
168 | , |
169 | |
170 | function: Box new |
171 | async move |
172 | let _handler = handler; |
173 | |
174 | let _object = match from_str |
175 | Ok => object, |
176 | Err => return Err, |
177 | ; |
178 | |
179 | // let setting: V = serde_json::from_value(value.0).unwrap(); |
180 | |
181 | // let _ = handler |
182 | // .handle_value_update(object, setting_name, setting, &state) |
183 | // .await; |
184 | |
185 | Ok |
186 | |
187 | .boxed |
188 | , |
189 | |
190 | |
191 | |
192 |