Debian Codegraph @

tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs

raw symbols SCIP
1 // automatically generated by the FlatBuffers compiler, do not modify
2 // @generated
3 extern crate alloc;
4 extern crate flatbuffers;
5 use alloc::boxed::Box;
6 use alloc::string::{String, ToString};
7 use alloc::vec::Vec;
8 use core::mem;
9 use core::cmp::Ordering;
10 extern crate serde;
11 use self::serde::ser::{Serialize, Serializer, SerializeStruct};
12 use self::flatbuffers::{EndianScalar, Follow};
13 use super::*;
14 // struct StructOfStructs, aligned to 4
15 #[repr(transparent)]
16 #[derive(Clone, Copy, PartialEq)]
17 pub struct StructOfStructs(pub [u8; 20]);
18 impl Default for StructOfStructs {
19 fn default() -> Self {
20 Self([0; 20])
21 }
22 }
23 impl core::fmt::Debug for StructOfStructs {
24 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
25 f.debug_struct("StructOfStructs")
26 .field("a", &self.a())
27 .field("b", &self.b())
28 .field("c", &self.c())
29 .finish()
30 }
31 }
32
33 impl flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
34 impl<'a> flatbuffers::Follow<'a> for StructOfStructs {
35 type Inner = &'a StructOfStructs;
36 #[inline]
37 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
38 <&'a StructOfStructs>::follow(buf, loc)
39 }
40 }
41 impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructs {
42 type Inner = &'a StructOfStructs;
43 #[inline]
44 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
45 flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc)
46 }
47 }
48 impl<'b> flatbuffers::Push for StructOfStructs {
49 type Output = StructOfStructs;
50 #[inline]
51 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
52 let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, <Self as flatbuffers::Push>::size());
53 dst.copy_from_slice(src);
54 }
55 #[inline]
56 fn alignment() -> flatbuffers::PushAlignment {
57 flatbuffers::PushAlignment::new(4)
58 }
59 }
60
61 impl<'a> flatbuffers::Verifiable for StructOfStructs {
62 #[inline]
63 fn run_verifier(
64 v: &mut flatbuffers::Verifier, pos: usize
65 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
66 use self::flatbuffers::Verifiable;
67 v.in_buffer::<Self>(pos)
68 }
69 }
70
71 impl Serialize for StructOfStructs {
72 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
73 where
74 S: Serializer,
75 {
76 let mut s = serializer.serialize_struct("StructOfStructs", 3)?;
77 s.serialize_field("a", &self.a())?;
78 s.serialize_field("b", &self.b())?;
79 s.serialize_field("c", &self.c())?;
80 s.end()
81 }
82 }
83
84 impl<'a> StructOfStructs {
85 #[allow(clippy::too_many_arguments)]
86 pub fn new(
87 a: &Ability,
88 b: &Test,
89 c: &Ability,
90 ) -> Self {
91 let mut s = Self([0; 20]);
92 s.set_a(a);
93 s.set_b(b);
94 s.set_c(c);
95 s
96 }
97
98 pub const fn get_fully_qualified_name() -> &'static str {
99 "MyGame.Example.StructOfStructs"
100 }
101
102 pub fn a(&self) -> &Ability {
103 // Safety:
104 // Created from a valid Table for this object
105 // Which contains a valid struct in this slot
106 unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
107 }
108
109 #[allow(clippy::identity_op)]
110 pub fn set_a(&mut self, x: &Ability) {
111 self.0[0..0 + 8].copy_from_slice(&x.0)
112 }
113
114 pub fn b(&self) -> &Test {
115 // Safety:
116 // Created from a valid Table for this object
117 // Which contains a valid struct in this slot
118 unsafe { &*(self.0[8..].as_ptr() as *const Test) }
119 }
120
121 #[allow(clippy::identity_op)]
122 pub fn set_b(&mut self, x: &Test) {
123 self.0[8..8 + 4].copy_from_slice(&x.0)
124 }
125
126 pub fn c(&self) -> &Ability {
127 // Safety:
128 // Created from a valid Table for this object
129 // Which contains a valid struct in this slot
130 unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
131 }
132
133 #[allow(clippy::identity_op)]
134 pub fn set_c(&mut self, x: &Ability) {
135 self.0[12..12 + 8].copy_from_slice(&x.0)
136 }
137
138 pub fn unpack(&self) -> StructOfStructsT {
139 StructOfStructsT {
140 a: self.a().unpack(),
141 b: self.b().unpack(),
142 c: self.c().unpack(),
143 }
144 }
145 }
146
147 #[derive(Debug, Clone, PartialEq, Default)]
148 pub struct StructOfStructsT {
149 pub a: AbilityT,
150 pub b: TestT,
151 pub c: AbilityT,
152 }
153 impl StructOfStructsT {
154 pub fn pack(&self) -> StructOfStructs {
155 StructOfStructs::new(
156 &self.a.pack(),
157 &self.b.pack(),
158 &self.c.pack(),
159 )
160 }
161 }
162