blob: cb93412f3d5aa39cb9689402b3995483d451d848 [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 {}
Austin Schuh2dd86a92022-09-14 21:19:23 -070030impl<'a> flatbuffers::Follow<'a> for Object {
31 type Inner = &'a Object;
32 #[inline]
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080033 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh2dd86a92022-09-14 21:19:23 -070034 <&'a Object>::follow(buf, loc)
35 }
36}
37impl<'a> flatbuffers::Follow<'a> for &'a Object {
38 type Inner = &'a Object;
39 #[inline]
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080040 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh2dd86a92022-09-14 21:19:23 -070041 flatbuffers::follow_cast_ref::<Object>(buf, loc)
42 }
43}
44impl<'b> flatbuffers::Push for Object {
45 type Output = Object;
46 #[inline]
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080047 unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
48 let src = ::core::slice::from_raw_parts(self as *const Object as *const u8, Self::size());
Austin Schuh2dd86a92022-09-14 21:19:23 -070049 dst.copy_from_slice(src);
50 }
51}
52
53impl<'a> flatbuffers::Verifiable for Object {
54 #[inline]
55 fn run_verifier(
56 v: &mut flatbuffers::Verifier, pos: usize
57 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
58 use self::flatbuffers::Verifiable;
59 v.in_buffer::<Self>(pos)
60 }
61}
62
63impl<'a> Object {
64 #[allow(clippy::too_many_arguments)]
65 pub fn new(
66 value: i32,
67 ) -> Self {
68 let mut s = Self([0; 4]);
69 s.set_value(value);
70 s
71 }
72
73 pub const fn get_fully_qualified_name() -> &'static str {
74 "Object"
75 }
76
77 pub fn value(&self) -> i32 {
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080078 let mut mem = core::mem::MaybeUninit::<<i32 as EndianScalar>::Scalar>::uninit();
79 // Safety:
80 // Created from a valid Table for this object
81 // Which contains a valid value in this slot
82 EndianScalar::from_little_endian(unsafe {
Austin Schuh2dd86a92022-09-14 21:19:23 -070083 core::ptr::copy_nonoverlapping(
84 self.0[0..].as_ptr(),
85 mem.as_mut_ptr() as *mut u8,
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080086 core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
Austin Schuh2dd86a92022-09-14 21:19:23 -070087 );
88 mem.assume_init()
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080089 })
Austin Schuh2dd86a92022-09-14 21:19:23 -070090 }
91
92 pub fn set_value(&mut self, x: i32) {
93 let x_le = x.to_little_endian();
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080094 // Safety:
95 // Created from a valid Table for this object
96 // Which contains a valid value in this slot
Austin Schuh2dd86a92022-09-14 21:19:23 -070097 unsafe {
98 core::ptr::copy_nonoverlapping(
James Kuszmaul3b15b0c2022-11-08 14:03:16 -080099 &x_le as *const _ as *const u8,
Austin Schuh2dd86a92022-09-14 21:19:23 -0700100 self.0[0..].as_mut_ptr(),
James Kuszmaul3b15b0c2022-11-08 14:03:16 -0800101 core::mem::size_of::<<i32 as EndianScalar>::Scalar>(),
Austin Schuh2dd86a92022-09-14 21:19:23 -0700102 );
103 }
104 }
105
106 pub fn unpack(&self) -> ObjectT {
107 ObjectT {
108 value: self.value(),
109 }
110 }
111}
112
113#[derive(Debug, Clone, PartialEq, Default)]
114pub(crate) struct ObjectT {
115 pub value: i32,
116}
117impl ObjectT {
118 pub fn pack(&self) -> Object {
119 Object::new(
120 self.value,
121 )
122 }
123}
124