Create `NetworkedSubstack`.
# giterated-protocol - Create `NetworkedSubstack` which will handle all networked operations giterated needs - Add support for `NetworkedSubstack` for both the daemon and client - Pipe everything through but leave APIs temp # `giterated-daemon` - Remove a bunch of random old code, dead code, and files that aren't needed. - Moved all connection handling to `client.rs`, simplified connection logic with new types
parent: tbd commit: 202bb12
1 | use ; |
2 | |
3 | use ; |
4 | use |
5 | , | GiteratedObject
6 | , | GiteratedOperation
7 | , | Setting
8 | , |
9 | ; |
10 | use Value; |
11 | use trace; |
12 | |
13 | use crate:: |
14 | AnyFailure, AnyObject, AnyOperation, AnySetting, AnySuccess, AnyValue, GiteratedStack, |
15 | ObjectOperationPair, ObjectSettingPair, ObjectValuePair, StackOperationState, |
16 | ; |
17 | |
18 | /// Stores runtime metadata for all in-use Giterated protocol types. |
19 | |
20 | |
21 | pub objects: , |
22 | pub operations: , |
23 | pub values: , |
24 | pub settings: , |
25 | |
26 | |
27 | |
28 | |
29 | let object_name = object_name .to_string; |
30 | |
31 | let object_meta = ; |
32 | |
33 | if self.objects.insert .is_some |
34 | trace! |
35 | "Registration of object {} overwrote previous registration.", |
36 | object_name |
37 | ; |
38 | else |
39 | trace! |
40 | |
41 | |
42 | |
43 | |
44 | &mut self, |
45 | |
46 | let _object_name = object_name .to_string; |
47 | let _operation_name = operation_name .to_string; |
48 | |
49 | if self |
50 | .operations |
51 | .insert |
52 | , |
53 | , |
54 | |
55 | .is_some |
56 | |
57 | trace! |
58 | "Registration of object operation {}<{}> overwrote previous registration.", |
59 | , | operation_name
60 | object_name |
61 | ; |
62 | else |
63 | trace! |
64 | "Registration of object operation {}<{}>.", |
65 | , | operation_name
66 | object_name |
67 | |
68 | |
69 | |
70 | |
71 | |
72 | O: GiteratedObject + 'static, |
73 | V: + 'static, |
74 | > |
75 | &mut self, |
76 | |
77 | if self |
78 | .values |
79 | .insert |
80 | .is_some |
81 | |
82 | trace! |
83 | "Registration of value <{}>::{} overwrote previous registration.", |
84 | , | object_name
85 | value_name |
86 | ; |
87 | else |
88 | trace! |
89 | "Registration of value <{}>::{}.", |
90 | , | object_name
91 | value_name |
92 | ; |
93 | |
94 | |
95 | |
96 | |
97 | if self |
98 | .settings |
99 | .insert |
100 | , |
101 | , |
102 | |
103 | .is_some |
104 | |
105 | trace! |
106 | "Registration of setting {} overwrote previous registration.", |
107 | name |
108 | ; |
109 | else |
110 | trace!; |
111 | |
112 | |
113 | |
114 | |
115 | self.objects.extend; |
116 | self.operations.extend; |
117 | self.values.extend; |
118 | self.settings.extend; |
119 | |
120 | |
121 | |
122 | |
123 | pub name: String, |
124 | pub deserialize: fn , |
125 | pub serialize: fn , |
126 | pub typed_get: fn , |
127 | pub is_get_value_typed: fn , |
128 | |
129 | |
130 | |
131 | ; |
132 | ; |
133 | ; |
134 | ; |
135 | ; |
136 | |
137 | |
138 | |
139 | |
140 | to_string | value_name .
141 | |
142 | |
143 | |
144 | Ok |
145 | |
146 | |
147 | |
148 | let value = value. .unwrap; |
149 | |
150 | to_vec |
151 | |
152 | |
153 | |
154 | Box new |
155 | ty: Default default, |
156 | |
157 | |
158 | |
159 | |
160 | typed_get_value. |
161 | |
162 | |
163 | |
164 | |
165 | |
166 | Self |
167 | name: name, |
168 | deserialize: deserialize, |
169 | serialize: serialize, |
170 | typed_get: typed_get, |
171 | is_get_value_typed: is_get_value_typed, |
172 | |
173 | |
174 | |
175 | |
176 | |
177 | pub name: String, |
178 | pub object_kind: String, |
179 | pub deserialize: fn , |
180 | pub any_is_same: fn , |
181 | pub serialize_success: fn , |
182 | pub serialize_error: fn , |
183 | |
184 | |
185 | |
186 | ; |
187 | ; |
188 | ; |
189 | ; |
190 | ; |
191 | |
192 | |
193 | |
194 | |
195 | : 'static, | Failure
196 | : 'static, | Success
197 | O: GiteratedObject, |
198 | D: + 'static, |
199 | |
200 | |
201 | to_string | operation_name .
202 | |
203 | |
204 | |
205 | Ok |
206 | |
207 | |
208 | |
209 | let to_serialize = success.0. .unwrap; |
210 | to_vec |
211 | |
212 | |
213 | |
214 | let to_serialize = failure.0. .unwrap; |
215 | to_vec |
216 | |
217 | |
218 | |
219 | other. |
220 | |
221 | |
222 | |
223 | |
224 | |
225 | Self |
226 | name: name, |
227 | deserialize: deserialize, |
228 | serialize_success: serialize_success, |
229 | serialize_error: serialize_failure, |
230 | object_kind: object_name .to_string, |
231 | any_is_same: any_is_same, |
232 | |
233 | |
234 | |
235 | |
236 | |
237 | pub name: String, |
238 | pub to_str: , |
239 | pub from_str: , |
240 | pub home_uri: fn , |
241 | pub any_is_same: fn , |
242 | |
243 | |
244 | |
245 | ; |
246 | ; |
247 | ; |
248 | |
249 | |
250 | |
251 | |
252 | to_string | object_name .
253 | |
254 | |
255 | |
256 | other. |
257 | |
258 | |
259 | |
260 | todo! |
261 | |
262 | |
263 | |
264 | |
265 | |
266 | Self |
267 | name: name, |
268 | from_str: Box new |
269 | let object = from_str .map_err?; |
270 | |
271 | Ok |
272 | , |
273 | to_str: Box new |
274 | let object: &I = source.downcast_ref .unwrap; |
275 | |
276 | object.to_string |
277 | , |
278 | any_is_same: any_is_same, |
279 | home_uri: home_uri, |
280 | |
281 | |
282 | |
283 | |
284 | |
285 | pub name: String, |
286 | pub deserialize: fn , |
287 | pub serialize: fn , |
288 | pub setting_updated: fn |
289 | AnyObject, |
290 | AnySetting, |
291 | , |
292 | &StackOperationState, |
293 | , |
294 | |
295 | |
296 | |
297 | ; |
298 | ; |
299 | ; |
300 | |
301 | object: AnyObject, |
302 | setting: AnySetting, |
303 | stack: , |
304 | operation_state: &StackOperationState, |
305 | ; |
306 | |
307 | |
308 | |
309 | |
310 | to_string | name .
311 | |
312 | |
313 | |
314 | Ok |
315 | |
316 | |
317 | |
318 | to_value |
319 | |
320 | |
321 | |
322 | object: AnyObject, |
323 | setting: AnySetting, |
324 | stack: , |
325 | operation_state: &StackOperationState, |
326 | |
327 | async move |
328 | stack |
329 | .setting_update |
330 | object.unwrap .clone, | .
331 | setting.unwrap .clone, | .
332 | operation_state, |
333 | |
334 | .await |
335 | |
336 | .boxed_local |
337 | |
338 | |
339 | |
340 | |
341 | |
342 | Self |
343 | name: name, |
344 | deserialize: deserialize, |
345 | serialize: serialize, |
346 | setting_updated: setting_updated, |
347 | |
348 | |
349 | |
350 |