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 NestedStruct, aligned to 8 13 #[repr(transparent)] 14 #[derive(Clone, Copy, PartialEq)] 15 pub struct NestedStruct(pub [u8; 32]); 16 impl Default for NestedStruct { default() -> Self17 fn default() -> Self { 18 Self([0; 32]) 19 } 20 } 21 impl core::fmt::Debug for NestedStruct { fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result22 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { 23 f.debug_struct("NestedStruct") 24 .field("a", &self.a()) 25 .field("b", &self.b()) 26 .field("c", &self.c()) 27 .field("d", &self.d()) 28 .finish() 29 } 30 } 31 32 impl flatbuffers::SimpleToVerifyInSlice for NestedStruct {} 33 impl flatbuffers::SafeSliceAccess for NestedStruct {} 34 impl<'a> flatbuffers::Follow<'a> for NestedStruct { 35 type Inner = &'a NestedStruct; 36 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner37 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 38 <&'a NestedStruct>::follow(buf, loc) 39 } 40 } 41 impl<'a> flatbuffers::Follow<'a> for &'a NestedStruct { 42 type Inner = &'a NestedStruct; 43 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner44 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 45 flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) 46 } 47 } 48 impl<'b> flatbuffers::Push for NestedStruct { 49 type Output = NestedStruct; 50 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])51 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 52 let src = unsafe { 53 ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, Self::size()) 54 }; 55 dst.copy_from_slice(src); 56 } 57 } 58 impl<'b> flatbuffers::Push for &'b NestedStruct { 59 type Output = NestedStruct; 60 61 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])62 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 63 let src = unsafe { 64 ::core::slice::from_raw_parts(*self as *const NestedStruct as *const u8, Self::size()) 65 }; 66 dst.copy_from_slice(src); 67 } 68 } 69 70 impl<'a> flatbuffers::Verifiable for NestedStruct { 71 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>72 fn run_verifier( 73 v: &mut flatbuffers::Verifier, pos: usize 74 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 75 use self::flatbuffers::Verifiable; 76 v.in_buffer::<Self>(pos) 77 } 78 } 79 80 impl<'a> NestedStruct { 81 #[allow(clippy::too_many_arguments)] new( a: &[i32; 2], b: TestEnum, c: &[TestEnum; 2], d: &[i64; 2], ) -> Self82 pub fn new( 83 a: &[i32; 2], 84 b: TestEnum, 85 c: &[TestEnum; 2], 86 d: &[i64; 2], 87 ) -> Self { 88 let mut s = Self([0; 32]); 89 s.set_a(a); 90 s.set_b(b); 91 s.set_c(c); 92 s.set_d(d); 93 s 94 } 95 get_fully_qualified_name() -> &'static str96 pub const fn get_fully_qualified_name() -> &'static str { 97 "MyGame.Example.NestedStruct" 98 } 99 a(&'a self) -> flatbuffers::Array<'a, i32, 2>100 pub fn a(&'a self) -> flatbuffers::Array<'a, i32, 2> { 101 flatbuffers::Array::follow(&self.0, 0) 102 } 103 set_a(&mut self, items: &[i32; 2])104 pub fn set_a(&mut self, items: &[i32; 2]) { 105 flatbuffers::emplace_scalar_array(&mut self.0, 0, items); 106 } 107 b(&self) -> TestEnum108 pub fn b(&self) -> TestEnum { 109 let mut mem = core::mem::MaybeUninit::<TestEnum>::uninit(); 110 unsafe { 111 core::ptr::copy_nonoverlapping( 112 self.0[8..].as_ptr(), 113 mem.as_mut_ptr() as *mut u8, 114 core::mem::size_of::<TestEnum>(), 115 ); 116 mem.assume_init() 117 }.from_little_endian() 118 } 119 set_b(&mut self, x: TestEnum)120 pub fn set_b(&mut self, x: TestEnum) { 121 let x_le = x.to_little_endian(); 122 unsafe { 123 core::ptr::copy_nonoverlapping( 124 &x_le as *const TestEnum as *const u8, 125 self.0[8..].as_mut_ptr(), 126 core::mem::size_of::<TestEnum>(), 127 ); 128 } 129 } 130 c(&'a self) -> flatbuffers::Array<'a, TestEnum, 2>131 pub fn c(&'a self) -> flatbuffers::Array<'a, TestEnum, 2> { 132 flatbuffers::Array::follow(&self.0, 9) 133 } 134 set_c(&mut self, x: &[TestEnum; 2])135 pub fn set_c(&mut self, x: &[TestEnum; 2]) { 136 unsafe { 137 core::ptr::copy( 138 x.as_ptr() as *const u8, 139 self.0.as_mut_ptr().add(9), 140 2, 141 ); 142 } 143 } 144 d(&'a self) -> flatbuffers::Array<'a, i64, 2>145 pub fn d(&'a self) -> flatbuffers::Array<'a, i64, 2> { 146 flatbuffers::Array::follow(&self.0, 16) 147 } 148 set_d(&mut self, items: &[i64; 2])149 pub fn set_d(&mut self, items: &[i64; 2]) { 150 flatbuffers::emplace_scalar_array(&mut self.0, 16, items); 151 } 152 unpack(&self) -> NestedStructT153 pub fn unpack(&self) -> NestedStructT { 154 NestedStructT { 155 a: self.a().into(), 156 b: self.b(), 157 c: self.c().into(), 158 d: self.d().into(), 159 } 160 } 161 } 162 163 #[derive(Debug, Clone, PartialEq, Default)] 164 pub struct NestedStructT { 165 pub a: [i32; 2], 166 pub b: TestEnum, 167 pub c: [TestEnum; 2], 168 pub d: [i64; 2], 169 } 170 impl NestedStructT { pack(&self) -> NestedStruct171 pub fn pack(&self) -> NestedStruct { 172 NestedStruct::new( 173 &self.a, 174 self.b, 175 &self.c, 176 &self.d, 177 ) 178 } 179 } 180 181