MCPcopy Create free account
hub / github.com/apache/fory / unknown_case_reads_send_sync_payload

Function unknown_case_reads_send_sync_payload

rust/tests/tests/test_enum.rs:248–348  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

246
247#[test]
248fn unknown_case_reads_send_sync_payload() {
249 use fory_core::ArcWeak;
250 use std::sync::{Arc, Mutex};
251
252 #[derive(ForyStruct, Debug)]
253 struct FutureLeaf {
254 label: String,
255 }
256
257 #[derive(ForyStruct, Debug)]
258 struct FutureNode {
259 value: i32,
260 parent: ArcWeak<Mutex<FutureNode>>,
261 children: Vec<Arc<Mutex<FutureNode>>>,
262 }
263
264 #[derive(ForyStruct, Debug)]
265 struct FuturePayload {
266 id: i32,
267 leaf: FutureLeaf,
268 primary: Arc<String>,
269 alias: Arc<String>,
270 root: Arc<Mutex<FutureNode>>,
271 }
272
273 #[derive(ForyUnion, Debug)]
274 enum OldUnion {
275 #[fory(unknown)]
276 Unknown(fory_core::UnknownCase),
277 #[fory(id = 0, default)]
278 Known(String),
279 }
280
281 #[derive(ForyUnion, Debug)]
282 enum NewUnion {
283 #[fory(unknown)]
284 Unknown(fory_core::UnknownCase),
285 #[fory(id = 0, default)]
286 Known(String),
287 #[fory(id = 1)]
288 Future(FuturePayload),
289 }
290
291 let mut writer = Fory::builder()
292 .xlang(true)
293 .compatible(false)
294 .track_ref(true)
295 .build();
296 writer.register::<FutureLeaf>(400).unwrap();
297 writer.register::<FuturePayload>(401).unwrap();
298 writer.register::<NewUnion>(402).unwrap();
299 writer.register::<FutureNode>(403).unwrap();
300
301 let mut reader = Fory::builder()
302 .xlang(true)
303 .compatible(false)
304 .track_ref(true)
305 .build();

Callers

nothing calls this directly

Calls 11

lockMethod · 0.65
serializeMethod · 0.65
deserializeMethod · 0.65
buildMethod · 0.45
track_refMethod · 0.45
compatibleMethod · 0.45
xlangMethod · 0.45
unwrapMethod · 0.45
to_stringMethod · 0.45
cloneMethod · 0.45
upgradeMethod · 0.45

Tested by

no test coverage detected