blob: e352b758393ee4d3f50deb658bea1c42dc38bcc8 [file] [log] [blame]
Austin Schuhe89fa2d2019-08-14 20:24:23 -07001// automatically generated by the FlatBuffers compiler, do not modify
2
3
Austin Schuh272c6132020-11-14 16:37:52 -08004#![allow(unused_imports, dead_code)]
5
6use std::mem;
7use std::cmp::Ordering;
8
9extern crate flatbuffers;
10use self::flatbuffers::EndianScalar;
11
12#[allow(unused_imports, dead_code)]
Austin Schuhe89fa2d2019-08-14 20:24:23 -070013pub mod my_game {
Austin Schuhe89fa2d2019-08-14 20:24:23 -070014
15 use std::mem;
Austin Schuhe89fa2d2019-08-14 20:24:23 -070016 use std::cmp::Ordering;
17
18 extern crate flatbuffers;
19 use self::flatbuffers::EndianScalar;
Austin Schuh272c6132020-11-14 16:37:52 -080020#[allow(unused_imports, dead_code)]
Austin Schuhe89fa2d2019-08-14 20:24:23 -070021pub mod sample {
Austin Schuhe89fa2d2019-08-14 20:24:23 -070022
23 use std::mem;
Austin Schuhe89fa2d2019-08-14 20:24:23 -070024 use std::cmp::Ordering;
25
26 extern crate flatbuffers;
27 use self::flatbuffers::EndianScalar;
28
Austin Schuh272c6132020-11-14 16:37:52 -080029#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
30pub const ENUM_MIN_COLOR: i8 = 0;
31#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
32pub const ENUM_MAX_COLOR: i8 = 2;
33#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
Austin Schuhe89fa2d2019-08-14 20:24:23 -070034#[allow(non_camel_case_types)]
Austin Schuh272c6132020-11-14 16:37:52 -080035pub const ENUM_VALUES_COLOR: [Color; 3] = [
36 Color::Red,
37 Color::Green,
38 Color::Blue,
39];
40
41#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
42#[repr(transparent)]
43pub struct Color(pub i8);
44#[allow(non_upper_case_globals)]
45impl Color {
46 pub const Red: Self = Self(0);
47 pub const Green: Self = Self(1);
48 pub const Blue: Self = Self(2);
49
50 pub const ENUM_MIN: i8 = 0;
51 pub const ENUM_MAX: i8 = 2;
52 pub const ENUM_VALUES: &'static [Self] = &[
53 Self::Red,
54 Self::Green,
55 Self::Blue,
56 ];
57 /// Returns the variant's name or "" if unknown.
58 pub fn variant_name(self) -> Option<&'static str> {
59 match self {
60 Self::Red => Some("Red"),
61 Self::Green => Some("Green"),
62 Self::Blue => Some("Blue"),
63 _ => None,
64 }
65 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -070066}
Austin Schuh272c6132020-11-14 16:37:52 -080067impl std::fmt::Debug for Color {
68 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
69 if let Some(name) = self.variant_name() {
70 f.write_str(name)
71 } else {
72 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
73 }
74 }
75}
Austin Schuhe89fa2d2019-08-14 20:24:23 -070076impl<'a> flatbuffers::Follow<'a> for Color {
77 type Inner = Self;
78 #[inline]
79 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh272c6132020-11-14 16:37:52 -080080 Self(flatbuffers::read_scalar_at::<i8>(buf, loc))
Austin Schuhe89fa2d2019-08-14 20:24:23 -070081 }
82}
83
84impl flatbuffers::Push for Color {
85 type Output = Color;
86 #[inline]
87 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
Austin Schuh272c6132020-11-14 16:37:52 -080088 flatbuffers::emplace_scalar::<i8>(dst, self.0);
Austin Schuhe89fa2d2019-08-14 20:24:23 -070089 }
90}
91
Austin Schuh272c6132020-11-14 16:37:52 -080092impl flatbuffers::EndianScalar for Color {
93 #[inline]
94 fn to_little_endian(self) -> Self {
95 Self(i8::to_le(self.0))
96 }
97 #[inline]
98 fn from_little_endian(self) -> Self {
99 Self(i8::from_le(self.0))
100 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700101}
102
Austin Schuh272c6132020-11-14 16:37:52 -0800103#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
104pub const ENUM_MIN_EQUIPMENT: u8 = 0;
105#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
106pub const ENUM_MAX_EQUIPMENT: u8 = 1;
107#[deprecated(since = "1.13", note = "Use associated constants instead. This will no longer be generated in 2021.")]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700108#[allow(non_camel_case_types)]
Austin Schuh272c6132020-11-14 16:37:52 -0800109pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
110 Equipment::NONE,
111 Equipment::Weapon,
112];
113
114#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
115#[repr(transparent)]
116pub struct Equipment(pub u8);
117#[allow(non_upper_case_globals)]
118impl Equipment {
119 pub const NONE: Self = Self(0);
120 pub const Weapon: Self = Self(1);
121
122 pub const ENUM_MIN: u8 = 0;
123 pub const ENUM_MAX: u8 = 1;
124 pub const ENUM_VALUES: &'static [Self] = &[
125 Self::NONE,
126 Self::Weapon,
127 ];
128 /// Returns the variant's name or "" if unknown.
129 pub fn variant_name(self) -> Option<&'static str> {
130 match self {
131 Self::NONE => Some("NONE"),
132 Self::Weapon => Some("Weapon"),
133 _ => None,
134 }
135 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700136}
Austin Schuh272c6132020-11-14 16:37:52 -0800137impl std::fmt::Debug for Equipment {
138 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
139 if let Some(name) = self.variant_name() {
140 f.write_str(name)
141 } else {
142 f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
143 }
144 }
145}
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700146impl<'a> flatbuffers::Follow<'a> for Equipment {
147 type Inner = Self;
148 #[inline]
149 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh272c6132020-11-14 16:37:52 -0800150 Self(flatbuffers::read_scalar_at::<u8>(buf, loc))
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700151 }
152}
153
154impl flatbuffers::Push for Equipment {
155 type Output = Equipment;
156 #[inline]
157 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
Austin Schuh272c6132020-11-14 16:37:52 -0800158 flatbuffers::emplace_scalar::<u8>(dst, self.0);
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700159 }
160}
161
Austin Schuh272c6132020-11-14 16:37:52 -0800162impl flatbuffers::EndianScalar for Equipment {
163 #[inline]
164 fn to_little_endian(self) -> Self {
165 Self(u8::to_le(self.0))
166 }
167 #[inline]
168 fn from_little_endian(self) -> Self {
169 Self(u8::from_le(self.0))
170 }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700171}
172
173pub struct EquipmentUnionTableOffset {}
174// struct Vec3, aligned to 4
175#[repr(C, align(4))]
Austin Schuh272c6132020-11-14 16:37:52 -0800176#[derive(Clone, Copy, PartialEq)]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700177pub struct Vec3 {
178 x_: f32,
179 y_: f32,
180 z_: f32,
181} // pub struct Vec3
Austin Schuh272c6132020-11-14 16:37:52 -0800182impl std::fmt::Debug for Vec3 {
183 fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
184 f.debug_struct("Vec3")
185 .field("x", &self.x())
186 .field("y", &self.y())
187 .field("z", &self.z())
188 .finish()
189 }
190}
191
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700192impl flatbuffers::SafeSliceAccess for Vec3 {}
193impl<'a> flatbuffers::Follow<'a> for Vec3 {
194 type Inner = &'a Vec3;
195 #[inline]
196 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
197 <&'a Vec3>::follow(buf, loc)
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700198 }
199}
200impl<'a> flatbuffers::Follow<'a> for &'a Vec3 {
201 type Inner = &'a Vec3;
202 #[inline]
203 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
204 flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
205 }
206}
207impl<'b> flatbuffers::Push for Vec3 {
208 type Output = Vec3;
209 #[inline]
210 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
211 let src = unsafe {
212 ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
213 };
214 dst.copy_from_slice(src);
215 }
216}
217impl<'b> flatbuffers::Push for &'b Vec3 {
218 type Output = Vec3;
219
220 #[inline]
221 fn push(&self, dst: &mut [u8], _rest: &[u8]) {
222 let src = unsafe {
223 ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
224 };
225 dst.copy_from_slice(src);
226 }
227}
228
229
230impl Vec3 {
Austin Schuh272c6132020-11-14 16:37:52 -0800231 pub fn new(_x: f32, _y: f32, _z: f32) -> Self {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700232 Vec3 {
233 x_: _x.to_little_endian(),
234 y_: _y.to_little_endian(),
235 z_: _z.to_little_endian(),
236
237 }
238 }
Austin Schuh272c6132020-11-14 16:37:52 -0800239 pub fn x(&self) -> f32 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700240 self.x_.from_little_endian()
241 }
Austin Schuh272c6132020-11-14 16:37:52 -0800242 pub fn y(&self) -> f32 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700243 self.y_.from_little_endian()
244 }
Austin Schuh272c6132020-11-14 16:37:52 -0800245 pub fn z(&self) -> f32 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700246 self.z_.from_little_endian()
247 }
248}
249
250pub enum MonsterOffset {}
Austin Schuh272c6132020-11-14 16:37:52 -0800251#[derive(Copy, Clone, PartialEq)]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700252
253pub struct Monster<'a> {
254 pub _tab: flatbuffers::Table<'a>,
255}
256
257impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
258 type Inner = Monster<'a>;
259 #[inline]
260 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh272c6132020-11-14 16:37:52 -0800261 Self { _tab: flatbuffers::Table { buf, loc } }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700262 }
263}
264
265impl<'a> Monster<'a> {
266 #[inline]
267 pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
268 Monster {
269 _tab: table,
270 }
271 }
272 #[allow(unused_mut)]
273 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
274 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
275 args: &'args MonsterArgs<'args>) -> flatbuffers::WIPOffset<Monster<'bldr>> {
276 let mut builder = MonsterBuilder::new(_fbb);
Austin Schuh272c6132020-11-14 16:37:52 -0800277 if let Some(x) = args.path { builder.add_path(x); }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700278 if let Some(x) = args.equipped { builder.add_equipped(x); }
279 if let Some(x) = args.weapons { builder.add_weapons(x); }
280 if let Some(x) = args.inventory { builder.add_inventory(x); }
281 if let Some(x) = args.name { builder.add_name(x); }
282 if let Some(x) = args.pos { builder.add_pos(x); }
283 builder.add_hp(args.hp);
284 builder.add_mana(args.mana);
285 builder.add_equipped_type(args.equipped_type);
286 builder.add_color(args.color);
287 builder.finish()
288 }
289
290 pub const VT_POS: flatbuffers::VOffsetT = 4;
291 pub const VT_MANA: flatbuffers::VOffsetT = 6;
292 pub const VT_HP: flatbuffers::VOffsetT = 8;
293 pub const VT_NAME: flatbuffers::VOffsetT = 10;
294 pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
295 pub const VT_COLOR: flatbuffers::VOffsetT = 16;
296 pub const VT_WEAPONS: flatbuffers::VOffsetT = 18;
297 pub const VT_EQUIPPED_TYPE: flatbuffers::VOffsetT = 20;
298 pub const VT_EQUIPPED: flatbuffers::VOffsetT = 22;
Austin Schuh272c6132020-11-14 16:37:52 -0800299 pub const VT_PATH: flatbuffers::VOffsetT = 24;
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700300
301 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800302 pub fn pos(&self) -> Option<&'a Vec3> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700303 self._tab.get::<Vec3>(Monster::VT_POS, None)
304 }
305 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800306 pub fn mana(&self) -> i16 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700307 self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()
308 }
309 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800310 pub fn hp(&self) -> i16 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700311 self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()
312 }
313 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800314 pub fn name(&self) -> Option<&'a str> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700315 self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)
316 }
317 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800318 pub fn inventory(&self) -> Option<&'a [u8]> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700319 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None).map(|v| v.safe_slice())
320 }
321 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800322 pub fn color(&self) -> Color {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700323 self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()
324 }
325 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800326 pub fn weapons(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700327 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<flatbuffers::ForwardsUOffset<Weapon<'a>>>>>(Monster::VT_WEAPONS, None)
328 }
329 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800330 pub fn equipped_type(&self) -> Equipment {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700331 self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()
332 }
333 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800334 pub fn equipped(&self) -> Option<flatbuffers::Table<'a>> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700335 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)
336 }
337 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800338 pub fn path(&self) -> Option<&'a [Vec3]> {
339 self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<Vec3>>>(Monster::VT_PATH, None).map(|v| v.safe_slice() )
340 }
341 #[inline]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700342 #[allow(non_snake_case)]
Austin Schuh272c6132020-11-14 16:37:52 -0800343 pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700344 if self.equipped_type() == Equipment::Weapon {
Austin Schuh272c6132020-11-14 16:37:52 -0800345 self.equipped().map(Weapon::init_from_table)
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700346 } else {
347 None
348 }
349 }
350
351}
352
353pub struct MonsterArgs<'a> {
Austin Schuh272c6132020-11-14 16:37:52 -0800354 pub pos: Option<&'a Vec3>,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700355 pub mana: i16,
356 pub hp: i16,
Austin Schuh272c6132020-11-14 16:37:52 -0800357 pub name: Option<flatbuffers::WIPOffset<&'a str>>,
358 pub inventory: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700359 pub color: Color,
Austin Schuh272c6132020-11-14 16:37:52 -0800360 pub weapons: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>>>,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700361 pub equipped_type: Equipment,
362 pub equipped: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
Austin Schuh272c6132020-11-14 16:37:52 -0800363 pub path: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Vec3>>>,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700364}
365impl<'a> Default for MonsterArgs<'a> {
366 #[inline]
367 fn default() -> Self {
368 MonsterArgs {
369 pos: None,
370 mana: 150,
371 hp: 100,
372 name: None,
373 inventory: None,
374 color: Color::Blue,
375 weapons: None,
376 equipped_type: Equipment::NONE,
377 equipped: None,
Austin Schuh272c6132020-11-14 16:37:52 -0800378 path: None,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700379 }
380 }
381}
382pub struct MonsterBuilder<'a: 'b, 'b> {
383 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
384 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
385}
386impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
387 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800388 pub fn add_pos(&mut self, pos: &Vec3) {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700389 self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
390 }
391 #[inline]
392 pub fn add_mana(&mut self, mana: i16) {
393 self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
394 }
395 #[inline]
396 pub fn add_hp(&mut self, hp: i16) {
397 self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
398 }
399 #[inline]
400 pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
401 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
402 }
403 #[inline]
404 pub fn add_inventory(&mut self, inventory: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
405 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
406 }
407 #[inline]
408 pub fn add_color(&mut self, color: Color) {
409 self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
410 }
411 #[inline]
412 pub fn add_weapons(&mut self, weapons: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
413 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
414 }
415 #[inline]
416 pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
417 self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
418 }
419 #[inline]
420 pub fn add_equipped(&mut self, equipped: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
421 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
422 }
423 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800424 pub fn add_path(&mut self, path: flatbuffers::WIPOffset<flatbuffers::Vector<'b , Vec3>>) {
425 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
426 }
427 #[inline]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700428 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MonsterBuilder<'a, 'b> {
429 let start = _fbb.start_table();
430 MonsterBuilder {
431 fbb_: _fbb,
432 start_: start,
433 }
434 }
435 #[inline]
436 pub fn finish(self) -> flatbuffers::WIPOffset<Monster<'a>> {
437 let o = self.fbb_.end_table(self.start_);
438 flatbuffers::WIPOffset::new(o.value())
439 }
440}
441
Austin Schuh272c6132020-11-14 16:37:52 -0800442impl std::fmt::Debug for Monster<'_> {
443 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
444 let mut ds = f.debug_struct("Monster");
445 ds.field("pos", &self.pos());
446 ds.field("mana", &self.mana());
447 ds.field("hp", &self.hp());
448 ds.field("name", &self.name());
449 ds.field("inventory", &self.inventory());
450 ds.field("color", &self.color());
451 ds.field("weapons", &self.weapons());
452 ds.field("equipped_type", &self.equipped_type());
453 match self.equipped_type() {
454 Equipment::Weapon => {
455 if let Some(x) = self.equipped_as_weapon() {
456 ds.field("equipped", &x)
457 } else {
458 ds.field("equipped", &"InvalidFlatbuffer: Union discriminant does not match value.")
459 }
460 },
461 _ => {
462 let x: Option<()> = None;
463 ds.field("equipped", &x)
464 },
465 };
466 ds.field("path", &self.path());
467 ds.finish()
468 }
469}
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700470pub enum WeaponOffset {}
Austin Schuh272c6132020-11-14 16:37:52 -0800471#[derive(Copy, Clone, PartialEq)]
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700472
473pub struct Weapon<'a> {
474 pub _tab: flatbuffers::Table<'a>,
475}
476
477impl<'a> flatbuffers::Follow<'a> for Weapon<'a> {
478 type Inner = Weapon<'a>;
479 #[inline]
480 fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Austin Schuh272c6132020-11-14 16:37:52 -0800481 Self { _tab: flatbuffers::Table { buf, loc } }
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700482 }
483}
484
485impl<'a> Weapon<'a> {
486 #[inline]
487 pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
488 Weapon {
489 _tab: table,
490 }
491 }
492 #[allow(unused_mut)]
493 pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
494 _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
495 args: &'args WeaponArgs<'args>) -> flatbuffers::WIPOffset<Weapon<'bldr>> {
496 let mut builder = WeaponBuilder::new(_fbb);
497 if let Some(x) = args.name { builder.add_name(x); }
498 builder.add_damage(args.damage);
499 builder.finish()
500 }
501
502 pub const VT_NAME: flatbuffers::VOffsetT = 4;
503 pub const VT_DAMAGE: flatbuffers::VOffsetT = 6;
504
505 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800506 pub fn name(&self) -> Option<&'a str> {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700507 self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)
508 }
509 #[inline]
Austin Schuh272c6132020-11-14 16:37:52 -0800510 pub fn damage(&self) -> i16 {
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700511 self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()
512 }
513}
514
515pub struct WeaponArgs<'a> {
Austin Schuh272c6132020-11-14 16:37:52 -0800516 pub name: Option<flatbuffers::WIPOffset<&'a str>>,
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700517 pub damage: i16,
518}
519impl<'a> Default for WeaponArgs<'a> {
520 #[inline]
521 fn default() -> Self {
522 WeaponArgs {
523 name: None,
524 damage: 0,
525 }
526 }
527}
528pub struct WeaponBuilder<'a: 'b, 'b> {
529 fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
530 start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
531}
532impl<'a: 'b, 'b> WeaponBuilder<'a, 'b> {
533 #[inline]
534 pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
535 self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
536 }
537 #[inline]
538 pub fn add_damage(&mut self, damage: i16) {
539 self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
540 }
541 #[inline]
542 pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> WeaponBuilder<'a, 'b> {
543 let start = _fbb.start_table();
544 WeaponBuilder {
545 fbb_: _fbb,
546 start_: start,
547 }
548 }
549 #[inline]
550 pub fn finish(self) -> flatbuffers::WIPOffset<Weapon<'a>> {
551 let o = self.fbb_.end_table(self.start_);
552 flatbuffers::WIPOffset::new(o.value())
553 }
554}
555
Austin Schuh272c6132020-11-14 16:37:52 -0800556impl std::fmt::Debug for Weapon<'_> {
557 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
558 let mut ds = f.debug_struct("Weapon");
559 ds.field("name", &self.name());
560 ds.field("damage", &self.damage());
561 ds.finish()
562 }
563}
Austin Schuhe89fa2d2019-08-14 20:24:23 -0700564#[inline]
565pub fn get_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
566 flatbuffers::get_root::<Monster<'a>>(buf)
567}
568
569#[inline]
570pub fn get_size_prefixed_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
571 flatbuffers::get_size_prefixed_root::<Monster<'a>>(buf)
572}
573
574#[inline]
575pub fn finish_monster_buffer<'a, 'b>(
576 fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
577 root: flatbuffers::WIPOffset<Monster<'a>>) {
578 fbb.finish(root, None);
579}
580
581#[inline]
582pub fn finish_size_prefixed_monster_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Monster<'a>>) {
583 fbb.finish_size_prefixed(root, None);
584}
585} // pub mod Sample
586} // pub mod MyGame
587