The long awaited, exhalted huge networking stack change.
parent: tbd commit: 21b6a72
1 | use ; |
2 | |
3 | use Error; |
4 | use FutureExt; |
5 | use |
6 | , | OperationError
7 | , | Instance
8 | , |
9 | , | GiteratedOperation
10 | , | Setting
11 | , | GiteratedObjectValue
12 | ; |
13 | use ; |
14 | |
15 | use crate:: |
16 | , MetadataProvider, AnyFailure, AnyObject, AnyOperation, | HandlerWrapper
17 | AnySetting, AnySuccess, AnyValue, GiteratedStack, GiteratedStackState, HandlerResolvable, |
18 | IntoGiteratedHandler, MaybeDynamicObject, MaybeDynamicValue, ObjectOperationPair, |
19 | ObjectSettingPair, ObjectValuePair, OperationHandler, OperationState, RuntimeMetadata, |
20 | SettingChange, SettingGetter, StackOperationState, ValueChange, ValueGetter, |
21 | ; |
22 | |
23 | |
24 | pub(crate) operation_handlers: , |
25 | pub(crate) value_getters: , |
26 | pub(crate) setting_getters: , |
27 | pub(crate) metadata: RuntimeMetadata, |
28 | pub(crate) value_change: , |
29 | pub(crate) metadata_providers: , |
30 | pub(crate) setting_change: , |
31 | |
32 | pub(crate) state: S, |
33 | _marker: , |
34 | |
35 | |
36 | |
37 | |
38 | Self |
39 | operation_handlers: Default default, |
40 | value_getters: Default default, |
41 | setting_getters: Default default, |
42 | metadata: Default default, |
43 | value_change: Default default, |
44 | metadata_providers: Default default, |
45 | setting_change: Default default, |
46 | state, |
47 | _marker: default, |
48 | |
49 | |
50 | |
51 | |
52 | |
53 | /// Insert an operation handler into the runtime builder. |
54 | /// |
55 | /// # Type Registration |
56 | /// Inserting the handler will automatically, if required, register the operation type of the |
57 | /// handler. It will **not** register the object type automatically. |
58 | |
59 | |
60 | O: GiteratedObject + Clone, |
61 | D: + Clone, |
62 | H: |
63 | + Send |
64 | + Sync |
65 | + 'static, |
66 | O: 'static, |
67 | D: 'static, |
68 | : Debug + 'static, | Failure
69 | : 'static, | Success
70 | OS: Clone, |
71 | |
72 | let wrapped = new; |
73 | |
74 | let wrapped = wrapped.map |
75 | |
76 | Ok |
77 | any_object.unwrap .clone, | .
78 | any_operation.unwrap .clone, | .
79 | |
80 | , |
81 | ; |
82 | |
83 | let wrapped = wrapped.map_return |
84 | Ok => Ok, |
85 | Err => Err |
86 | => | Operation
87 | Operation |
88 | |
89 | => Internal, | Internal
90 | => Unhandled, | Unhandled
91 | , |
92 | ; |
93 | |
94 | let pair = ; |
95 | |
96 | self.operation_handlers.insert; |
97 | |
98 | self.metadata.; |
99 | |
100 | self |
101 | |
102 | |
103 | /// Register a [`GiteratedObjectValue<O>`] type with the runtime, providing |
104 | /// its associated handler for [`GetValue`]. |
105 | /// |
106 | /// # Type Registration |
107 | /// This will register the provided [`GiteratedObjectValue`] type for its matching / specified |
108 | /// object type. It will **not** register the object type automatically. |
109 | |
110 | |
111 | O: MaybeDynamicObject + 'static, |
112 | F: |
113 | (O, String), |
114 | A, |
115 | S, |
116 | OS, |
117 | , |
118 | > + Send |
119 | + Sync, |
120 | F: 'static, |
121 | |
122 | let wrapped = new; |
123 | |
124 | let wrapped = wrapped.map |
125 | Ok |
126 | ; |
127 | |
128 | let wrapped = wrapped.map_return |
129 | Ok => Ok, |
130 | Err => Err |
131 | => Internal, | Operation
132 | => Internal, | Internal
133 | => Unhandled, | Unhandled
134 | , |
135 | ; |
136 | |
137 | assert! |
138 | .value_getters |
139 | .insert |
140 | ObjectValuePair |
141 | object_kind: object_name, |
142 | value_kind: "any" |
143 | , |
144 | wrapped |
145 | |
146 | .is_none; |
147 | |
148 | self |
149 | |
150 | |
151 | |
152 | |
153 | F: |
154 | + Send |
155 | + Sync, |
156 | V: MaybeDynamicValue + Clone + 'static, |
157 | O: 'static + MaybeDynamicObject, |
158 | V: 'static, |
159 | F: 'static, |
160 | |
161 | let wrapped = new; |
162 | |
163 | let wrapped = wrapped.map |
164 | |
165 | Ok |
166 | , |
167 | ; |
168 | |
169 | assert! |
170 | .value_change |
171 | .insert |
172 | ObjectValuePair |
173 | object_kind: object_name, |
174 | value_kind: value_name |
175 | , |
176 | wrapped |
177 | |
178 | .is_none; |
179 | |
180 | self |
181 | |
182 | |
183 | |
184 | self.metadata_providers.push; |
185 | |
186 | self |
187 | |
188 | |
189 | /// Register a [`GiteratedObject`] type with the runtime. |
190 | /// |
191 | /// # Type Registration |
192 | /// This will register the provided object type. |
193 | |
194 | |
195 | : , |
196 | : | Error
197 | , |
198 | |
199 | self.metadata.; |
200 | |
201 | // Insert handler so ObjectRequest is handled properly |
202 | |
203 | self.operation |
204 | move |_object: Instance, |
205 | operation: ObjectRequest, |
206 | _state: S, |
207 | stack: | |
208 | let operation = operation.clone; |
209 | async move |
210 | for in stack.inner.metadata.objects.iter |
211 | if .is_ok |
212 | return Ok; |
213 | |
214 | |
215 | |
216 | Err |
217 | |
218 | .boxed_local |
219 | , |
220 | ; |
221 | |
222 | self |
223 | |
224 | |
225 | |
226 | |
227 | /// Register a [`Setting`] type with the runtime. |
228 | /// |
229 | /// # Type Registration |
230 | /// This will register the provided setting type. |
231 | |
232 | &mut self, |
233 | |
234 | self.metadata.; |
235 | |
236 | self |
237 | |
238 | |
239 | /// Register a [`GiteratedObjectValue`] that is also a [`Setting`], which |
240 | /// allows for automatic value updates. |
241 | |
242 | O: GiteratedObject + 'static + Clone, |
243 | T: + Setting + 'static + Clone, |
244 | > |
245 | &mut self, |
246 | |
247 | self.metadata.; |
248 | self.metadata.; |
249 | |
250 | self.setting_change.insert |
251 | , |
252 | new |
253 | , |
254 | move |object: AnyObject, |
255 | setting: AnySetting, |
256 | _state: _, |
257 | OperationState: , |
258 | stack: | |
259 | trace! |
260 | "value setting updated {}::{}", |
261 | , | object_name
262 | value_name |
263 | ; |
264 | let object = object.clone; |
265 | async move |
266 | let object = object. .unwrap; |
267 | let setting = setting. .unwrap; |
268 | stack |
269 | .value_update |
270 | object.clone, |
271 | , | new
272 | &operation_state, |
273 | |
274 | .await; |
275 | Ok |
276 | |
277 | .boxed_local |
278 | , |
279 | , |
280 | ; |
281 | |
282 | let wrapped = new |
283 | self.state.clone, |
284 | |
285 | |
286 | _state: _, |
287 | stack: | |
288 | info!; |
289 | let object = object.clone; |
290 | async move |
291 | match stack |
292 | . |
293 | .await |
294 | |
295 | Ok => Ok, |
296 | Err => |
297 | panic!; |
298 | |
299 | |
300 | |
301 | .boxed_local |
302 | , |
303 | ; |
304 | |
305 | self.value_getters |
306 | .insert; |
307 | |
308 | self |
309 | |
310 | |
311 | |
312 | // Placeholder |
313 | |
314 | |
315 | |
316 | H: |
317 | (AnyObject, AnyOperation), |
318 | A, |
319 | S, |
320 | OS, |
321 | , |
322 | > + Send |
323 | + Sync |
324 | + 'static, |
325 | OS: Clone + Send + Sync + 'static, |
326 | |
327 | let wrapped = new; |
328 | |
329 | self.operation_handlers.insert |
330 | ObjectOperationPair |
331 | object_name: "any", |
332 | operation_name: "any", |
333 | , |
334 | wrapped, |
335 | ; |
336 | |
337 | self |
338 | |
339 | |
340 | |
341 | |
342 | ; |
343 |