Beginning of `stack-next` refactor
-Refactoring the protocol stack into something similar to a runtime. -Handles merging handler builders which is placing the ground work for plugins in. - Increased metadata generation during compilation enables less ser/de during execution. - Goal is to have an O(1) time from incoming operation to calling handlers. - Decreased penalty for using the statically typed API from within your code, now avoids some allocation. # Changes - Added `GiteratedRuntime` which is to replace the current unified stack - Added `RuntimeBuilder` which does what the current `OperationHandlers` struct does, but much better. - Added `RuntimeMetadata` to store type metadata for new `Any` based internals - Refactored serde_json out of the internal operation handling
parent: tbd commit: 708dea4
1 | use Arc; |
2 | |
3 | use ; |
4 | use |
5 | , | GiteratedObject
6 | , |
7 | , |
8 | ; |
9 | |
10 | use crate StackOperationState; |
11 | |
12 | |
13 | |
14 | async |
15 | &mut self, |
16 | object: O, |
17 | value_name: String, |
18 | value: V, |
19 | operation_state: &StackOperationState, |
20 | ; |
21 | |
22 | |
23 | |
24 | |
25 | |
26 | F: Fn(O, String, V, &StackOperationState) -> + Send + Sync, |
27 | O: GiteratedObject + Send + Sync + 'static, |
28 | V: + Send + Sync + 'static, |
29 | |
30 | async |
31 | &mut self, |
32 | object: O, |
33 | value_name: String, |
34 | value: V, |
35 | operation_state: &StackOperationState, |
36 | |
37 | self .await |
38 | |
39 | |
40 | |
41 | |
42 | |
43 | async |
44 | &mut self, |
45 | object: O, |
46 | setting_name: String, |
47 | setting: S, |
48 | operation_state: &StackOperationState, |
49 | ; |
50 | |
51 | |
52 | |
53 | |
54 | |
55 | F: Fn(O, String, S, &StackOperationState) -> + Send + Sync, |
56 | O: GiteratedObject + Send + Sync + 'static, |
57 | S: Setting + Send + Sync + 'static, |
58 | |
59 | async |
60 | &mut self, |
61 | object: O, |
62 | setting_name: String, |
63 | setting: S, |
64 | operation_state: &StackOperationState, |
65 | |
66 | self .await |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | async ; |
73 | |
74 | |
75 | |
76 | |
77 | async ; |
78 | |
79 | |
80 | |
81 | |
82 | pub object_kind: String, |
83 | pub value_name: String, |
84 | |
85 | |
86 | |
87 | |
88 | pub object_kind: String, |
89 | pub setting_name: String, |
90 | |
91 | |
92 | |
93 | pub target: SettingUpdateKind, |
94 | pub function: |
95 | dyn FnOnce( |
96 | String, |
97 | String, |
98 | AnySetting, |
99 | StackOperationState, |
100 | ) -> |
101 | + Send |
102 | + Sync, |
103 | >, |
104 | |
105 | |
106 | |
107 | |
108 | S: Setting + Send + Sync, |
109 | T: + 'static + Clone + Send + Sync, |
110 | O: GiteratedObject + Send + Sync, |
111 | > |
112 | handler: T, |
113 | setting_name: &str, |
114 | |
115 | Self |
116 | target: SettingUpdateKind |
117 | object_kind: object_name .to_string, |
118 | setting_name: setting_name.to_string, |
119 | , |
120 | |
121 | function: Box new |
122 | async move |
123 | let mut handler = handler; |
124 | |
125 | let object = match from_str |
126 | Ok => object, |
127 | Err => return Err, |
128 | ; |
129 | |
130 | let setting: S = from_value .unwrap; |
131 | |
132 | handler |
133 | .handle_setting_update |
134 | .await; |
135 | |
136 | Ok |
137 | |
138 | .boxed |
139 | , |
140 | |
141 | |
142 | |
143 | |
144 | |
145 | pub target: ValueUpdateKind, |
146 | pub function: |
147 | dyn FnOnce( |
148 | String, |
149 | String, |
150 | AnySetting, |
151 | StackOperationState, |
152 | ) -> |
153 | + Send |
154 | + Sync, |
155 | >, |
156 | |
157 | |
158 | |
159 | |
160 | V: + Send + Sync, |
161 | T: + 'static + Clone + Send + Sync, |
162 | O: GiteratedObject + Send + Sync, |
163 | > |
164 | handler: T, |
165 | value_name: &str, |
166 | |
167 | Self |
168 | target: ValueUpdateKind |
169 | object_kind: object_name .to_string, |
170 | value_name: value_name.to_string, |
171 | , |
172 | |
173 | function: Box new |
174 | async move |
175 | let mut handler = handler; |
176 | |
177 | let object = match from_str |
178 | Ok => object, |
179 | Err => return Err, |
180 | ; |
181 | |
182 | let setting: V = from_value .unwrap; |
183 | |
184 | handler |
185 | .handle_value_update |
186 | .await; |
187 | |
188 | Ok |
189 | |
190 | .boxed |
191 | , |
192 | |
193 | |
194 | |
195 |