| 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 StructInNestedNS, aligned to 4 |
| 13 |
#[repr(transparent)] |
| 14 |
#[derive(Clone, Copy, PartialEq)] |
| 15 |
pub struct StructInNestedNS(pub [u8; 8]); |
| 16 |
impl Default for StructInNestedNS { |
| 17 |
fn default() -> Self { |
| 18 |
Self([0; 8]) |
| 19 |
} |
| 20 |
} |
| 21 |
impl core::fmt::Debug for StructInNestedNS { |
| 22 |
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { |
| 23 |
f.debug_struct("StructInNestedNS") |
| 24 |
.field("a", &self.a()) |
| 25 |
.field("b", &self.b()) |
| 26 |
.finish() |
| 27 |
} |
| 28 |
} |
| 29 |
|
| 30 |
impl flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {} |
| 31 |
impl<'a> flatbuffers::Follow<'a> for StructInNestedNS { |
| 32 |
type Inner = &'a StructInNestedNS; |
| 33 |
#[inline] |
| 34 |
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { |
| 35 |
<&'a StructInNestedNS>::follow(buf, loc) |
| 36 |
} |
| 37 |
} |
| 38 |
impl<'a> flatbuffers::Follow<'a> for &'a StructInNestedNS { |
| 39 |
type Inner = &'a StructInNestedNS; |
| 40 |
#[inline] |
| 41 |
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { |
| 42 |
flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) |
| 43 |
} |
| 44 |
} |
| 45 |
impl<'b> flatbuffers::Push for StructInNestedNS { |
| 46 |
type Output = StructInNestedNS; |
| 47 |
#[inline] |
| 48 |
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { |
| 49 |
let src = ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, Self::size()); |
| 50 |
dst.copy_from_slice(src); |
| 51 |
} |
| 52 |
} |
| 53 |
|
| 54 |
impl<'a> flatbuffers::Verifiable for StructInNestedNS { |
| 55 |
#[inline] |
| 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> StructInNestedNS { |
| 65 |
#[allow(clippy::too_many_arguments)] |
| 66 |
pub fn new( |
| 67 |
a: i32, |
| 68 |
b: i32, |
| 69 |
) -> Self { |
| 70 |
let mut s = Self([0; 8]); |
| 71 |
s.set_a(a); |
| 72 |
s.set_b(b); |
| 73 |
s |
| 74 |
} |
| 75 |
|
| 76 |
pub const fn get_fully_qualified_name() -> &'static str { |
| 77 |
"NamespaceA.NamespaceB.StructInNestedNS" |
| 78 |
} |
| 79 |
|
| 80 |
pub fn a(&self) -> i32 { |
| 81 |
let mut mem = core::mem::MaybeUninit::<<i32 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::<<i32 as EndianScalar>::Scalar>(), |
| 90 |
); |
| 91 |
mem.assume_init() |
| 92 |
}) |
| 93 |
} |
| 94 |
|
| 95 |
pub fn set_a(&mut self, x: i32) { |
| 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::<<i32 as EndianScalar>::Scalar>(), |
| 105 |
); |
| 106 |
} |
| 107 |
} |
| 108 |
|
| 109 |
pub fn b(&self) -> i32 { |
| 110 |
let mut mem = core::mem::MaybeUninit::<<i32 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[4..].as_ptr(), |
| 117 |
mem.as_mut_ptr() as *mut u8, |
| 118 |
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(), |
| 119 |
); |
| 120 |
mem.assume_init() |
| 121 |
}) |
| 122 |
} |
| 123 |
|
| 124 |
pub fn set_b(&mut self, x: i32) { |
| 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[4..].as_mut_ptr(), |
| 133 |
core::mem::size_of::<<i32 as EndianScalar>::Scalar>(), |
| 134 |
); |
| 135 |
} |
| 136 |
} |
| 137 |
|
| 138 |
pub fn unpack(&self) -> StructInNestedNST { |
| 139 |
StructInNestedNST { |
| 140 |
a: self.a(), |
| 141 |
b: self.b(), |
| 142 |
} |
| 143 |
} |
| 144 |
} |
| 145 |
|
| 146 |
#[derive(Debug, Clone, PartialEq, Default)] |
| 147 |
pub struct StructInNestedNST { |
| 148 |
pub a: i32, |
| 149 |
pub b: i32, |
| 150 |
} |
| 151 |
impl StructInNestedNST { |
| 152 |
pub fn pack(&self) -> StructInNestedNS { |
| 153 |
StructInNestedNS::new( |
| 154 |
self.a, |
| 155 |
self.b, |
| 156 |
) |
| 157 |
} |
| 158 |
} |
| 159 |
|