hyperlight_common/flatbuffers/hyperlight/generated/
function_call_result_generated.rs

1// 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::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: flatbuffers::Table::new(buf, loc),
26        }
27    }
28}
29
30impl<'a> FunctionCallResult<'a> {
31    pub const VT_RETURN_VALUE_TYPE: flatbuffers::VOffsetT = 4;
32    pub const VT_RETURN_VALUE: 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.return_value {
45            builder.add_return_value(x);
46        }
47        builder.add_return_value_type(args.return_value_type);
48        builder.finish()
49    }
50
51    #[inline]
52    pub fn return_value_type(&self) -> ReturnValue {
53        // Safety:
54        // Created from valid Table for this object
55        // which contains a valid value in this slot
56        unsafe {
57            self._tab
58                .get::<ReturnValue>(
59                    FunctionCallResult::VT_RETURN_VALUE_TYPE,
60                    Some(ReturnValue::NONE),
61                )
62                .unwrap()
63        }
64    }
65    #[inline]
66    pub fn return_value(&self) -> flatbuffers::Table<'a> {
67        // Safety:
68        // Created from valid Table for this object
69        // which contains a valid value in this slot
70        unsafe {
71            self._tab
72                .get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(
73                    FunctionCallResult::VT_RETURN_VALUE,
74                    None,
75                )
76                .unwrap()
77        }
78    }
79    #[inline]
80    #[allow(non_snake_case)]
81    pub fn return_value_as_hlint(&self) -> Option<hlint<'a>> {
82        if self.return_value_type() == ReturnValue::hlint {
83            let u = self.return_value();
84            // Safety:
85            // Created from a valid Table for this object
86            // Which contains a valid union in this slot
87            Some(unsafe { hlint::init_from_table(u) })
88        } else {
89            None
90        }
91    }
92
93    #[inline]
94    #[allow(non_snake_case)]
95    pub fn return_value_as_hluint(&self) -> Option<hluint<'a>> {
96        if self.return_value_type() == ReturnValue::hluint {
97            let u = self.return_value();
98            // Safety:
99            // Created from a valid Table for this object
100            // Which contains a valid union in this slot
101            Some(unsafe { hluint::init_from_table(u) })
102        } else {
103            None
104        }
105    }
106
107    #[inline]
108    #[allow(non_snake_case)]
109    pub fn return_value_as_hllong(&self) -> Option<hllong<'a>> {
110        if self.return_value_type() == ReturnValue::hllong {
111            let u = self.return_value();
112            // Safety:
113            // Created from a valid Table for this object
114            // Which contains a valid union in this slot
115            Some(unsafe { hllong::init_from_table(u) })
116        } else {
117            None
118        }
119    }
120
121    #[inline]
122    #[allow(non_snake_case)]
123    pub fn return_value_as_hlulong(&self) -> Option<hlulong<'a>> {
124        if self.return_value_type() == ReturnValue::hlulong {
125            let u = self.return_value();
126            // Safety:
127            // Created from a valid Table for this object
128            // Which contains a valid union in this slot
129            Some(unsafe { hlulong::init_from_table(u) })
130        } else {
131            None
132        }
133    }
134
135    #[inline]
136    #[allow(non_snake_case)]
137    pub fn return_value_as_hlfloat(&self) -> Option<hlfloat<'a>> {
138        if self.return_value_type() == ReturnValue::hlfloat {
139            let u = self.return_value();
140            // Safety:
141            // Created from a valid Table for this object
142            // Which contains a valid union in this slot
143            Some(unsafe { hlfloat::init_from_table(u) })
144        } else {
145            None
146        }
147    }
148
149    #[inline]
150    #[allow(non_snake_case)]
151    pub fn return_value_as_hldouble(&self) -> Option<hldouble<'a>> {
152        if self.return_value_type() == ReturnValue::hldouble {
153            let u = self.return_value();
154            // Safety:
155            // Created from a valid Table for this object
156            // Which contains a valid union in this slot
157            Some(unsafe { hldouble::init_from_table(u) })
158        } else {
159            None
160        }
161    }
162
163    #[inline]
164    #[allow(non_snake_case)]
165    pub fn return_value_as_hlstring(&self) -> Option<hlstring<'a>> {
166        if self.return_value_type() == ReturnValue::hlstring {
167            let u = self.return_value();
168            // Safety:
169            // Created from a valid Table for this object
170            // Which contains a valid union in this slot
171            Some(unsafe { hlstring::init_from_table(u) })
172        } else {
173            None
174        }
175    }
176
177    #[inline]
178    #[allow(non_snake_case)]
179    pub fn return_value_as_hlbool(&self) -> Option<hlbool<'a>> {
180        if self.return_value_type() == ReturnValue::hlbool {
181            let u = self.return_value();
182            // Safety:
183            // Created from a valid Table for this object
184            // Which contains a valid union in this slot
185            Some(unsafe { hlbool::init_from_table(u) })
186        } else {
187            None
188        }
189    }
190
191    #[inline]
192    #[allow(non_snake_case)]
193    pub fn return_value_as_hlvoid(&self) -> Option<hlvoid<'a>> {
194        if self.return_value_type() == ReturnValue::hlvoid {
195            let u = self.return_value();
196            // Safety:
197            // Created from a valid Table for this object
198            // Which contains a valid union in this slot
199            Some(unsafe { hlvoid::init_from_table(u) })
200        } else {
201            None
202        }
203    }
204
205    #[inline]
206    #[allow(non_snake_case)]
207    pub fn return_value_as_hlsizeprefixedbuffer(&self) -> Option<hlsizeprefixedbuffer<'a>> {
208        if self.return_value_type() == ReturnValue::hlsizeprefixedbuffer {
209            let u = self.return_value();
210            // Safety:
211            // Created from a valid Table for this object
212            // Which contains a valid union in this slot
213            Some(unsafe { hlsizeprefixedbuffer::init_from_table(u) })
214        } else {
215            None
216        }
217    }
218}
219
220impl flatbuffers::Verifiable for FunctionCallResult<'_> {
221    #[inline]
222    fn run_verifier(
223        v: &mut flatbuffers::Verifier,
224        pos: usize,
225    ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
226        use self::flatbuffers::Verifiable;
227        v.visit_table(pos)?
228            .visit_union::<ReturnValue, _>(
229                "return_value_type",
230                Self::VT_RETURN_VALUE_TYPE,
231                "return_value",
232                Self::VT_RETURN_VALUE,
233                true,
234                |key, v, pos| match key {
235                    ReturnValue::hlint => v
236                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlint>>(
237                            "ReturnValue::hlint",
238                            pos,
239                        ),
240                    ReturnValue::hluint => v
241                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hluint>>(
242                            "ReturnValue::hluint",
243                            pos,
244                        ),
245                    ReturnValue::hllong => v
246                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hllong>>(
247                            "ReturnValue::hllong",
248                            pos,
249                        ),
250                    ReturnValue::hlulong => v
251                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlulong>>(
252                            "ReturnValue::hlulong",
253                            pos,
254                        ),
255                    ReturnValue::hlfloat => v
256                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlfloat>>(
257                            "ReturnValue::hlfloat",
258                            pos,
259                        ),
260                    ReturnValue::hldouble => v
261                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hldouble>>(
262                            "ReturnValue::hldouble",
263                            pos,
264                        ),
265                    ReturnValue::hlstring => v
266                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlstring>>(
267                            "ReturnValue::hlstring",
268                            pos,
269                        ),
270                    ReturnValue::hlbool => v
271                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlbool>>(
272                            "ReturnValue::hlbool",
273                            pos,
274                        ),
275                    ReturnValue::hlvoid => v
276                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlvoid>>(
277                            "ReturnValue::hlvoid",
278                            pos,
279                        ),
280                    ReturnValue::hlsizeprefixedbuffer => v
281                        .verify_union_variant::<flatbuffers::ForwardsUOffset<hlsizeprefixedbuffer>>(
282                            "ReturnValue::hlsizeprefixedbuffer",
283                            pos,
284                        ),
285                    _ => Ok(()),
286                },
287            )?
288            .finish();
289        Ok(())
290    }
291}
292pub struct FunctionCallResultArgs {
293    pub return_value_type: ReturnValue,
294    pub return_value: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
295}
296impl<'a> Default for FunctionCallResultArgs {
297    #[inline]
298    fn default() -> Self {
299        FunctionCallResultArgs {
300            return_value_type: ReturnValue::NONE,
301            return_value: None, // required field
302        }
303    }
304}
305
306pub struct FunctionCallResultBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
307    fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
308    start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
309}
310impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FunctionCallResultBuilder<'a, 'b, A> {
311    #[inline]
312    pub fn add_return_value_type(&mut self, return_value_type: ReturnValue) {
313        self.fbb_.push_slot::<ReturnValue>(
314            FunctionCallResult::VT_RETURN_VALUE_TYPE,
315            return_value_type,
316            ReturnValue::NONE,
317        );
318    }
319    #[inline]
320    pub fn add_return_value(
321        &mut self,
322        return_value: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>,
323    ) {
324        self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(
325            FunctionCallResult::VT_RETURN_VALUE,
326            return_value,
327        );
328    }
329    #[inline]
330    pub fn new(
331        _fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
332    ) -> FunctionCallResultBuilder<'a, 'b, A> {
333        let start = _fbb.start_table();
334        FunctionCallResultBuilder {
335            fbb_: _fbb,
336            start_: start,
337        }
338    }
339    #[inline]
340    pub fn finish(self) -> flatbuffers::WIPOffset<FunctionCallResult<'a>> {
341        let o = self.fbb_.end_table(self.start_);
342        self.fbb_
343            .required(o, FunctionCallResult::VT_RETURN_VALUE, "return_value");
344        flatbuffers::WIPOffset::new(o.value())
345    }
346}
347
348impl core::fmt::Debug for FunctionCallResult<'_> {
349    fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
350        let mut ds = f.debug_struct("FunctionCallResult");
351        ds.field("return_value_type", &self.return_value_type());
352        match self.return_value_type() {
353            ReturnValue::hlint => {
354                if let Some(x) = self.return_value_as_hlint() {
355                    ds.field("return_value", &x)
356                } else {
357                    ds.field(
358                        "return_value",
359                        &"InvalidFlatbuffer: Union discriminant does not match value.",
360                    )
361                }
362            }
363            ReturnValue::hluint => {
364                if let Some(x) = self.return_value_as_hluint() {
365                    ds.field("return_value", &x)
366                } else {
367                    ds.field(
368                        "return_value",
369                        &"InvalidFlatbuffer: Union discriminant does not match value.",
370                    )
371                }
372            }
373            ReturnValue::hllong => {
374                if let Some(x) = self.return_value_as_hllong() {
375                    ds.field("return_value", &x)
376                } else {
377                    ds.field(
378                        "return_value",
379                        &"InvalidFlatbuffer: Union discriminant does not match value.",
380                    )
381                }
382            }
383            ReturnValue::hlulong => {
384                if let Some(x) = self.return_value_as_hlulong() {
385                    ds.field("return_value", &x)
386                } else {
387                    ds.field(
388                        "return_value",
389                        &"InvalidFlatbuffer: Union discriminant does not match value.",
390                    )
391                }
392            }
393            ReturnValue::hlfloat => {
394                if let Some(x) = self.return_value_as_hlfloat() {
395                    ds.field("return_value", &x)
396                } else {
397                    ds.field(
398                        "return_value",
399                        &"InvalidFlatbuffer: Union discriminant does not match value.",
400                    )
401                }
402            }
403            ReturnValue::hldouble => {
404                if let Some(x) = self.return_value_as_hldouble() {
405                    ds.field("return_value", &x)
406                } else {
407                    ds.field(
408                        "return_value",
409                        &"InvalidFlatbuffer: Union discriminant does not match value.",
410                    )
411                }
412            }
413            ReturnValue::hlstring => {
414                if let Some(x) = self.return_value_as_hlstring() {
415                    ds.field("return_value", &x)
416                } else {
417                    ds.field(
418                        "return_value",
419                        &"InvalidFlatbuffer: Union discriminant does not match value.",
420                    )
421                }
422            }
423            ReturnValue::hlbool => {
424                if let Some(x) = self.return_value_as_hlbool() {
425                    ds.field("return_value", &x)
426                } else {
427                    ds.field(
428                        "return_value",
429                        &"InvalidFlatbuffer: Union discriminant does not match value.",
430                    )
431                }
432            }
433            ReturnValue::hlvoid => {
434                if let Some(x) = self.return_value_as_hlvoid() {
435                    ds.field("return_value", &x)
436                } else {
437                    ds.field(
438                        "return_value",
439                        &"InvalidFlatbuffer: Union discriminant does not match value.",
440                    )
441                }
442            }
443            ReturnValue::hlsizeprefixedbuffer => {
444                if let Some(x) = self.return_value_as_hlsizeprefixedbuffer() {
445                    ds.field("return_value", &x)
446                } else {
447                    ds.field(
448                        "return_value",
449                        &"InvalidFlatbuffer: Union discriminant does not match value.",
450                    )
451                }
452            }
453            _ => {
454                let x: Option<()> = None;
455                ds.field("return_value", &x)
456            }
457        };
458        ds.finish()
459    }
460}
461#[inline]
462/// Verifies that a buffer of bytes contains a `FunctionCallResult`
463/// and returns it.
464/// Note that verification is still experimental and may not
465/// catch every error, or be maximally performant. For the
466/// previous, unchecked, behavior use
467/// `root_as_function_call_result_unchecked`.
468pub fn root_as_function_call_result(
469    buf: &[u8],
470) -> Result<FunctionCallResult, flatbuffers::InvalidFlatbuffer> {
471    flatbuffers::root::<FunctionCallResult>(buf)
472}
473#[inline]
474/// Verifies that a buffer of bytes contains a size prefixed
475/// `FunctionCallResult` and returns it.
476/// Note that verification is still experimental and may not
477/// catch every error, or be maximally performant. For the
478/// previous, unchecked, behavior use
479/// `size_prefixed_root_as_function_call_result_unchecked`.
480pub fn size_prefixed_root_as_function_call_result(
481    buf: &[u8],
482) -> Result<FunctionCallResult, flatbuffers::InvalidFlatbuffer> {
483    flatbuffers::size_prefixed_root::<FunctionCallResult>(buf)
484}
485#[inline]
486/// Verifies, with the given options, that a buffer of bytes
487/// contains a `FunctionCallResult` and returns it.
488/// Note that verification is still experimental and may not
489/// catch every error, or be maximally performant. For the
490/// previous, unchecked, behavior use
491/// `root_as_function_call_result_unchecked`.
492pub fn root_as_function_call_result_with_opts<'b, 'o>(
493    opts: &'o flatbuffers::VerifierOptions,
494    buf: &'b [u8],
495) -> Result<FunctionCallResult<'b>, flatbuffers::InvalidFlatbuffer> {
496    flatbuffers::root_with_opts::<FunctionCallResult<'b>>(opts, buf)
497}
498#[inline]
499/// Verifies, with the given verifier options, that a buffer of
500/// bytes contains a size prefixed `FunctionCallResult` and returns
501/// it. Note that verification is still experimental and may not
502/// catch every error, or be maximally performant. For the
503/// previous, unchecked, behavior use
504/// `root_as_function_call_result_unchecked`.
505pub fn size_prefixed_root_as_function_call_result_with_opts<'b, 'o>(
506    opts: &'o flatbuffers::VerifierOptions,
507    buf: &'b [u8],
508) -> Result<FunctionCallResult<'b>, flatbuffers::InvalidFlatbuffer> {
509    flatbuffers::size_prefixed_root_with_opts::<FunctionCallResult<'b>>(opts, buf)
510}
511#[inline]
512/// Assumes, without verification, that a buffer of bytes contains a FunctionCallResult and returns it.
513/// # Safety
514/// Callers must trust the given bytes do indeed contain a valid `FunctionCallResult`.
515pub unsafe fn root_as_function_call_result_unchecked(buf: &[u8]) -> FunctionCallResult {
516    flatbuffers::root_unchecked::<FunctionCallResult>(buf)
517}
518#[inline]
519/// Assumes, without verification, that a buffer of bytes contains a size prefixed FunctionCallResult and returns it.
520/// # Safety
521/// Callers must trust the given bytes do indeed contain a valid size prefixed `FunctionCallResult`.
522pub unsafe fn size_prefixed_root_as_function_call_result_unchecked(
523    buf: &[u8],
524) -> FunctionCallResult {
525    flatbuffers::size_prefixed_root_unchecked::<FunctionCallResult>(buf)
526}
527#[inline]
528pub fn finish_function_call_result_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
529    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
530    root: flatbuffers::WIPOffset<FunctionCallResult<'a>>,
531) {
532    fbb.finish(root, None);
533}
534
535#[inline]
536pub fn finish_size_prefixed_function_call_result_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
537    fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
538    root: flatbuffers::WIPOffset<FunctionCallResult<'a>>,
539) {
540    fbb.finish_size_prefixed(root, None);
541}