Debian Codegraph @

tests/monster_test_serialize/my_game/other_name_space/unused_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 Unused, aligned to 4
15 #[repr(transparent)]
16 #[derive(Clone, Copy, PartialEq)]
17 pub struct Unused(pub [u8; 4]);
18 impl Default for Unused {
19 fn default() -> Self {
20 Self([0; 4])
21 }
22 }
23 impl core::fmt::Debug for Unused {
24 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
25 f.debug_struct("Unused")
26 .field("a", &self.a())
27 .finish()
28 }
29 }
30
31 impl flatbuffers::SimpleToVerifyInSlice for Unused {}
32 impl<'a> flatbuffers::Follow<'a> for Unused {
33 type Inner = &'a Unused;
34 #[inline]
35 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
36 <&'a Unused>::follow(buf, loc)
37 }
38 }
39 impl<'a> flatbuffers::Follow<'a> for &'a Unused {
40 type Inner = &'a Unused;
41 #[inline]
42 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
43 flatbuffers::follow_cast_ref::<Unused>(buf, loc)
44 }
45 }
46 impl<'b> flatbuffers::Push for Unused {
47 type Output = Unused;
48 #[inline]
49 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
50 let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as flatbuffers::Push>::size());
51 dst.copy_from_slice(src);
52 }
53 #[inline]
54 fn alignment() -> flatbuffers::PushAlignment {
55 flatbuffers::PushAlignment::new(4)
56 }
57 }
58
59 impl<'a> flatbuffers::Verifiable for Unused {
60 #[inline]
61 fn run_verifier(
62 v: &mut flatbuffers::Verifier, pos: usize
63 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
64 use self::flatbuffers::Verifiable;
65 v.in_buffer::<Self>(pos)
66 }
67 }
68
69 impl Serialize for Unused {
70 fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
71 where
72 S: Serializer,
73 {
74 let mut s = serializer.serialize_struct("Unused", 1)?;
75 s.serialize_field("a", &self.a())?;
76 s.end()
77 }
78 }
79
80 impl<'a> Unused {
81 #[allow(clippy::too_many_arguments)]
82 pub fn new(
83 a: i32,
84 ) -> Self {
85 let mut s = Self([0; 4]);
86 s.set_a(a);
87 s
88 }
89
90 pub const fn get_fully_qualified_name() -> &'static str {
91 "MyGame.OtherNameSpace.Unused"
92 }
93
94 pub fn a(&self) -> i32 {
95 let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
96 // Safety:
97 // Created from a valid Table for this object
98 // Which contains a valid value in this slot
99 EndianScalar::from_little_endian(unsafe {
100 core::ptr::copy_nonoverlapping(
101 self.0[0..].as_ptr(),
102 mem.as_mut_ptr() as *mut u8,
103 core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
104 );
105 mem.assume_init()
106 })
107 }
108
109 pub fn set_a(&mut self, x: i32) {
110 let x_le = x.to_little_endian();
111 // Safety:
112 // Created from a valid Table for this object
113 // Which contains a valid value in this slot
114 unsafe {
115 core::ptr::copy_nonoverlapping(
116 &x_le as *const _ as *const u8,
117 self.0[0..].as_mut_ptr(),
118 core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
119 );
120 }
121 }
122
123 pub fn unpack(&self) -> UnusedT {
124 UnusedT {
125 a: self.a(),
126 }
127 }
128 }
129
130 #[derive(Debug, Clone, PartialEq, Default)]
131 pub struct UnusedT {
132 pub a: i32,
133 }
134 impl UnusedT {
135 pub fn pack(&self) -> Unused {
136 Unused::new(
137 self.a,
138 )
139 }
140 }
141