File: table_in_first_ns_generated.rs

package info (click to toggle)
flatbuffers 2.0.8%2Bdfsg1-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 14,308 kB
  • sloc: cpp: 44,808; python: 6,544; cs: 4,852; java: 4,389; ansic: 1,615; php: 1,455; xml: 973; javascript: 938; sh: 806; makefile: 35
file content (255 lines) | stat: -rw-r--r-- 9,387 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
extern crate alloc;
extern crate flatbuffers;
use alloc::boxed::Box;
use alloc::string::{String, ToString};
use alloc::vec::Vec;
use core::mem;
use core::cmp::Ordering;
use self::flatbuffers::{EndianScalar, Follow};
use super::*;
pub enum TableInFirstNSOffset {}
#[derive(Copy, Clone, PartialEq)]

pub struct TableInFirstNS<'a> {
  pub _tab: flatbuffers::Table<'a>,
}

impl<'a> flatbuffers::Follow<'a> for TableInFirstNS<'a> {
  type Inner = TableInFirstNS<'a>;
  #[inline]
  fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
    Self { _tab: flatbuffers::Table { buf, loc } }
  }
}

impl<'a> TableInFirstNS<'a> {
  pub const VT_FOO_TABLE: flatbuffers::VOffsetT = 4;
  pub const VT_FOO_ENUM: flatbuffers::VOffsetT = 6;
  pub const VT_FOO_UNION_TYPE: flatbuffers::VOffsetT = 8;
  pub const VT_FOO_UNION: flatbuffers::VOffsetT = 10;
  pub const VT_FOO_STRUCT: flatbuffers::VOffsetT = 12;

  pub const fn get_fully_qualified_name() -> &'static str {
    "NamespaceA.TableInFirstNS"
  }

  #[inline]
  pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
    TableInFirstNS { _tab: table }
  }
  #[allow(unused_mut)]
  pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
    _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
    args: &'args TableInFirstNSArgs<'args>
  ) -> flatbuffers::WIPOffset<TableInFirstNS<'bldr>> {
    let mut builder = TableInFirstNSBuilder::new(_fbb);
    if let Some(x) = args.foo_struct { builder.add_foo_struct(x); }
    if let Some(x) = args.foo_union { builder.add_foo_union(x); }
    if let Some(x) = args.foo_table { builder.add_foo_table(x); }
    builder.add_foo_union_type(args.foo_union_type);
    builder.add_foo_enum(args.foo_enum);
    builder.finish()
  }

  pub fn unpack(&self) -> TableInFirstNST {
    let foo_table = self.foo_table().map(|x| {
      Box::new(x.unpack())
    });
    let foo_enum = self.foo_enum();
    let foo_union = match self.foo_union_type() {
      namespace_b::UnionInNestedNS::NONE => namespace_b::UnionInNestedNST::NONE,
      namespace_b::UnionInNestedNS::TableInNestedNS => namespace_b::UnionInNestedNST::TableInNestedNS(Box::new(
        self.foo_union_as_table_in_nested_ns()
            .expect("Invalid union table, expected `namespace_b::UnionInNestedNS::TableInNestedNS`.")
            .unpack()
      )),
      _ => namespace_b::UnionInNestedNST::NONE,
    };
    let foo_struct = self.foo_struct().map(|x| {
      x.unpack()
    });
    TableInFirstNST {
      foo_table,
      foo_enum,
      foo_union,
      foo_struct,
    }
  }

  #[inline]
  pub fn foo_table(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
    self._tab.get::<flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, None)
  }
  #[inline]
  pub fn foo_enum(&self) -> namespace_b::EnumInNestedNS {
    self._tab.get::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, Some(namespace_b::EnumInNestedNS::A)).unwrap()
  }
  #[inline]
  pub fn foo_union_type(&self) -> namespace_b::UnionInNestedNS {
    self._tab.get::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, Some(namespace_b::UnionInNestedNS::NONE)).unwrap()
  }
  #[inline]
  pub fn foo_union(&self) -> Option<flatbuffers::Table<'a>> {
    self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(TableInFirstNS::VT_FOO_UNION, None)
  }
  #[inline]
  pub fn foo_struct(&self) -> Option<&'a namespace_b::StructInNestedNS> {
    self._tab.get::<namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, None)
  }
  #[inline]
  #[allow(non_snake_case)]
  pub fn foo_union_as_table_in_nested_ns(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
    if self.foo_union_type() == namespace_b::UnionInNestedNS::TableInNestedNS {
      self.foo_union().map(namespace_b::TableInNestedNS::init_from_table)
    } else {
      None
    }
  }

}

