summaryrefslogtreecommitdiff
path: root/examples/16-transient-0/output/rust/src/gen/data/transient_0.rs
blob: b72964c9701406467a15feb7ee544f75f6389f21 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
// Generated by hobgoblin.

pub fn encode_struct_singleton(value: &crate::data::StructSingleton, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    ::std::io::Result::Ok(())
}

pub fn decode_struct_singleton(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructSingleton> {
    ::std::io::Result::Ok(crate::data::StructSingleton)
}

pub fn encode_struct_with_bool(value: &crate::data::StructWithBool, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_bool(&value.a, writer, shared_values)?;
    crate::transient_0::encode_bool(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_bool(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithBool> {
    let a = crate::transient_0::decode_bool(reader, shared_values)?;
    let b = crate::transient_0::decode_bool(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithBool { a: a, b: b })
}

pub fn encode_struct_with_int_8(value: &crate::data::StructWithInt8, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_8(&value.a, writer, shared_values)?;
    crate::transient_0::encode_int_8(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_int_8(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithInt8> {
    let a = crate::transient_0::decode_int_8(reader, shared_values)?;
    let b = crate::transient_0::decode_int_8(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithInt8 { a: a, b: b })
}

pub fn encode_struct_with_int_32(value: &crate::data::StructWithInt32, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_32(&value.a, writer, shared_values)?;
    crate::transient_0::encode_int_32(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_int_32(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithInt32> {
    let a = crate::transient_0::decode_int_32(reader, shared_values)?;
    let b = crate::transient_0::decode_int_32(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithInt32 { a: a, b: b })
}

pub fn encode_struct_with_int_64(value: &crate::data::StructWithInt64, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_64(&value.a, writer, shared_values)?;
    crate::transient_0::encode_int_64(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_int_64(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithInt64> {
    let a = crate::transient_0::decode_int_64(reader, shared_values)?;
    let b = crate::transient_0::decode_int_64(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithInt64 { a: a, b: b })
}

pub fn encode_struct_with_string(value: &crate::data::StructWithString, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_string(&value.a, writer, shared_values)?;
    crate::transient_0::encode_string(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_string(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithString> {
    let a = crate::transient_0::decode_string(reader, shared_values)?;
    let b = crate::transient_0::decode_string(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithString { a: a, b: b })
}

pub fn encode_struct_with_struct(value: &crate::data::StructWithStruct, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_struct_with_int_32(&value.inner, writer, shared_values)?;
    crate::transient_0::encode_int_32(&value.c, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_struct(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithStruct> {
    let inner = crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?;
    let c = crate::transient_0::decode_int_32(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithStruct { inner: inner, c: c })
}

pub fn encode_struct_with_list(value: &crate::data::StructWithList, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    {
        crate::transient_0::encode_int_64(&(((&value.a).len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?, writer, shared_values)?;
        for element in &value.a {
            crate::transient_0::encode_int_64(element, writer, shared_values)?;
        };
    };
    {
        crate::transient_0::encode_int_64(&(((&value.b).len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?, writer, shared_values)?;
        for element in &value.b {
            crate::data::transient_0::encode_struct_with_int_32(element, writer, shared_values)?;
        };
    };
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_list(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithList> {
    let a = {
        let len = crate::transient_0::decode_int_64(reader, shared_values)?;
        let mut elements = ::std::vec::Vec::with_capacity((len.try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?);
        for _ in 0..len {
            elements.push(crate::transient_0::decode_int_64(reader, shared_values)?);
        };
        elements
    };
    let b = {
        let len = crate::transient_0::decode_int_64(reader, shared_values)?;
        let mut elements = ::std::vec::Vec::with_capacity((len.try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?);
        for _ in 0..len {
            elements.push(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?);
        };
        elements
    };
    ::std::io::Result::Ok(crate::data::StructWithList { a: a, b: b })
}

pub fn encode_struct_with_option(value: &crate::data::StructWithOption, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    match &value.a {
        ::std::option::Option::Some(value) => {
            crate::transient_0::encode_bool(&true, writer, shared_values)?;
            crate::transient_0::encode_int_64(&value, writer, shared_values)?;
        },
        ::std::option::Option::None => {
            crate::transient_0::encode_bool(&false, writer, shared_values)?;
        },
    };
    match &value.b {
        ::std::option::Option::Some(value) => {
            crate::transient_0::encode_bool(&true, writer, shared_values)?;
            crate::data::transient_0::encode_struct_with_int_32(&value, writer, shared_values)?;
        },
        ::std::option::Option::None => {
            crate::transient_0::encode_bool(&false, writer, shared_values)?;
        },
    };
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_option(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithOption> {
    let a = {
        let is_some = crate::transient_0::decode_bool(reader, shared_values)?;
        if is_some {
            ::std::option::Option::Some(crate::transient_0::decode_int_64(reader, shared_values)?)
        } else {
            ::std::option::Option::None
        }
    };
    let b = {
        let is_some = crate::transient_0::decode_bool(reader, shared_values)?;
        if is_some {
            ::std::option::Option::Some(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?)
        } else {
            ::std::option::Option::None
        }
    };
    ::std::io::Result::Ok(crate::data::StructWithOption { a: a, b: b })
}

pub fn encode_enum_with_variants(value: &crate::data::EnumWithVariants, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_32(&match value {
        crate::data::EnumWithVariants::Zero => 0,
        crate::data::EnumWithVariants::One => 1,
        crate::data::EnumWithVariants::Two => 2,
    }, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_enum_with_variants(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::EnumWithVariants> {
    ::std::io::Result::Ok(match &crate::transient_0::decode_int_32(reader, shared_values)? {
        0 => crate::data::EnumWithVariants::Zero,
        1 => crate::data::EnumWithVariants::One,
        2 => crate::data::EnumWithVariants::Two,
        _ => ::std::result::Result::Err(::std::io::Error::new(::std::io::ErrorKind::InvalidData, "unrecognised variant tag for data.EnumWithVariants"))?,
    })
}

pub fn encode_struct_with_enum(value: &crate::data::StructWithEnum, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_enum_with_variants(&value.inner, writer, shared_values)?;
    crate::transient_0::encode_int_32(&value.c, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_enum(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithEnum> {
    let inner = crate::data::transient_0::decode_enum_with_variants(reader, shared_values)?;
    let c = crate::transient_0::decode_int_32(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithEnum { inner: inner, c: c })
}

pub fn encode_sum_with_variants(value: &crate::data::SumWithVariants, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    match value {
        crate::data::SumWithVariants::VariantOne(value) => {
            crate::transient_0::encode_int_32(&0, writer, shared_values)?;
            crate::data::transient_0::encode_variant_one(value, writer, shared_values)?;
        },
        crate::data::SumWithVariants::VariantTwo(value) => {
            crate::transient_0::encode_int_32(&1, writer, shared_values)?;
            crate::data::transient_0::encode_variant_two(value, writer, shared_values)?;
        },
    };
    ::std::io::Result::Ok(())
}

pub fn decode_sum_with_variants(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::SumWithVariants> {
    ::std::io::Result::Ok(match &crate::transient_0::decode_int_32(reader, shared_values)? {
        0 => crate::data::SumWithVariants::VariantOne(crate::data::transient_0::decode_variant_one(reader, shared_values)?),
        1 => crate::data::SumWithVariants::VariantTwo(crate::data::transient_0::decode_variant_two(reader, shared_values)?),
        _ => ::std::result::Result::Err(::std::io::Error::new(::std::io::ErrorKind::InvalidData, "unrecognised variant tag for data.SumWithVariants"))?,
    })
}

pub fn encode_variant_one(value: &crate::data::VariantOne, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_32(&value.a, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_variant_one(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::VariantOne> {
    let a = crate::transient_0::decode_int_32(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::VariantOne { a: a })
}

pub fn encode_variant_two(value: &crate::data::VariantTwo, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::transient_0::encode_int_64(&value.a, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_variant_two(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::VariantTwo> {
    let a = crate::transient_0::decode_int_64(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::VariantTwo { a: a })
}

pub fn encode_sum_with_boxed_variants(value: &crate::data::SumWithBoxedVariants, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    match value {
        crate::data::SumWithBoxedVariants::VariantOne(value) => {
            crate::transient_0::encode_int_32(&0, writer, shared_values)?;
            crate::data::transient_0::encode_variant_one(value.as_ref(), writer, shared_values)?;
        },
        crate::data::SumWithBoxedVariants::VariantTwo(value) => {
            crate::transient_0::encode_int_32(&1, writer, shared_values)?;
            crate::data::transient_0::encode_variant_two(value.as_ref(), writer, shared_values)?;
        },
    };
    ::std::io::Result::Ok(())
}

pub fn decode_sum_with_boxed_variants(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::SumWithBoxedVariants> {
    ::std::io::Result::Ok(match &crate::transient_0::decode_int_32(reader, shared_values)? {
        0 => crate::data::SumWithBoxedVariants::VariantOne(::std::boxed::Box::new(crate::data::transient_0::decode_variant_one(reader, shared_values)?)),
        1 => crate::data::SumWithBoxedVariants::VariantTwo(::std::boxed::Box::new(crate::data::transient_0::decode_variant_two(reader, shared_values)?)),
        _ => ::std::result::Result::Err(::std::io::Error::new(::std::io::ErrorKind::InvalidData, "unrecognised variant tag for data.SumWithBoxedVariants"))?,
    })
}

pub fn encode_struct_with_sum(value: &crate::data::StructWithSum, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_sum_with_variants(&value.inner, writer, shared_values)?;
    crate::transient_0::encode_int_32(&value.b, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_sum(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithSum> {
    let inner = crate::data::transient_0::decode_sum_with_variants(reader, shared_values)?;
    let b = crate::transient_0::decode_int_32(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithSum { inner: inner, b: b })
}

pub fn encode_struct_with_native(value: &crate::data::StructWithNative, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_native(&value.a, writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_native(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithNative> {
    let a = crate::data::transient_0::decode_native(reader, shared_values)?;
    ::std::io::Result::Ok(crate::data::StructWithNative { a: a })
}

pub fn encode_struct_with_generic_native(value: &crate::data::StructWithGenericNative, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_generic_native(&value.a, writer, shared_values, |value, writer, shared_values| {
        crate::transient_0::encode_int_32(value, writer, shared_values)?;
        ::std::io::Result::Ok(())
    }, |value, writer, shared_values| {
        crate::transient_0::encode_string(value, writer, shared_values)?;
        ::std::io::Result::Ok(())
    })?;
    crate::data::transient_0::encode_generic_native(&value.b, writer, shared_values, |value, writer, shared_values| {
        match value {
            ::std::option::Option::Some(value) => {
                crate::transient_0::encode_bool(&true, writer, shared_values)?;
                crate::transient_0::encode_string(&value, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                crate::transient_0::encode_bool(&false, writer, shared_values)?;
            },
        };
        ::std::io::Result::Ok(())
    }, |value, writer, shared_values| {
        crate::data::transient_0::encode_generic_native(value, writer, shared_values, |value, writer, shared_values| {
            match value {
                ::std::option::Option::Some(value) => {
                    crate::transient_0::encode_bool(&true, writer, shared_values)?;
                    crate::transient_0::encode_string(&value, writer, shared_values)?;
                },
                ::std::option::Option::None => {
                    crate::transient_0::encode_bool(&false, writer, shared_values)?;
                },
            };
            ::std::io::Result::Ok(())
        }, |value, writer, shared_values| {
            crate::data::transient_0::encode_generic_native(value, writer, shared_values, |value, writer, shared_values| {
                crate::transient_0::encode_string(value, writer, shared_values)?;
                ::std::io::Result::Ok(())
            }, |value, writer, shared_values| {
                crate::transient_0::encode_string(value, writer, shared_values)?;
                ::std::io::Result::Ok(())
            })?;
            ::std::io::Result::Ok(())
        })?;
        ::std::io::Result::Ok(())
    })?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_generic_native(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithGenericNative> {
    let a = crate::data::transient_0::decode_generic_native(reader, shared_values, |reader, shared_values| ::std::io::Result::Ok(crate::transient_0::decode_int_32(reader, shared_values)?), |reader, shared_values| ::std::io::Result::Ok(crate::transient_0::decode_string(reader, shared_values)?))?;
    let b = crate::data::transient_0::decode_generic_native(reader, shared_values, |reader, shared_values| ::std::io::Result::Ok({
        let is_some = crate::transient_0::decode_bool(reader, shared_values)?;
        if is_some {
            ::std::option::Option::Some(crate::transient_0::decode_string(reader, shared_values)?)
        } else {
            ::std::option::Option::None
        }
    }), |reader, shared_values| ::std::io::Result::Ok(crate::data::transient_0::decode_generic_native(reader, shared_values, |reader, shared_values| ::std::io::Result::Ok({
        let is_some = crate::transient_0::decode_bool(reader, shared_values)?;
        if is_some {
            ::std::option::Option::Some(crate::transient_0::decode_string(reader, shared_values)?)
        } else {
            ::std::option::Option::None
        }
    }), |reader, shared_values| ::std::io::Result::Ok(crate::data::transient_0::decode_generic_native(reader, shared_values, |reader, shared_values| ::std::io::Result::Ok(crate::transient_0::decode_string(reader, shared_values)?), |reader, shared_values| ::std::io::Result::Ok(crate::transient_0::decode_string(reader, shared_values)?))?))?))?;
    ::std::io::Result::Ok(crate::data::StructWithGenericNative { a: a, b: b })
}

pub fn encode_struct_with_box(value: &crate::data::StructWithBox, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    crate::data::transient_0::encode_struct_with_int_32((&value.inner).as_ref(), writer, shared_values)?;
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_box(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithBox> {
    let inner = ::std::boxed::Box::new(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?);
    ::std::io::Result::Ok(crate::data::StructWithBox { inner: inner })
}

pub fn encode_struct_with_list_of_shared(value: &crate::data::StructWithListOfShared, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    {
        crate::transient_0::encode_int_64(&(((&value.inner).len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?, writer, shared_values)?;
        for element in &value.inner {
            {
                let ptr = ::std::sync::Arc::as_ptr(&element) as ::core::primitive::usize;
                match (shared_values.get(&ptr)).copied() {
                    ::std::option::Option::Some(id) => {
                        crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                    },
                    ::std::option::Option::None => {
                        let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                        crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                        shared_values.insert(ptr, id);
                        crate::data::transient_0::encode_struct_with_int_32(element.as_ref(), writer, shared_values)?;
                    },
                };
            };
        };
    };
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_list_of_shared(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithListOfShared> {
    let inner = {
        let len = crate::transient_0::decode_int_64(reader, shared_values)?;
        let mut elements = ::std::vec::Vec::with_capacity((len.try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?);
        for _ in 0..len {
            elements.push({
                let id = crate::transient_0::decode_int_64(reader, shared_values)?;
                if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
                    ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
                } else {
                    let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?);
                    shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
                    decoded_value
                }
            });
        };
        elements
    };
    ::std::io::Result::Ok(crate::data::StructWithListOfShared { inner: inner })
}

pub fn encode_struct_with_different_shared_types(value: &crate::data::StructWithDifferentSharedTypes, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    {
        let ptr = ::std::sync::Arc::as_ptr(&&value.a) as ::core::primitive::usize;
        match (shared_values.get(&ptr)).copied() {
            ::std::option::Option::Some(id) => {
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                shared_values.insert(ptr, id);
                crate::data::transient_0::encode_struct_with_int_32((&value.a).as_ref(), writer, shared_values)?;
            },
        };
    };
    {
        let ptr = ::std::sync::Arc::as_ptr(&&value.b) as ::core::primitive::usize;
        match (shared_values.get(&ptr)).copied() {
            ::std::option::Option::Some(id) => {
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                shared_values.insert(ptr, id);
                crate::data::transient_0::encode_struct_with_int_64((&value.b).as_ref(), writer, shared_values)?;
            },
        };
    };
    {
        let ptr = ::std::sync::Arc::as_ptr(&&value.c) as ::core::primitive::usize;
        match (shared_values.get(&ptr)).copied() {
            ::std::option::Option::Some(id) => {
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                shared_values.insert(ptr, id);
                crate::data::transient_0::encode_struct_with_int_32((&value.c).as_ref(), writer, shared_values)?;
            },
        };
    };
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_different_shared_types(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithDifferentSharedTypes> {
    let a = {
        let id = crate::transient_0::decode_int_64(reader, shared_values)?;
        if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
            ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
        } else {
            let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?);
            shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
            decoded_value
        }
    };
    let b = {
        let id = crate::transient_0::decode_int_64(reader, shared_values)?;
        if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
            ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
        } else {
            let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_64(reader, shared_values)?);
            shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
            decoded_value
        }
    };
    let c = {
        let id = crate::transient_0::decode_int_64(reader, shared_values)?;
        if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
            ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
        } else {
            let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_struct_with_int_32(reader, shared_values)?);
            shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
            decoded_value
        }
    };
    ::std::io::Result::Ok(crate::data::StructWithDifferentSharedTypes { a: a, b: b, c: c })
}

pub fn encode_struct_with_shared_sum_and_variant(value: &crate::data::StructWithSharedSumAndVariant, writer: &mut impl std::io::Write, shared_values: &mut ::std::collections::HashMap::<::core::primitive::usize, ::core::primitive::i64>) -> ::std::io::Result::<()> {
    {
        let ptr = ::std::sync::Arc::as_ptr(&&value.a) as ::core::primitive::usize;
        match (shared_values.get(&ptr)).copied() {
            ::std::option::Option::Some(id) => {
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                shared_values.insert(ptr, id);
                crate::data::transient_0::encode_sum_with_variants((&value.a).as_ref(), writer, shared_values)?;
            },
        };
    };
    {
        let ptr = ::std::sync::Arc::as_ptr(&&value.b) as ::core::primitive::usize;
        match (shared_values.get(&ptr)).copied() {
            ::std::option::Option::Some(id) => {
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
            },
            ::std::option::Option::None => {
                let id = ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?;
                crate::transient_0::encode_int_64(&id, writer, shared_values)?;
                shared_values.insert(ptr, id);
                crate::data::transient_0::encode_variant_one((&value.b).as_ref(), writer, shared_values)?;
            },
        };
    };
    ::std::io::Result::Ok(())
}

pub fn decode_struct_with_shared_sum_and_variant(reader: &mut impl std::io::Read, shared_values: &mut ::std::vec::Vec::<::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>>) -> ::std::io::Result::<crate::data::StructWithSharedSumAndVariant> {
    let a = {
        let id = crate::transient_0::decode_int_64(reader, shared_values)?;
        if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
            ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
        } else {
            let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_sum_with_variants(reader, shared_values)?);
            shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
            decoded_value
        }
    };
    let b = {
        let id = crate::transient_0::decode_int_64(reader, shared_values)?;
        if id < ((shared_values.len()).try_into()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))? {
            ((::std::sync::Arc::clone(&shared_values[(::core::primitive::usize::try_from(id)).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, error))?])).downcast()).map_err(|error| ::std::io::Error::new(::std::io::ErrorKind::InvalidData, "referenced value has wrong type"))?
        } else {
            let decoded_value = ::std::sync::Arc::new(crate::data::transient_0::decode_variant_one(reader, shared_values)?);
            shared_values.push(::std::sync::Arc::clone(&decoded_value) as ::std::sync::Arc::<dyn ::std::any::Any + ::std::marker::Sync + ::std::marker::Send>);
            decoded_value
        }
    };
    ::std::io::Result::Ok(crate::data::StructWithSharedSumAndVariant { a: a, b: b })
}