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 Test, aligned to 2 13 #[repr(transparent)] 14 #[derive(Clone, Copy, PartialEq)] 15 pub struct Test(pub [u8; 4]); 16 impl Default for Test { default() -> Self17 fn default() -> Self { 18 Self([0; 4]) 19 } 20 } 21 impl core::fmt::Debug for Test { 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("Test") 24 .field("a", &self.a()) 25 .field("b", &self.b()) 26 .finish() 27 } 28 } 29 30 impl flatbuffers::SimpleToVerifyInSlice for Test {} 31 impl flatbuffers::SafeSliceAccess for Test {} 32 impl<'a> flatbuffers::Follow<'a> for Test { 33 type Inner = &'a Test; 34 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner35 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 36 <&'a Test>::follow(buf, loc) 37 } 38 } 39 impl<'a> flatbuffers::Follow<'a> for &'a Test { 40 type Inner = &'a Test; 41 #[inline] follow(buf: &'a [u8], loc: usize) -> Self::Inner42 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { 43 flatbuffers::follow_cast_ref::<Test>(buf, loc) 44 } 45 } 46 impl<'b> flatbuffers::Push for Test { 47 type Output = Test; 48 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])49 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 50 let src = unsafe { 51 ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size()) 52 }; 53 dst.copy_from_slice(src); 54 } 55 } 56 impl<'b> flatbuffers::Push for &'b Test { 57 type Output = Test; 58 59 #[inline] push(&self, dst: &mut [u8], _rest: &[u8])60 fn push(&self, dst: &mut [u8], _rest: &[u8]) { 61 let src = unsafe { 62 ::core::slice::from_raw_parts(*self as *const Test as *const u8, Self::size()) 63 }; 64 dst.copy_from_slice(src); 65 } 66 } 67 68 impl<'a> flatbuffers::Verifiable for Test { 69 #[inline] run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>70 fn run_verifier( 71 v: &mut flatbuffers::Verifier, pos: usize 72 ) -> Result<(), flatbuffers::InvalidFlatbuffer> { 73 use self::flatbuffers::Verifiable; 74 v.in_buffer::<Self>(pos) 75 } 76 } 77 78 impl<'a> Test { 79 #[allow(clippy::too_many_arguments)] new( a: i16, b: i8, ) -> Self80 pub fn new( 81 a: i16, 82 b: i8, 83 ) -> Self { 84 let mut s = Self([0; 4]); 85 s.set_a(a); 86 s.set_b(b); 87 s 88 } 89 get_fully_qualified_name() -> &'static str90 pub const fn get_fully_qualified_name() -> &'static str { 91 "MyGame.Example.Test" 92 } 93 a(&self) -> i1694 pub fn a(&self) -> i16 { 95 let mut mem = core::mem::MaybeUninit::<i16>::uninit(); 96 unsafe { 97 core::ptr::copy_nonoverlapping( 98 self.0[0..].as_ptr(), 99 mem.as_mut_ptr() as *mut u8, 100 core::mem::size_of::<i16>(), 101 ); 102 mem.assume_init() 103 }.from_little_endian() 104 } 105 set_a(&mut self, x: i16)106 pub fn set_a(&mut self, x: i16) { 107 let x_le = x.to_little_endian(); 108 unsafe { 109 core::ptr::copy_nonoverlapping( 110 &x_le as *const i16 as *const u8, 111 self.0[0..].as_mut_ptr(), 112 core::mem::size_of::<i16>(), 113 ); 114 } 115 } 116 b(&self) -> i8117 pub fn b(&self) -> i8 { 118 let mut mem = core::mem::MaybeUninit::<i8>::uninit(); 119 unsafe { 120 core::ptr::copy_nonoverlapping( 121 self.0[2..].as_ptr(), 122 mem.as_mut_ptr() as *mut u8, 123 core::mem::size_of::<i8>(), 124 ); 125 mem.assume_init() 126 }.from_little_endian() 127 } 128 set_b(&mut self, x: i8)129 pub fn set_b(&mut self, x: i8) { 130 let x_le = x.to_little_endian(); 131 unsafe { 132 core::ptr::copy_nonoverlapping( 133 &x_le as *const i8 as *const u8, 134 self.0[2..].as_mut_ptr(), 135 core::mem::size_of::<i8>(), 136 ); 137 } 138 } 139 unpack(&self) -> TestT140 pub fn unpack(&self) -> TestT { 141 TestT { 142 a: self.a(), 143 b: self.b(), 144 } 145 } 146 } 147 148 #[derive(Debug, Clone, PartialEq, Default)] 149 pub struct TestT { 150 pub a: i16, 151 pub b: i8, 152 } 153 impl TestT { pack(&self) -> Test154 pub fn pack(&self) -> Test { 155 Test::new( 156 self.a, 157 self.b, 158 ) 159 } 160 } 161 162