blob: 64419a9e04b782824547986a31f144d1077cd366 [file] [log] [blame]
Austin Schuh2dd86a92022-09-14 21:19:23 -07001// automatically generated by the FlatBuffers compiler, do not modify
2// @generated
3extern crate alloc;
4extern crate flatbuffers;
5use alloc::boxed::Box;
6use alloc::string::{String, ToString};
7use alloc::vec::Vec;
8use core::mem;
9use core::cmp::Ordering;
10use self::flatbuffers::{EndianScalar, Follow};
11use super::*;
12// struct Object, aligned to 4
13#[repr(transparent)]
14#[derive(Clone, Copy, PartialEq)]
15pub(crate) struct Object(pub [u8; 4]);
16impl Default for Object {
17 fn default() -> Self {
18 Self([0; 4])
19 }
20}
21impl core::fmt::Debug for Object {
22 fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
23 f.debug_struct("Object")
24 .field("value", &self.value())
25 .finish()
26 }
27}
28
29impl flatbuffers::SimpleToVerifyInSlice for Object {}
30impl flatbuffers::SafeSliceAccess for Object {}
31impl<'a> flatbuffers::Follow<'a> for Object {
32 type Inner = &'a Object;
33 #[inline]
34 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
35 <&'a Object>::follow(buf, loc)
36 }
37}
38impl<'a> flatbuffers::Follow<'a> for &'a Object {
39 type Inner = &'a Object;
40 #[inline]
41 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
42 flatbuffers::follow_cast_ref::<Object>(buf, loc)
43 }
44}
45impl<'b> flatbuffers::Push for Object {
46 type Output = Object;
47 #[inline]
48 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
49 let src = unsafe {
50 ::core::slice::from_raw_parts(self as *const Object as *const u8, Self::size())
51 };
52 dst.copy_from_slice(src);
53 }
54}
55impl<'b> flatbuffers::Push for &'b Object {
56 type Output = Object;
57
58 #[inline]
59 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
60 let src = unsafe {
61 ::core::slice::from_raw_parts(*self as *const Object as *const u8, Self::size())
62 };
63 dst.copy_from_slice(src);
64 }
65}
66
67impl<'a> flatbuffers::Verifiable for Object {
68 #[inline]
69 fn run_verifier(
70 v: &mut flatbuffers::Verifier, pos: usize
71 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
72 use self::flatbuffers::Verifiable;
73 v.in_buffer::<Self>(pos)
74 }
75}
76
77impl<'a> Object {
78 #[allow(clippy::too_many_arguments)]
79 pub fn new(
80 value: i32,
81 ) -> Self {
82 let mut s = Self([0; 4]);
83 s.set_value(value);
84 s
85 }
86
87 pub const fn get_fully_qualified_name() -> &'static str {
88 "Object"
89 }
90
91 pub fn value(&self) -> i32 {
92 let mut mem = core::mem::MaybeUninit::<i32>::uninit();
93 unsafe {
94 core::ptr::copy_nonoverlapping(
95 self.0[0..].as_ptr(),
96 mem.as_mut_ptr() as *mut u8,
97 core::mem::size_of::<i32>(),
98 );
99 mem.assume_init()
100 }.from_little_endian()
101 }
102
103 pub fn set_value(&mut self, x: i32) {
104 let x_le = x.to_little_endian();
105 unsafe {
106 core::ptr::copy_nonoverlapping(
107 &x_le as *const i32 as *const u8,
108 self.0[0..].as_mut_ptr(),
109 core::mem::size_of::<i32>(),
110 );
111 }
112 }
113
114 pub fn unpack(&self) -> ObjectT {
115 ObjectT {
116 value: self.value(),
117 }
118 }
119}
120
121#[derive(Debug, Clone, PartialEq, Default)]
122pub(crate) struct ObjectT {
123 pub value: i32,
124}
125impl ObjectT {
126 pub fn pack(&self) -> Object {
127 Object::new(
128 self.value,
129 )
130 }
131}
132