impl flatbuffers::Verifiable for TableInFirstNS<'_> {
  #[inline]
  fn run_verifier(
    v: &mut flatbuffers::Verifier, pos: usize
  ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
    use self::flatbuffers::Verifiable;
    v.visit_table(pos)?
     .visit_field::<flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("foo_table", Self::VT_FOO_TABLE, false)?
     .visit_field::<namespace_b::EnumInNestedNS>("foo_enum", Self::VT_FOO_ENUM, false)?
     .visit_union::<namespace_b::UnionInNestedNS, _>("foo_union_type", Self::VT_FOO_UNION_TYPE, "foo_union", Self::VT_FOO_UNION, false, |key, v, pos| {
        match key {
          namespace_b::UnionInNestedNS::TableInNestedNS => v.verify_union_variant::<flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("namespace_b::UnionInNestedNS::TableInNestedNS", pos),
          _ => Ok(()),
        }
     })?
     .visit_field::<namespace_b::StructInNestedNS>("foo_struct", Self::VT_FOO_STRUCT, false)?
     .finish();
    Ok(())
  }
}
pub struct TableInFirstNSArgs<'a> {
    pub foo_table: Option<flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'a>>>,
    pub foo_enum: namespace_b::EnumInNestedNS,
    pub foo_union_type: namespace_b::UnionInNestedNS,
    pub foo_union: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
    pub foo_struct: Option<&'a namespace_b::StructInNestedNS>,
}
impl<'a> Default for TableInFirstNSArgs<'a> {
  #[inline]
  fn default() -> Self {
    TableInFirstNSArgs {
      foo_table: None,
      foo_enum: namespace_b::EnumInNestedNS::A,
      foo_union_type: namespace_b::UnionInNestedNS::NONE,
      foo_union: None,
      foo_struct: None,
    }
  }
}

pub struct TableInFirstNSBuilder<'a: 'b, 'b> {
  fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
  start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b> TableInFirstNSBuilder<'a, 'b> {
  #[inline]
  pub fn add_foo_table(&mut self, foo_table: flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'b >>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, foo_table);
  }
  #[inline]
  pub fn add_foo_enum(&mut self, foo_enum: namespace_b::EnumInNestedNS) {
    self.fbb_.push_slot::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, foo_enum, namespace_b::EnumInNestedNS::A);
  }
  #[inline]
  pub fn add_foo_union_type(&mut self, foo_union_type: namespace_b::UnionInNestedNS) {
    self.fbb_.push_slot::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, foo_union_type, namespace_b::UnionInNestedNS::NONE);
  }
  #[inline]
  pub fn add_foo_union(&mut self, foo_union: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
    self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(TableInFirstNS::VT_FOO_UNION, foo_union);
  }
  #[inline]
  pub fn add_foo_struct(&mut self, foo_struct: &namespace_b::StructInNestedNS) {
    self.fbb_.push_slot_always::<&namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, foo_struct);
  }
  #[inline]
  pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> TableInFirstNSBuilder<'a, 'b> {
    let start = _fbb.start_table();
    TableInFirstNSBuilder {
      fbb_: _fbb,
      start_: start,
    }
  }
  #[inline]
  pub fn finish(self) -> flatbuffers::WIPOffset<TableInFirstNS<'a>> {
    let o = self.fbb_.end_table(self.start_);
    flatbuffers::WIPOffset::new(o.value())
  }
}

impl core::fmt::Debug for TableInFirstNS<'_> {
  fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
    let mut ds = f.debug_struct("TableInFirstNS");
      ds.field("foo_table", &self.foo_table());
      ds.field("foo_enum", &self.foo_enum());
      ds.field("foo_union_type", &self.foo_union_type());
      match self.foo_union_type() {
        namespace_b::UnionInNestedNS::TableInNestedNS => {
          if let Some(x) = self.foo_union_as_table_in_nested_ns() {
            ds.field("foo_union", &x)
          } else {
            ds.field("foo_union", &"InvalidFlatbuffer: Union discriminant does not match value.")
          }
        },
        _ => {
          let x: Option<()> = None;
          ds.field("foo_union", &x)
        },
      };
      ds.field("foo_struct", &self.foo_struct());
      ds.finish()
  }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInFirstNST {
  pub foo_table: Option<Box<namespace_b::TableInNestedNST>>,
  pub foo_enum: namespace_b::EnumInNestedNS,
  pub foo_union: namespace_b::UnionInNestedNST,
  pub foo_struct: Option<namespace_b::StructInNestedNST>,
}
impl Default for TableInFirstNST {
  fn default() -> Self {
    Self {
      foo_table: None,
      foo_enum: namespace_b::EnumInNestedNS::A,
      foo_union: namespace_b::UnionInNestedNST::NONE,
      foo_struct: None,
    }
  }
}
impl TableInFirstNST {
  pub fn pack<'b>(
    &self,
    _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
  ) -> flatbuffers::WIPOffset<TableInFirstNS<'b>> {
    let foo_table = self.foo_table.as_ref().map(|x|{
      x.pack(_fbb)
    });
    let foo_enum = self.foo_enum;
    let foo_union_type = self.foo_union.union_in_nested_ns_type();
    let foo_union = self.foo_union.pack(_fbb);
    let foo_struct_tmp = self.foo_struct.as_ref().map(|x| x.pack());
    let foo_struct = foo_struct_tmp.as_ref();
    TableInFirstNS::create(_fbb, &TableInFirstNSArgs{
      foo_table,
      foo_enum,
      foo_union_type,
      foo_union,
      foo_struct,
    })
  }
}