hyperlight_common/flatbuffers/hyperlight/generated/
function_call_result_generated.rs1extern crate alloc;
4extern crate flatbuffers;
5use alloc::boxed::Box;
6use alloc::string::{String, ToString};
7use alloc::vec::Vec;
8use core::cmp::Ordering;
9use core::mem;
10
11use self::flatbuffers::{EndianScalar, Follow};
12use super::*;
13pub enum FunctionCallResultOffset {}
14#[derive(Copy, Clone, PartialEq)]
15
16pub struct FunctionCallResult<'a> {
17 pub _tab: flatbuffers::Table<'a>,
18}
19
20impl<'a> flatbuffers::Follow<'a> for FunctionCallResult<'a> {
21 type Inner = FunctionCallResult<'a>;
22 #[inline]
23 unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
24 Self {
25 _tab: unsafe { flatbuffers::Table::new(buf, loc) },
26 }
27 }
28}
29
30impl<'a> FunctionCallResult<'a> {
31 pub const VT_RESULT_TYPE: flatbuffers::VOffsetT = 4;
32 pub const VT_RESULT: flatbuffers::VOffsetT = 6;
33
34 #[inline]
35 pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
36 FunctionCallResult { _tab: table }
37 }
38 #[allow(unused_mut)]
39 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
40 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
41 args: &'args FunctionCallResultArgs,
42 ) -> flatbuffers::WIPOffset<FunctionCallResult<'bldr>> {
43 let mut builder = FunctionCallResultBuilder::new(_fbb);
44 if let Some(x) = args.result {
45 builder.add_result(x);
46 }
47 builder.add_result_type(args.result_type);
48 builder.finish()
49 }
50
51 #[inline]
52 pub fn result_type(&self) -> FunctionCallResultType {
53 unsafe {
57 self._tab
58 .get::<FunctionCallResultType>(
59 FunctionCallResult::VT_RESULT_TYPE,
60 Some(FunctionCallResultType::NONE),
61 )
62 .unwrap()
63 }
64 }
65 #[inline]
66 pub fn result(&self) -> flatbuffers::Table<'a> {
67 unsafe {
71 self._tab
72 .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
73 FunctionCallResult::VT_RESULT,
74 None,
75 )
76 .unwrap()
77 }
78 }
79 #[inline]
80 #[allow(non_snake_case)]
81 pub fn result_as_return_value_box(&self) -> Option<ReturnValueBox<'a>> {
82 if self.result_type() == FunctionCallResultType::ReturnValueBox {
83 let u = self.result();
84 Some(unsafe { ReturnValueBox::init_from_table(u) })
88 } else {
89 None
90 }
91 }
92
93 #[inline]
94 #[allow(non_snake_case)]
95 pub fn result_as_guest_error(&self) -> Option<GuestError<'a>> {
96 if self.result_type() == FunctionCallResultType::GuestError {
97 let u = self.result();
98 Some(unsafe { GuestError::init_from_table(u) })
102 } else {
103 None
104 }
105 }
106}
107
108impl flatbuffers::Verifiable for FunctionCallResult<'_> {
109 #[inline]
110 fn run_verifier(
111 v: &mut flatbuffers::Verifier,
112 pos: usize,
113 ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
114 use self::flatbuffers::Verifiable;
115 v.visit_table(pos)?
116 .visit_union::<FunctionCallResultType, _>(
117 "result_type",
118 Self::VT_RESULT_TYPE,
119 "result",
120 Self::VT_RESULT,
121 true,
122 |key, v, pos| match key {
123 FunctionCallResultType::ReturnValueBox => v
124 .verify_union_variant::<flatbuffers::ForwardsUOffset<ReturnValueBox>>(
125 "FunctionCallResultType::ReturnValueBox",
126 pos,
127 ),
128 FunctionCallResultType::GuestError => v
129 .verify_union_variant::<flatbuffers::ForwardsUOffset<GuestError>>(
130 "FunctionCallResultType::GuestError",
131 pos,
132 ),
133 _ => Ok(()),
134 },
135 )?
136 .finish();
137 Ok(())
138 }
139}
140pub struct FunctionCallResultArgs {
141 pub result_type: FunctionCallResultType,
142 pub result: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
143}
144impl<'a> Default for FunctionCallResultArgs {
145 #[inline]
146 fn default() -> Self {
147 FunctionCallResultArgs {
148 result_type: FunctionCallResultType::NONE,
149 result: None, }
151 }
152}
153
154pub struct FunctionCallResultBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
155 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
156 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
157}
158impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionCallResultBuilder<'a, 'b, A> {
159 #[inline]
160 pub fn add_result_type(&mut self, result_type: FunctionCallResultType) {
161 self.fbb_.push_slot::<FunctionCallResultType>(
162 FunctionCallResult::VT_RESULT_TYPE,
163 result_type,
164 FunctionCallResultType::NONE,
165 );
166 }
167 #[inline]
168 pub fn add_result(&mut self, result: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
169 self.fbb_
170 .push_slot_always::<flatbuffers::WIPOffset<_>>(FunctionCallResult::VT_RESULT, result);
171 }
172 #[inline]
173 pub fn new(
174 _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
175 ) -> FunctionCallResultBuilder<'a, 'b, A> {
176 let start = _fbb.start_table();
177 FunctionCallResultBuilder {
178 fbb_: _fbb,
179 start_: start,
180 }
181 }
182 #[inline]
183 pub fn finish(self) -> flatbuffers::WIPOffset<FunctionCallResult<'a>> {
184 let o = self.fbb_.end_table(self.start_);
185 self.fbb_
186 .required(o, FunctionCallResult::VT_RESULT, "result");
187 flatbuffers::WIPOffset::new(o.value())
188 }
189}
190
191impl core::fmt::Debug for FunctionCallResult<'_> {
192 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
193 let mut ds = f.debug_struct("FunctionCallResult");
194 ds.field("result_type", &self.result_type());
195 match self.result_type() {
196 FunctionCallResultType::ReturnValueBox => {
197 if let Some(x) = self.result_as_return_value_box() {
198 ds.field("result", &x)
199 } else {
200 ds.field(
201 "result",
202 &"InvalidFlatbuffer: Union discriminant does not match value.",
203 )
204 }
205 }
206 FunctionCallResultType::GuestError => {
207 if let Some(x) = self.result_as_guest_error() {
208 ds.field("result", &x)
209 } else {
210 ds.field(
211 "result",
212 &"InvalidFlatbuffer: Union discriminant does not match value.",
213 )
214 }
215 }
216 _ => {
217 let x: Option<()> = None;
218 ds.field("result", &x)
219 }
220 };
221 ds.finish()
222 }
223}