diff options
Diffstat (limited to 'tests/monster_test_generated.rs')
-rw-r--r-- | tests/monster_test_generated.rs | 1018 |
1 files changed, 987 insertions, 31 deletions
diff --git a/tests/monster_test_generated.rs b/tests/monster_test_generated.rs index 59c8f142..3f8714ba 100644 --- a/tests/monster_test_generated.rs +++ b/tests/monster_test_generated.rs @@ -44,9 +44,7 @@ impl<'a> InParentNamespace<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - InParentNamespace { - _tab: table, - } + InParentNamespace { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -56,6 +54,10 @@ impl<'a> InParentNamespace<'a> { builder.finish() } + pub fn unpack(&self) -> InParentNamespaceT { + InParentNamespaceT { + } + } } impl flatbuffers::Verifiable for InParentNamespace<'_> { @@ -104,6 +106,19 @@ impl std::fmt::Debug for InParentNamespace<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct InParentNamespaceT { +} +impl InParentNamespaceT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<InParentNamespace<'b>> { + InParentNamespace::create(_fbb, &InParentNamespaceArgs{ + }) + } +} #[allow(unused_imports, dead_code)] pub mod example_2 { @@ -137,9 +152,7 @@ impl<'a> Monster<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Monster { - _tab: table, - } + Monster { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -149,6 +162,10 @@ impl<'a> Monster<'a> { builder.finish() } + pub fn unpack(&self) -> MonsterT { + MonsterT { + } + } } impl flatbuffers::Verifiable for Monster<'_> { @@ -197,6 +214,19 @@ impl std::fmt::Debug for Monster<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct MonsterT { +} +impl MonsterT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<Monster<'b>> { + Monster::create(_fbb, &MonsterArgs{ + }) + } +} } // pub mod Example2 #[allow(unused_imports, dead_code)] @@ -214,6 +244,7 @@ pub mod example { mod bitflags_color { flatbuffers::bitflags::bitflags! { /// Composite components of Monster color. + #[derive(Default)] pub struct Color: u8 { const Red = 1; /// \brief color Green @@ -280,7 +311,7 @@ pub const ENUM_VALUES_RACE: [Race; 4] = [ Race::Elf, ]; -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct Race(pub i8); #[allow(non_upper_case_globals)] @@ -372,7 +403,7 @@ pub const ENUM_VALUES_ANY: [Any; 4] = [ Any::MyGame_Example2_Monster, ]; -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct Any(pub u8); #[allow(non_upper_case_globals)] @@ -410,7 +441,6 @@ impl std::fmt::Debug for Any { } } } -pub struct AnyUnionTableOffset {} impl<'a> flatbuffers::Follow<'a> for Any { type Inner = Self; #[inline] @@ -452,6 +482,102 @@ impl<'a> flatbuffers::Verifiable for Any { } impl flatbuffers::SimpleToVerifyInSlice for Any {} +pub struct AnyUnionTableOffset {} + +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq)] +pub enum AnyT { + NONE, + Monster(Box<MonsterT>), + TestSimpleTableWithEnum(Box<TestSimpleTableWithEnumT>), + MyGameExample2Monster(Box<super::example_2::MonsterT>), +} +impl Default for AnyT { + fn default() -> Self { + Self::NONE + } +} +impl AnyT { + fn any_type(&self) -> Any { + match self { + Self::NONE => Any::NONE, + Self::Monster(_) => Any::Monster, + Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum, + Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster, + } + } + pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> { + match self { + Self::NONE => None, + Self::Monster(v) => Some(v.pack(fbb).as_union_value()), + Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()), + Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()), + } + } + /// If the union variant matches, return the owned MonsterT, setting the union to NONE. + pub fn take_monster(&mut self) -> Option<Box<MonsterT>> { + if let Self::Monster(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::Monster(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the MonsterT. + pub fn as_monster(&self) -> Option<&MonsterT> { + if let Self::Monster(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the MonsterT. + pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> { + if let Self::Monster(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. + pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> { + if let Self::TestSimpleTableWithEnum(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::TestSimpleTableWithEnum(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT. + pub fn as_test_simple_table_with_enum(&self) -> Option<&TestSimpleTableWithEnumT> { + if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT. + pub fn as_test_simple_table_with_enum_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> { + if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. + pub fn take_my_game_example_2_monster(&mut self) -> Option<Box<super::example_2::MonsterT>> { + if let Self::MyGameExample2Monster(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::MyGameExample2Monster(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the super::example_2::MonsterT. + pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> { + if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT. + pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> { + if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None } + } +} #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_ANY_UNIQUE_ALIASES: u8 = 0; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] @@ -465,7 +591,7 @@ pub const ENUM_VALUES_ANY_UNIQUE_ALIASES: [AnyUniqueAliases; 4] = [ AnyUniqueAliases::M2, ]; -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct AnyUniqueAliases(pub u8); #[allow(non_upper_case_globals)] @@ -503,7 +629,6 @@ impl std::fmt::Debug for AnyUniqueAliases { } } } -pub struct AnyUniqueAliasesUnionTableOffset {} impl<'a> flatbuffers::Follow<'a> for AnyUniqueAliases { type Inner = Self; #[inline] @@ -545,6 +670,102 @@ impl<'a> flatbuffers::Verifiable for AnyUniqueAliases { } impl flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {} +pub struct AnyUniqueAliasesUnionTableOffset {} + +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq)] +pub enum AnyUniqueAliasesT { + NONE, + M(Box<MonsterT>), + TS(Box<TestSimpleTableWithEnumT>), + M2(Box<super::example_2::MonsterT>), +} +impl Default for AnyUniqueAliasesT { + fn default() -> Self { + Self::NONE + } +} +impl AnyUniqueAliasesT { + fn any_unique_aliases_type(&self) -> AnyUniqueAliases { + match self { + Self::NONE => AnyUniqueAliases::NONE, + Self::M(_) => AnyUniqueAliases::M, + Self::TS(_) => AnyUniqueAliases::TS, + Self::M2(_) => AnyUniqueAliases::M2, + } + } + pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> { + match self { + Self::NONE => None, + Self::M(v) => Some(v.pack(fbb).as_union_value()), + Self::TS(v) => Some(v.pack(fbb).as_union_value()), + Self::M2(v) => Some(v.pack(fbb).as_union_value()), + } + } + /// If the union variant matches, return the owned MonsterT, setting the union to NONE. + pub fn take_m(&mut self) -> Option<Box<MonsterT>> { + if let Self::M(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::M(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the MonsterT. + pub fn as_m(&self) -> Option<&MonsterT> { + if let Self::M(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the MonsterT. + pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> { + if let Self::M(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. + pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> { + if let Self::TS(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::TS(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT. + pub fn as_ts(&self) -> Option<&TestSimpleTableWithEnumT> { + if let Self::TS(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT. + pub fn as_ts_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> { + if let Self::TS(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. + pub fn take_m2(&mut self) -> Option<Box<super::example_2::MonsterT>> { + if let Self::M2(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::M2(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the super::example_2::MonsterT. + pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> { + if let Self::M2(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT. + pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> { + if let Self::M2(v) = self { Some(v.as_mut()) } else { None } + } +} #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0; #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")] @@ -558,7 +779,7 @@ pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [ AnyAmbiguousAliases::M3, ]; -#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)] +#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)] #[repr(transparent)] pub struct AnyAmbiguousAliases(pub u8); #[allow(non_upper_case_globals)] @@ -596,7 +817,6 @@ impl std::fmt::Debug for AnyAmbiguousAliases { } } } -pub struct AnyAmbiguousAliasesUnionTableOffset {} impl<'a> flatbuffers::Follow<'a> for AnyAmbiguousAliases { type Inner = Self; #[inline] @@ -638,9 +858,105 @@ impl<'a> flatbuffers::Verifiable for AnyAmbiguousAliases { } impl flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {} +pub struct AnyAmbiguousAliasesUnionTableOffset {} + +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq)] +pub enum AnyAmbiguousAliasesT { + NONE, + M1(Box<MonsterT>), + M2(Box<MonsterT>), + M3(Box<MonsterT>), +} +impl Default for AnyAmbiguousAliasesT { + fn default() -> Self { + Self::NONE + } +} +impl AnyAmbiguousAliasesT { + fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases { + match self { + Self::NONE => AnyAmbiguousAliases::NONE, + Self::M1(_) => AnyAmbiguousAliases::M1, + Self::M2(_) => AnyAmbiguousAliases::M2, + Self::M3(_) => AnyAmbiguousAliases::M3, + } + } + pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> { + match self { + Self::NONE => None, + Self::M1(v) => Some(v.pack(fbb).as_union_value()), + Self::M2(v) => Some(v.pack(fbb).as_union_value()), + Self::M3(v) => Some(v.pack(fbb).as_union_value()), + } + } + /// If the union variant matches, return the owned MonsterT, setting the union to NONE. + pub fn take_m1(&mut self) -> Option<Box<MonsterT>> { + if let Self::M1(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::M1(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the MonsterT. + pub fn as_m1(&self) -> Option<&MonsterT> { + if let Self::M1(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the MonsterT. + pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> { + if let Self::M1(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned MonsterT, setting the union to NONE. + pub fn take_m2(&mut self) -> Option<Box<MonsterT>> { + if let Self::M2(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::M2(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the MonsterT. + pub fn as_m2(&self) -> Option<&MonsterT> { + if let Self::M2(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the MonsterT. + pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> { + if let Self::M2(v) = self { Some(v.as_mut()) } else { None } + } + /// If the union variant matches, return the owned MonsterT, setting the union to NONE. + pub fn take_m3(&mut self) -> Option<Box<MonsterT>> { + if let Self::M3(_) = self { + let v = std::mem::replace(self, Self::NONE); + if let Self::M3(w) = v { + Some(w) + } else { + unreachable!() + } + } else { + None + } + } + /// If the union variant matches, return a reference to the MonsterT. + pub fn as_m3(&self) -> Option<&MonsterT> { + if let Self::M3(v) = self { Some(v.as_ref()) } else { None } + } + /// If the union variant matches, return a mutable reference to the MonsterT. + pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> { + if let Self::M3(v) = self { Some(v.as_mut()) } else { None } + } +} // struct Test, aligned to 2 #[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Default)] pub struct Test(pub [u8; 4]); impl std::fmt::Debug for Test { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -760,11 +1076,31 @@ impl Test { } } + pub fn unpack(&self) -> TestT { + TestT { + a: self.a(), + b: self.b(), + } + } +} + +#[derive(Debug, Clone, PartialEq, Default)] +pub struct TestT { + pub a: i16, + pub b: i8, +} +impl TestT { + pub fn pack(&self) -> Test { + Test::new( + self.a, + self.b, + ) + } } // struct Vec3, aligned to 8 #[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Default)] pub struct Vec3(pub [u8; 32]); impl std::fmt::Debug for Vec3 { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -973,11 +1309,43 @@ impl Vec3 { self.0[26..26+4].copy_from_slice(&x.0) } + pub fn unpack(&self) -> Vec3T { + Vec3T { + x: self.x(), + y: self.y(), + z: self.z(), + test1: self.test1(), + test2: self.test2(), + test3: self.test3().unpack(), + } + } +} + +#[derive(Debug, Clone, PartialEq, Default)] +pub struct Vec3T { + pub x: f32, + pub y: f32, + pub z: f32, + pub test1: f64, + pub test2: Color, + pub test3: TestT, +} +impl Vec3T { + pub fn pack(&self) -> Vec3 { + Vec3::new( + self.x, + self.y, + self.z, + self.test1, + self.test2, + &self.test3.pack(), + ) + } } // struct Ability, aligned to 4 #[repr(transparent)] -#[derive(Clone, Copy, PartialEq)] +#[derive(Clone, Copy, PartialEq, Default)] pub struct Ability(pub [u8; 8]); impl std::fmt::Debug for Ability { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { @@ -1107,6 +1475,26 @@ impl Ability { } } + pub fn unpack(&self) -> AbilityT { + AbilityT { + id: self.id(), + distance: self.distance(), + } + } +} + +#[derive(Debug, Clone, PartialEq, Default)] +pub struct AbilityT { + pub id: u32, + pub distance: u32, +} +impl AbilityT { + pub fn pack(&self) -> Ability { + Ability::new( + self.id, + self.distance, + ) + } } pub enum TestSimpleTableWithEnumOffset {} @@ -1131,9 +1519,7 @@ impl<'a> TestSimpleTableWithEnum<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TestSimpleTableWithEnum { - _tab: table, - } + TestSimpleTableWithEnum { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -1144,6 +1530,12 @@ impl<'a> TestSimpleTableWithEnum<'a> { builder.finish() } + pub fn unpack(&self) -> TestSimpleTableWithEnumT { + let color = self.color(); + TestSimpleTableWithEnumT { + color, + } + } pub const VT_COLOR: flatbuffers::VOffsetT = 4; #[inline] @@ -1206,6 +1598,22 @@ impl std::fmt::Debug for TestSimpleTableWithEnum<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct TestSimpleTableWithEnumT { + pub color: Color, +} +impl TestSimpleTableWithEnumT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> { + let color = self.color; + TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{ + color, + }) + } +} pub enum StatOffset {} #[derive(Copy, Clone, PartialEq)] @@ -1228,9 +1636,7 @@ impl<'a> Stat<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Stat { - _tab: table, - } + Stat { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -1243,6 +1649,18 @@ impl<'a> Stat<'a> { builder.finish() } + pub fn unpack(&self) -> StatT { + let id = self.id().map(|x| { + x.to_string() + }); + let val = self.val(); + let count = self.count(); + StatT { + id, + val, + count, + } + } pub const VT_ID: flatbuffers::VOffsetT = 4; pub const VT_VAL: flatbuffers::VOffsetT = 6; pub const VT_COUNT: flatbuffers::VOffsetT = 8; @@ -1341,6 +1759,30 @@ impl std::fmt::Debug for Stat<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct StatT { + pub id: Option<String>, + pub val: i64, + pub count: u16, +} +impl StatT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<Stat<'b>> { + let id = self.id.as_ref().map(|x|{ + _fbb.create_string(x) + }); + let val = self.val; + let count = self.count; + Stat::create(_fbb, &StatArgs{ + id, + val, + count, + }) + } +} pub enum ReferrableOffset {} #[derive(Copy, Clone, PartialEq)] @@ -1363,9 +1805,7 @@ impl<'a> Referrable<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Referrable { - _tab: table, - } + Referrable { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -1376,6 +1816,12 @@ impl<'a> Referrable<'a> { builder.finish() } + pub fn unpack(&self) -> ReferrableT { + let id = self.id(); + ReferrableT { + id, + } + } pub const VT_ID: flatbuffers::VOffsetT = 4; #[inline] @@ -1448,6 +1894,22 @@ impl std::fmt::Debug for Referrable<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct ReferrableT { + pub id: u64, +} +impl ReferrableT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<Referrable<'b>> { + let id = self.id; + Referrable::create(_fbb, &ReferrableArgs{ + id, + }) + } +} pub enum MonsterOffset {} #[derive(Copy, Clone, PartialEq)] @@ -1471,9 +1933,7 @@ impl<'a> Monster<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - Monster { - _tab: table, - } + Monster { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -1533,6 +1993,209 @@ impl<'a> Monster<'a> { builder.finish() } + pub fn unpack(&self) -> MonsterT { + let pos = self.pos().map(|x| { + x.unpack() + }); + let mana = self.mana(); + let hp = self.hp(); + let name = { + let x = self.name(); + x.to_string() + }; + let inventory = self.inventory().map(|x| { + x.to_vec() + }); + let color = self.color(); + let test = match self.test_type() { + Any::NONE => AnyT::NONE, + Any::Monster => AnyT::Monster(Box::new( + self.test_as_monster() + .expect("Invalid union table, expected `Any::Monster`.") + .unpack() + )), + Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(Box::new( + self.test_as_test_simple_table_with_enum() + .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.") + .unpack() + )), + Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(Box::new( + self.test_as_my_game_example_2_monster() + .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.") + .unpack() + )), + _ => AnyT::NONE, + }; + let test4 = self.test4().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let testarrayofstring = self.testarrayofstring().map(|x| { + x.iter().map(|s| s.to_string()).collect() + }); + let testarrayoftables = self.testarrayoftables().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let enemy = self.enemy().map(|x| { + Box::new(x.unpack()) + }); + let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| { + x.to_vec() + }); + let testempty = self.testempty().map(|x| { + Box::new(x.unpack()) + }); + let testbool = self.testbool(); + let testhashs32_fnv1 = self.testhashs32_fnv1(); + let testhashu32_fnv1 = self.testhashu32_fnv1(); + let testhashs64_fnv1 = self.testhashs64_fnv1(); + let testhashu64_fnv1 = self.testhashu64_fnv1(); + let testhashs32_fnv1a = self.testhashs32_fnv1a(); + let testhashu32_fnv1a = self.testhashu32_fnv1a(); + let testhashs64_fnv1a = self.testhashs64_fnv1a(); + let testhashu64_fnv1a = self.testhashu64_fnv1a(); + let testarrayofbools = self.testarrayofbools().map(|x| { + x.to_vec() + }); + let testf = self.testf(); + let testf2 = self.testf2(); + let testf3 = self.testf3(); + let testarrayofstring2 = self.testarrayofstring2().map(|x| { + x.iter().map(|s| s.to_string()).collect() + }); + let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let flex = self.flex().map(|x| { + x.to_vec() + }); + let test5 = self.test5().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let vector_of_longs = self.vector_of_longs().map(|x| { + x.into_iter().collect() + }); + let vector_of_doubles = self.vector_of_doubles().map(|x| { + x.into_iter().collect() + }); + let parent_namespace_test = self.parent_namespace_test().map(|x| { + Box::new(x.unpack()) + }); + let vector_of_referrables = self.vector_of_referrables().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let single_weak_reference = self.single_weak_reference(); + let vector_of_weak_references = self.vector_of_weak_references().map(|x| { + x.into_iter().collect() + }); + let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + let co_owning_reference = self.co_owning_reference(); + let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| { + x.into_iter().collect() + }); + let non_owning_reference = self.non_owning_reference(); + let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| { + x.into_iter().collect() + }); + let any_unique = match self.any_unique_type() { + AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE, + AnyUniqueAliases::M => AnyUniqueAliasesT::M(Box::new( + self.any_unique_as_m() + .expect("Invalid union table, expected `AnyUniqueAliases::M`.") + .unpack() + )), + AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(Box::new( + self.any_unique_as_ts() + .expect("Invalid union table, expected `AnyUniqueAliases::TS`.") + .unpack() + )), + AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(Box::new( + self.any_unique_as_m2() + .expect("Invalid union table, expected `AnyUniqueAliases::M2`.") + .unpack() + )), + _ => AnyUniqueAliasesT::NONE, + }; + let any_ambiguous = match self.any_ambiguous_type() { + AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE, + AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(Box::new( + self.any_ambiguous_as_m1() + .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.") + .unpack() + )), + AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(Box::new( + self.any_ambiguous_as_m2() + .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.") + .unpack() + )), + AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(Box::new( + self.any_ambiguous_as_m3() + .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.") + .unpack() + )), + _ => AnyAmbiguousAliasesT::NONE, + }; + let vector_of_enums = self.vector_of_enums().map(|x| { + x.into_iter().collect() + }); + let signed_enum = self.signed_enum(); + let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| { + x.to_vec() + }); + let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| { + x.iter().map(|t| t.unpack()).collect() + }); + MonsterT { + pos, + mana, + hp, + name, + inventory, + color, + test, + test4, + testarrayofstring, + testarrayoftables, + enemy, + testnestedflatbuffer, + testempty, + testbool, + testhashs32_fnv1, + testhashu32_fnv1, + testhashs64_fnv1, + testhashu64_fnv1, + testhashs32_fnv1a, + testhashu32_fnv1a, + testhashs64_fnv1a, + testhashu64_fnv1a, + testarrayofbools, + testf, + testf2, + testf3, + testarrayofstring2, + testarrayofsortedstruct, + flex, + test5, + vector_of_longs, + vector_of_doubles, + parent_namespace_test, + vector_of_referrables, + single_weak_reference, + vector_of_weak_references, + vector_of_strong_referrables, + co_owning_reference, + vector_of_co_owning_references, + non_owning_reference, + vector_of_non_owning_references, + any_unique, + any_ambiguous, + vector_of_enums, + signed_enum, + testrequirednestedflatbuffer, + scalar_key_sorted_tables, + } + } pub const VT_POS: flatbuffers::VOffsetT = 4; pub const VT_MANA: flatbuffers::VOffsetT = 6; pub const VT_HP: flatbuffers::VOffsetT = 8; @@ -2443,6 +3106,216 @@ impl std::fmt::Debug for Monster<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct MonsterT { + pub pos: Option<Vec3T>, + pub mana: i16, + pub hp: i16, + pub name: String, + pub inventory: Option<Vec<u8>>, + pub color: Color, + pub test: AnyT, + pub test4: Option<Vec<TestT>>, + pub testarrayofstring: Option<Vec<String>>, + pub testarrayoftables: Option<Vec<MonsterT>>, + pub enemy: Option<Box<MonsterT>>, + pub testnestedflatbuffer: Option<Vec<u8>>, + pub testempty: Option<Box<StatT>>, + pub testbool: bool, + pub testhashs32_fnv1: i32, + pub testhashu32_fnv1: u32, + pub testhashs64_fnv1: i64, + pub testhashu64_fnv1: u64, + pub testhashs32_fnv1a: i32, + pub testhashu32_fnv1a: u32, + pub testhashs64_fnv1a: i64, + pub testhashu64_fnv1a: u64, + pub testarrayofbools: Option<Vec<bool>>, + pub testf: f32, + pub testf2: f32, + pub testf3: f32, + pub testarrayofstring2: Option<Vec<String>>, + pub testarrayofsortedstruct: Option<Vec<AbilityT>>, + pub flex: Option<Vec<u8>>, + pub test5: Option<Vec<TestT>>, + pub vector_of_longs: Option<Vec<i64>>, + pub vector_of_doubles: Option<Vec<f64>>, + pub parent_namespace_test: Option<Box<super::InParentNamespaceT>>, + pub vector_of_referrables: Option<Vec<ReferrableT>>, + pub single_weak_reference: u64, + pub vector_of_weak_references: Option<Vec<u64>>, + pub vector_of_strong_referrables: Option<Vec<ReferrableT>>, + pub co_owning_reference: u64, + pub vector_of_co_owning_references: Option<Vec<u64>>, + pub non_owning_reference: u64, + pub vector_of_non_owning_references: Option<Vec<u64>>, + pub any_unique: AnyUniqueAliasesT, + pub any_ambiguous: AnyAmbiguousAliasesT, + pub vector_of_enums: Option<Vec<Color>>, + pub signed_enum: Race, + pub testrequirednestedflatbuffer: Option<Vec<u8>>, + pub scalar_key_sorted_tables: Option<Vec<StatT>>, +} +impl MonsterT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<Monster<'b>> { + let pos_tmp = self.pos.as_ref().map(|x| x.pack()); + let pos = pos_tmp.as_ref(); + let mana = self.mana; + let hp = self.hp; + let name = Some({ + let x = &self.name; + _fbb.create_string(x) + }); + let inventory = self.inventory.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let color = self.color; + let test_type = self.test.any_type(); + let test = self.test.pack(_fbb); + let test4 = self.test4.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + }); + let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|s| s.as_ref()).collect();_fbb.create_vector_of_strings(&w) + }); + let testarrayoftables = self.testarrayoftables.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + }); + let enemy = self.enemy.as_ref().map(|x|{ + x.pack(_fbb) + }); + let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let testempty = self.testempty.as_ref().map(|x|{ + x.pack(_fbb) + }); + let testbool = self.testbool; + let testhashs32_fnv1 = self.testhashs32_fnv1; + let testhashu32_fnv1 = self.testhashu32_fnv1; + let testhashs64_fnv1 = self.testhashs64_fnv1; + let testhashu64_fnv1 = self.testhashu64_fnv1; + let testhashs32_fnv1a = self.testhashs32_fnv1a; + let testhashu32_fnv1a = self.testhashu32_fnv1a; + let testhashs64_fnv1a = self.testhashs64_fnv1a; + let testhashu64_fnv1a = self.testhashu64_fnv1a; + let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let testf = self.testf; + let testf2 = self.testf2; + let testf3 = self.testf3; + let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|s| s.as_ref()).collect();_fbb.create_vector_of_strings(&w) + }); + let testarrayofsortedstruct = self.testarrayofsortedstruct.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + }); + let flex = self.flex.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let test5 = self.test5.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + }); + let vector_of_longs = self.vector_of_longs.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{ + x.pack(_fbb) + }); + let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + }); + let single_weak_reference = self.single_weak_reference; + let vector_of_weak_references = self.vector_of_weak_references.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let vector_of_strong_referrables = self.vector_of_strong_referrables.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + }); + let co_owning_reference = self.co_owning_reference; + let vector_of_co_owning_references = self.vector_of_co_owning_references.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let non_owning_reference = self.non_owning_reference; + let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let any_unique_type = self.any_unique.any_unique_aliases_type(); + let any_unique = self.any_unique.pack(_fbb); + let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type(); + let any_ambiguous = self.any_ambiguous.pack(_fbb); + let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let signed_enum = self.signed_enum; + let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{ + let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + }); + Monster::create(_fbb, &MonsterArgs{ + pos, + mana, + hp, + name, + inventory, + color, + test_type, + test, + test4, + testarrayofstring, + testarrayoftables, + enemy, + testnestedflatbuffer, + testempty, + testbool, + testhashs32_fnv1, + testhashu32_fnv1, + testhashs64_fnv1, + testhashu64_fnv1, + testhashs32_fnv1a, + testhashu32_fnv1a, + testhashs64_fnv1a, + testhashu64_fnv1a, + testarrayofbools, + testf, + testf2, + testf3, + testarrayofstring2, + testarrayofsortedstruct, + flex, + test5, + vector_of_longs, + vector_of_doubles, + parent_namespace_test, + vector_of_referrables, + single_weak_reference, + vector_of_weak_references, + vector_of_strong_referrables, + co_owning_reference, + vector_of_co_owning_references, + non_owning_reference, + vector_of_non_owning_references, + any_unique_type, + any_unique, + any_ambiguous_type, + any_ambiguous, + vector_of_enums, + signed_enum, + testrequirednestedflatbuffer, + scalar_key_sorted_tables, + }) + } +} pub enum TypeAliasesOffset {} #[derive(Copy, Clone, PartialEq)] @@ -2465,9 +3338,7 @@ impl<'a> TypeAliases<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TypeAliases { - _tab: table, - } + TypeAliases { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -2489,6 +3360,38 @@ impl<'a> TypeAliases<'a> { builder.finish() } + pub fn unpack(&self) -> TypeAliasesT { + let i8_ = self.i8_(); + let u8_ = self.u8_(); + let i16_ = self.i16_(); + let u16_ = self.u16_(); + let i32_ = self.i32_(); + let u32_ = self.u32_(); + let i64_ = self.i64_(); + let u64_ = self.u64_(); + let f32_ = self.f32_(); + let f64_ = self.f64_(); + let v8 = self.v8().map(|x| { + x.to_vec() + }); + let vf64 = self.vf64().map(|x| { + x.into_iter().collect() + }); + TypeAliasesT { + i8_, + u8_, + i16_, + u16_, + i32_, + u32_, + i64_, + u64_, + f32_, + f64_, + v8, + vf64, + } + } pub const VT_I8_: flatbuffers::VOffsetT = 4; pub const VT_U8_: flatbuffers::VOffsetT = 6; pub const VT_I16_: flatbuffers::VOffsetT = 8; @@ -2694,6 +3597,59 @@ impl std::fmt::Debug for TypeAliases<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct TypeAliasesT { + pub i8_: i8, + pub u8_: u8, + pub i16_: i16, + pub u16_: u16, + pub i32_: i32, + pub u32_: u32, + pub i64_: i64, + pub u64_: u64, + pub f32_: f32, + pub f64_: f64, + pub v8: Option<Vec<i8>>, + pub vf64: Option<Vec<f64>>, +} +impl TypeAliasesT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<TypeAliases<'b>> { + let i8_ = self.i8_; + let u8_ = self.u8_; + let i16_ = self.i16_; + let u16_ = self.u16_; + let i32_ = self.i32_; + let u32_ = self.u32_; + let i64_ = self.i64_; + let u64_ = self.u64_; + let f32_ = self.f32_; + let f64_ = self.f64_; + let v8 = self.v8.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + let vf64 = self.vf64.as_ref().map(|x|{ + _fbb.create_vector(x) + }); + TypeAliases::create(_fbb, &TypeAliasesArgs{ + i8_, + u8_, + i16_, + u16_, + i32_, + u32_, + i64_, + u64_, + f32_, + f64_, + v8, + vf64, + }) + } +} #[inline] #[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")] pub fn get_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> { |