• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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<'a> flatbuffers::Follow<'a> for Test {
32   type Inner = &'a Test;
33   #[inline]
follow(buf: &'a [u8], loc: usize) -> Self::Inner34   unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
35     <&'a Test>::follow(buf, loc)
36   }
37 }
38 impl<'a> flatbuffers::Follow<'a> for &'a Test {
39   type Inner = &'a Test;
40   #[inline]
follow(buf: &'a [u8], loc: usize) -> Self::Inner41   unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
42     flatbuffers::follow_cast_ref::<Test>(buf, loc)
43   }
44 }
45 impl<'b> flatbuffers::Push for Test {
46     type Output = Test;
47     #[inline]
push(&self, dst: &mut [u8], _written_len: usize)48     unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
49         let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, Self::size());
50         dst.copy_from_slice(src);
51     }
52 }
53 
54 impl<'a> flatbuffers::Verifiable for Test {
55   #[inline]
run_verifier( v: &mut flatbuffers::Verifier, pos: usize ) -> Result<(), flatbuffers::InvalidFlatbuffer>56   fn run_verifier(
57     v: &mut flatbuffers::Verifier, pos: usize
58   ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
59     use self::flatbuffers::Verifiable;
60     v.in_buffer::<Self>(pos)
61   }
62 }
63 
64 impl<'a> Test {
65   #[allow(clippy::too_many_arguments)]
new( a: i16, b: i8, ) -> Self66   pub fn new(
67     a: i16,
68     b: i8,
69   ) -> Self {
70     let mut s = Self([0; 4]);
71     s.set_a(a);
72     s.set_b(b);
73     s
74   }
75 
get_fully_qualified_name() -> &'static str76   pub const fn get_fully_qualified_name() -> &'static str {
77     "MyGame.Example.Test"
78   }
79 
a(&self) -> i1680   pub fn a(&self) -> i16 {
81     let mut mem = core::mem::MaybeUninit::<<i16 as EndianScalar>::Scalar>::uninit();
82     // Safety:
83     // Created from a valid Table for this object
84     // Which contains a valid value in this slot
85     EndianScalar::from_little_endian(unsafe {
86       core::ptr::copy_nonoverlapping(
87         self.0[0..].as_ptr(),
88         mem.as_mut_ptr() as *mut u8,
89         core::mem::size_of::<<i16 as EndianScalar>::Scalar>(),
90       );
91       mem.assume_init()
92     })
93   }
94 
set_a(&mut self, x: i16)95   pub fn set_a(&mut self, x: i16) {
96     let x_le = x.to_little_endian();
97     // Safety:
98     // Created from a valid Table for this object
99     // Which contains a valid value in this slot
100     unsafe {
101       core::ptr::copy_nonoverlapping(
102         &x_le as *const _ as *const u8,
103         self.0[0..].as_mut_ptr(),
104         core::mem::size_of::<<i16 as EndianScalar>::Scalar>(),
105       );
106     }
107   }
108 
b(&self) -> i8109   pub fn b(&self) -> i8 {
110     let mut mem = core::mem::MaybeUninit::<<i8 as EndianScalar>::Scalar>::uninit();
111     // Safety:
112     // Created from a valid Table for this object
113     // Which contains a valid value in this slot
114     EndianScalar::from_little_endian(unsafe {
115       core::ptr::copy_nonoverlapping(
116         self.0[2..].as_ptr(),
117         mem.as_mut_ptr() as *mut u8,
118         core::mem::size_of::<<i8 as EndianScalar>::Scalar>(),
119       );
120       mem.assume_init()
121     })
122   }
123 
set_b(&mut self, x: i8)124   pub fn set_b(&mut self, x: i8) {
125     let x_le = x.to_little_endian();
126     // Safety:
127     // Created from a valid Table for this object
128     // Which contains a valid value in this slot
129     unsafe {
130       core::ptr::copy_nonoverlapping(
131         &x_le as *const _ as *const u8,
132         self.0[2..].as_mut_ptr(),
133         core::mem::size_of::<<i8 as EndianScalar>::Scalar>(),
134       );
135     }
136   }
137 
unpack(&self) -> TestT138   pub fn unpack(&self) -> TestT {
139     TestT {
140       a: self.a(),
141       b: self.b(),
142     }
143   }
144 }
145 
146 #[derive(Debug, Clone, PartialEq, Default)]
147 pub struct TestT {
148   pub a: i16,
149   pub b: i8,
150 }
151 impl TestT {
pack(&self) -> Test152   pub fn pack(&self) -> Test {
153     Test::new(
154       self.a,
155       self.b,
156     )
157   }
158 }
159 
160