So. Much. Work.
parent: tbd commit: b05f964
1 | use ; |
2 | use ; |
3 | |
4 | use crate; |
5 | |
6 | use ; |
7 | |
8 | /// A wrapper for operation handling that enforces handling rules. |
9 | /// |
10 | /// # Handler Resolution |
11 | /// In order, handler resolution will be attempted as follows: |
12 | /// |
13 | /// | Index | object_kind | operation_kind | Special Case? | |
14 | /// |-------|-------------|-----------------|---------------| |
15 | /// | 1 | `any` | `typed` | No | |
16 | /// | 2 | `typed` | `any` | No | |
17 | /// | 3 | `any` | `any` | No | |
18 | /// | 4 | `any` | `GetValue` | ⚠️ Yes ⚠️ | |
19 | /// | 5 | `any` | `GetSetting` | ⚠️ Yes ⚠️ | |
20 | /// | 6 | `any` | `SetSetting` | ⚠️ Yes ⚠️ | |
21 | /// | 7 | `any` | `ObjectRequest` | ⚠️ Yes ⚠️ | |
22 | /// | 8 | `typed` | `typed` | No | |
23 | |
24 | object_kind: &'a str, |
25 | operation_name: &'a str, |
26 | handlers: &'a RuntimeHandlers, |
27 | |
28 | |
29 | |
30 | |
31 | object_kind: &'o str, |
32 | operation_name: &'o str, |
33 | handlers: &'o RuntimeHandlers, |
34 | |
35 | Self |
36 | object_kind, |
37 | operation_name, |
38 | handlers, |
39 | |
40 | |
41 | |
42 | |
43 | // object_kind: `any` |
44 | // operation_kind: `typed` |
45 | if let Some = self |
46 | .handlers |
47 | .operation_handlers |
48 | .get |
49 | |
50 | todo! |
51 | |
52 | |
53 | // object_kind: `typed` |
54 | // operation_kind: `any` |
55 | if let Some = self |
56 | .handlers |
57 | .operation_handlers |
58 | .get |
59 | |
60 | |
61 | // object_kind: `any` |
62 | // operation_kind: `any` |
63 | if let Some = self |
64 | .handlers |
65 | .operation_handlers |
66 | .get |
67 | |
68 | |
69 | // ⚠️ Special Case ⚠️ |
70 | // object_kind: `any` |
71 | // operation_kind: `GetValue` |
72 | if self.operation_name == "get_value" |
73 | let operation: GetValue = from_slice .unwrap; |
74 | let _guard = trace_span! |
75 | "get_value handler resolving", |
76 | object = self.object_kind, |
77 | value = operation.value_name |
78 | |
79 | .entered; |
80 | |
81 | if let Some = self.handlers.value_getters.get |
82 | & new, |
83 | |
84 | trace_span! |
85 | "get_value handler.", |
86 | object = self.object_kind, |
87 | value_name = operation.value_name |
88 | ; |
89 | |
90 | let object_vtable = domain |
91 | .object_vtable |
92 | .ok_or_else?; |
93 | trace!; |
94 | |
95 | let value_vtable = domain |
96 | .value_vtable |
97 | .ok_or_else?; |
98 | trace! |
99 | "Resolved value vtable for {}::{}", |
100 | self.object_kind, |
101 | operation.value_name |
102 | ; |
103 | |
104 | let object = unsafe |
105 | .map_err?; |
106 | |
107 | let _guard = debug_span!; |
108 | |
109 | let result = |
110 | unsafe ; |
111 | |
112 | // Todo deser |
113 | |
114 | return Ok; |
115 | else |
116 | trace!; |
117 | |
118 | |
119 | |
120 | // ⚠️ Special Case ⚠️ |
121 | // object_kind: `any` |
122 | // operation_kind: `GetSetting` |
123 | if self.operation_name == "get_setting" |
124 | let operation: GetSetting = from_slice .unwrap; |
125 | let _guard = trace_span! |
126 | "get_setting handler resolving", |
127 | object = self.object_kind, |
128 | setting = operation.setting_name |
129 | |
130 | .entered; |
131 | |
132 | if let Some = self.handlers.setting_getters.get |
133 | & new, |
134 | |
135 | trace_span! |
136 | "get_setting handler.", |
137 | object = self.object_kind, |
138 | setting_name = operation.setting_name |
139 | ; |
140 | |
141 | let object_vtable = domain |
142 | .object_vtable |
143 | .ok_or_else?; |
144 | trace!; |
145 | |
146 | let setting_vtable = domain |
147 | .setting_vtable |
148 | .ok_or_else?; |
149 | trace!; |
150 | |
151 | let object = unsafe |
152 | .map_err?; |
153 | |
154 | let _guard = debug_span!; |
155 | |
156 | let result = |
157 | unsafe ; |
158 | |
159 | // Todo deser |
160 | |
161 | return Ok; |
162 | else |
163 | trace!; |
164 | |
165 | |
166 | |
167 | // ⚠️ Special Case ⚠️ |
168 | // object_kind: `any` |
169 | // operation_kind: `SetSetting` |
170 | if self.operation_name == "set_setting" |
171 | |
172 | // ⚠️ Special Case ⚠️ |
173 | // object_kind: `any` |
174 | // operation_kind: `ObjectRequest` |
175 | if self.operation_name == "object_request" |
176 | |
177 | // object_kind: `typed` |
178 | // operation_kind: `typed` |
179 | if let Some = |
180 | self.handlers |
181 | .operation_handlers |
182 | .get |
183 | self.object_kind, |
184 | self.operation_name, |
185 | |
186 | |
187 | let _guard = trace_span! .entered; |
188 | |
189 | let object_vtable = domain |
190 | .object_vtable |
191 | .ok_or_else?; |
192 | trace!; |
193 | |
194 | let operation_vtable = domain |
195 | .operation_vtable |
196 | .ok_or_else?; |
197 | trace! |
198 | "Resolved operation vtable for {}::{}", |
199 | self.object_kind, |
200 | self.operation_name |
201 | ; |
202 | |
203 | let object = unsafe |
204 | .map_err?; |
205 | let operation = unsafe |
206 | .map_err?; |
207 | trace!; |
208 | |
209 | let _guard = debug_span! .entered; |
210 | let result = unsafe |
211 | |
212 | handler.callback_ptr, |
213 | &domain.plugin.state, |
214 | object, |
215 | operation, |
216 | |
217 | ; |
218 | |
219 | // todo |
220 | return Ok; |
221 | |
222 | |
223 | Err |
224 | |
225 | |
226 |