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