Debian Codegraph @

tests/include_test2/my_game/other_name_space/unused_generated.rs

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