forked from BigfootDev/flatbuffers
Refactor idl_gen_rust and Rust generated code to use consistent whitespace (#6809)
* Remove dead code in idl_gen_rust * Use 2space indentation in mod.rs * use In/DecrementIdentValue in idl_gen_rust Fix some whitespace too in generated code. * make default fn 2space ident * More 2space formatting * git clang format * make vs2015 happy Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
@@ -1,17 +1,17 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod sample {
|
||||
use super::*;
|
||||
pub mod sample {
|
||||
use super::*;
|
||||
mod color_generated;
|
||||
pub use self::color_generated::*;
|
||||
mod equipment_generated;
|
||||
pub use self::equipment_generated::*;
|
||||
mod vec_3_generated;
|
||||
pub use self::vec_3_generated::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
mod weapon_generated;
|
||||
pub use self::weapon_generated::*;
|
||||
} // sample
|
||||
mod color_generated;
|
||||
pub use self::color_generated::*;
|
||||
mod equipment_generated;
|
||||
pub use self::equipment_generated::*;
|
||||
mod vec_3_generated;
|
||||
pub use self::vec_3_generated::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
mod weapon_generated;
|
||||
pub use self::weapon_generated::*;
|
||||
} // sample
|
||||
} // my_game
|
||||
|
||||
@@ -12,90 +12,92 @@ pub struct Monster<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Monster<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Monster"
|
||||
}
|
||||
pub const VT_POS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_MANA: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_HP: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_WEAPONS: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_EQUIPPED_TYPE: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_EQUIPPED: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_PATH: flatbuffers::VOffsetT = 24;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MonsterArgs<'args>) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
if let Some(x) = args.path { builder.add_path(x); }
|
||||
if let Some(x) = args.equipped { builder.add_equipped(x); }
|
||||
if let Some(x) = args.weapons { builder.add_weapons(x); }
|
||||
if let Some(x) = args.inventory { builder.add_inventory(x); }
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
if let Some(x) = args.pos { builder.add_pos(x); }
|
||||
builder.add_hp(args.hp);
|
||||
builder.add_mana(args.mana);
|
||||
builder.add_equipped_type(args.equipped_type);
|
||||
builder.add_color(args.color);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Monster"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> MonsterT {
|
||||
let pos = self.pos().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
let mana = self.mana();
|
||||
let hp = self.hp();
|
||||
let name = self.name().map(|x| {
|
||||
x.to_string()
|
||||
});
|
||||
let inventory = self.inventory().map(|x| {
|
||||
x.to_vec()
|
||||
});
|
||||
let color = self.color();
|
||||
let weapons = self.weapons().map(|x| {
|
||||
x.iter().map(|t| t.unpack()).collect()
|
||||
});
|
||||
let equipped = match self.equipped_type() {
|
||||
Equipment::NONE => EquipmentT::NONE,
|
||||
Equipment::Weapon => EquipmentT::Weapon(Box::new(
|
||||
self.equipped_as_weapon()
|
||||
.expect("Invalid union table, expected `Equipment::Weapon`.")
|
||||
.unpack()
|
||||
)),
|
||||
_ => EquipmentT::NONE,
|
||||
};
|
||||
let path = self.path().map(|x| {
|
||||
x.iter().map(|t| t.unpack()).collect()
|
||||
});
|
||||
MonsterT {
|
||||
pos,
|
||||
mana,
|
||||
hp,
|
||||
name,
|
||||
inventory,
|
||||
color,
|
||||
weapons,
|
||||
equipped,
|
||||
path,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MonsterArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
if let Some(x) = args.path { builder.add_path(x); }
|
||||
if let Some(x) = args.equipped { builder.add_equipped(x); }
|
||||
if let Some(x) = args.weapons { builder.add_weapons(x); }
|
||||
if let Some(x) = args.inventory { builder.add_inventory(x); }
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
if let Some(x) = args.pos { builder.add_pos(x); }
|
||||
builder.add_hp(args.hp);
|
||||
builder.add_mana(args.mana);
|
||||
builder.add_equipped_type(args.equipped_type);
|
||||
builder.add_color(args.color);
|
||||
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 = self.name().map(|x| {
|
||||
x.to_string()
|
||||
});
|
||||
let inventory = self.inventory().map(|x| {
|
||||
x.to_vec()
|
||||
});
|
||||
let color = self.color();
|
||||
let weapons = self.weapons().map(|x| {
|
||||
x.iter().map(|t| t.unpack()).collect()
|
||||
});
|
||||
let equipped = match self.equipped_type() {
|
||||
Equipment::NONE => EquipmentT::NONE,
|
||||
Equipment::Weapon => EquipmentT::Weapon(Box::new(
|
||||
self.equipped_as_weapon()
|
||||
.expect("Invalid union table, expected `Equipment::Weapon`.")
|
||||
.unpack()
|
||||
)),
|
||||
_ => EquipmentT::NONE,
|
||||
};
|
||||
let path = self.path().map(|x| {
|
||||
x.iter().map(|t| t.unpack()).collect()
|
||||
});
|
||||
MonsterT {
|
||||
pos,
|
||||
mana,
|
||||
hp,
|
||||
name,
|
||||
inventory,
|
||||
color,
|
||||
weapons,
|
||||
equipped,
|
||||
path,
|
||||
}
|
||||
pub const VT_POS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_MANA: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_HP: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_WEAPONS: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_EQUIPPED_TYPE: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_EQUIPPED: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_PATH: flatbuffers::VOffsetT = 24;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pos(&self) -> Option<&'a Vec3> {
|
||||
@@ -187,21 +189,21 @@ pub struct MonsterArgs<'a> {
|
||||
pub path: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Vec3>>>,
|
||||
}
|
||||
impl<'a> Default for MonsterArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
pos: None,
|
||||
mana: 150,
|
||||
hp: 100,
|
||||
name: None,
|
||||
inventory: None,
|
||||
color: Color::Blue,
|
||||
weapons: None,
|
||||
equipped_type: Equipment::NONE,
|
||||
equipped: None,
|
||||
path: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
pos: None,
|
||||
mana: 150,
|
||||
hp: 100,
|
||||
name: None,
|
||||
inventory: None,
|
||||
color: Color::Blue,
|
||||
weapons: None,
|
||||
equipped_type: Equipment::NONE,
|
||||
equipped: None,
|
||||
path: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct MonsterBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -84,9 +84,9 @@ impl<'a> Vec3 {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Vec3"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Vec3"
|
||||
}
|
||||
|
||||
pub fn x(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<f32>::uninit();
|
||||
|
||||
@@ -12,44 +12,46 @@ pub struct Weapon<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Weapon<'a> {
|
||||
type Inner = Weapon<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Weapon<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Weapon<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Weapon"
|
||||
}
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_DAMAGE: flatbuffers::VOffsetT = 6;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Weapon { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args WeaponArgs<'args>) -> flatbuffers::WIPOffset<Weapon<'bldr>> {
|
||||
let mut builder = WeaponBuilder::new(_fbb);
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
builder.add_damage(args.damage);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Weapon"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> WeaponT {
|
||||
let name = self.name().map(|x| {
|
||||
x.to_string()
|
||||
});
|
||||
let damage = self.damage();
|
||||
WeaponT {
|
||||
name,
|
||||
damage,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Weapon { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args WeaponArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Weapon<'bldr>> {
|
||||
let mut builder = WeaponBuilder::new(_fbb);
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
builder.add_damage(args.damage);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> WeaponT {
|
||||
let name = self.name().map(|x| {
|
||||
x.to_string()
|
||||
});
|
||||
let damage = self.damage();
|
||||
WeaponT {
|
||||
name,
|
||||
damage,
|
||||
}
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_DAMAGE: flatbuffers::VOffsetT = 6;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn name(&self) -> Option<&'a str> {
|
||||
@@ -79,13 +81,13 @@ pub struct WeaponArgs<'a> {
|
||||
pub damage: i16,
|
||||
}
|
||||
impl<'a> Default for WeaponArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
WeaponArgs {
|
||||
name: None,
|
||||
damage: 0,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
WeaponArgs {
|
||||
name: None,
|
||||
damage: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct WeaponBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -182,31 +182,9 @@ FullType GetFullType(const Type &type) {
|
||||
return ftBool;
|
||||
}
|
||||
|
||||
// If the second parameter is false then wrap the first with Option<...>
|
||||
std::string WrapInOptionIfNotRequired(std::string s, bool required) {
|
||||
if (required) {
|
||||
return s;
|
||||
} else {
|
||||
return "Option<" + s + ">";
|
||||
}
|
||||
}
|
||||
|
||||
// If the second parameter is false then add .unwrap()
|
||||
std::string AddUnwrapIfRequired(std::string s, bool required) {
|
||||
if (required) {
|
||||
return s + ".unwrap()";
|
||||
} else {
|
||||
return s;
|
||||
}
|
||||
}
|
||||
|
||||
bool IsBitFlagsEnum(const EnumDef &enum_def) {
|
||||
return enum_def.attributes.Lookup("bit_flags") != nullptr;
|
||||
}
|
||||
bool IsBitFlagsEnum(const FieldDef &field) {
|
||||
EnumDef *ed = field.value.type.enum_def;
|
||||
return ed && IsBitFlagsEnum(*ed);
|
||||
}
|
||||
|
||||
// TableArgs make required non-scalars "Option<_>".
|
||||
// TODO(cneo): Rework how we do defaults and stuff.
|
||||
@@ -259,7 +237,7 @@ bool GenerateRustModuleRootFile(const Parser &parser,
|
||||
it++) {
|
||||
root_module.Insert(*it, parser.opts.filename_suffix);
|
||||
}
|
||||
CodeWriter code(" ");
|
||||
CodeWriter code(" ");
|
||||
// TODO(caspern): Move generated warning out of BaseGenerator.
|
||||
code +=
|
||||
"// Automatically generated by the Flatbuffers compiler. "
|
||||
@@ -384,6 +362,7 @@ class RustGenerator : public BaseGenerator {
|
||||
// clang-format on
|
||||
};
|
||||
for (auto kw = keywords; *kw; kw++) keywords_.insert(*kw);
|
||||
code_.SetPadding(" ");
|
||||
}
|
||||
|
||||
bool generate() {
|
||||
@@ -639,9 +618,9 @@ class RustGenerator : public BaseGenerator {
|
||||
|
||||
// Generate a comment from the schema.
|
||||
void GenComment(const std::vector<std::string> &dc, const char *prefix = "") {
|
||||
std::string text;
|
||||
::flatbuffers::GenComment(dc, &text, nullptr, prefix);
|
||||
code_ += text + "\\";
|
||||
for (auto it = dc.begin(); it != dc.end(); it++) {
|
||||
code_ += std::string(prefix) + "///" + *it;
|
||||
}
|
||||
}
|
||||
|
||||
// Return a Rust type from the table in idl.h.
|
||||
@@ -738,7 +717,9 @@ class RustGenerator : public BaseGenerator {
|
||||
const auto &ev = **it;
|
||||
code_.SetValue("VARIANT", Name(ev));
|
||||
code_.SetValue("VALUE", enum_def.ToString(ev));
|
||||
code_.IncrementIdentLevel();
|
||||
cb(ev);
|
||||
code_.DecrementIdentLevel();
|
||||
}
|
||||
}
|
||||
void ForAllEnumValues(const EnumDef &enum_def, std::function<void()> cb) {
|
||||
@@ -775,8 +756,8 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " #[derive(Default)]";
|
||||
code_ += " pub struct {{ENUM_NAME}}: {{BASE_TYPE}} {";
|
||||
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
|
||||
this->GenComment(ev.doc_comment, " ");
|
||||
code_ += " const {{VARIANT}} = {{VALUE}};";
|
||||
this->GenComment(ev.doc_comment, " ");
|
||||
code_ += " const {{VARIANT}} = {{VALUE}};";
|
||||
});
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
@@ -806,7 +787,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "pub const ENUM_VALUES_{{ENUM_NAME_CAPS}}: [{{ENUM_NAME}}; " +
|
||||
num_fields + "] = [";
|
||||
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
|
||||
code_ += " " + GetEnumValue(enum_def, ev) + ",";
|
||||
code_ += GetEnumValue(enum_def, ev) + ",";
|
||||
});
|
||||
code_ += "];";
|
||||
code_ += "";
|
||||
@@ -823,21 +804,21 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "#[allow(non_upper_case_globals)]";
|
||||
code_ += "impl {{ENUM_NAME}} {";
|
||||
ForAllEnumValues1(enum_def, [&](const EnumVal &ev) {
|
||||
this->GenComment(ev.doc_comment, " ");
|
||||
code_ += " pub const {{VARIANT}}: Self = Self({{VALUE}});";
|
||||
this->GenComment(ev.doc_comment);
|
||||
code_ += "pub const {{VARIANT}}: Self = Self({{VALUE}});";
|
||||
});
|
||||
code_ += "";
|
||||
// Generate Associated constants
|
||||
code_ += " pub const ENUM_MIN: {{BASE_TYPE}} = {{ENUM_MIN_BASE_VALUE}};";
|
||||
code_ += " pub const ENUM_MAX: {{BASE_TYPE}} = {{ENUM_MAX_BASE_VALUE}};";
|
||||
code_ += " pub const ENUM_VALUES: &'static [Self] = &[";
|
||||
ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
|
||||
ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
|
||||
code_ += " ];";
|
||||
code_ += " /// Returns the variant's name or \"\" if unknown.";
|
||||
code_ += " pub fn variant_name(self) -> Option<&'static str> {";
|
||||
code_ += " match self {";
|
||||
ForAllEnumValues(enum_def, [&]() {
|
||||
code_ += " Self::{{VARIANT}} => Some(\"{{VARIANT}}\"),";
|
||||
code_ += " Self::{{VARIANT}} => Some(\"{{VARIANT}}\"),";
|
||||
});
|
||||
code_ += " _ => None,";
|
||||
code_ += " }";
|
||||
@@ -933,7 +914,9 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("U_ELEMENT_NAME", MakeSnakeCase(Name(enum_val)));
|
||||
code_.SetValue("U_ELEMENT_TABLE_TYPE",
|
||||
NamespacedNativeName(*enum_val.union_type.struct_def));
|
||||
code_.IncrementIdentLevel();
|
||||
cb();
|
||||
code_.DecrementIdentLevel();
|
||||
}
|
||||
}
|
||||
void GenUnionObject(const EnumDef &enum_def) {
|
||||
@@ -949,7 +932,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "pub enum {{NATIVE_NAME}} {";
|
||||
code_ += " NONE,";
|
||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||
code_ += " {{NATIVE_VARIANT}}(Box<{{U_ELEMENT_TABLE_TYPE}}>),";
|
||||
code_ += "{{NATIVE_VARIANT}}(Box<{{U_ELEMENT_TABLE_TYPE}}>),";
|
||||
});
|
||||
code_ += "}";
|
||||
// Generate Default (NONE).
|
||||
@@ -969,7 +952,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " Self::NONE => {{ENUM_NAME}}::NONE,";
|
||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||
code_ +=
|
||||
" Self::{{NATIVE_VARIANT}}(_) => {{ENUM_NAME}}::"
|
||||
" Self::{{NATIVE_VARIANT}}(_) => {{ENUM_NAME}}::"
|
||||
"{{VARIANT_NAME}},";
|
||||
});
|
||||
code_ += " }";
|
||||
@@ -982,9 +965,8 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " match self {";
|
||||
code_ += " Self::NONE => None,";
|
||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||
code_ +=
|
||||
" Self::{{NATIVE_VARIANT}}(v) => "
|
||||
"Some(v.pack(fbb).as_union_value()),";
|
||||
code_ += " Self::{{NATIVE_VARIANT}}(v) => \\";
|
||||
code_ += "Some(v.pack(fbb).as_union_value()),";
|
||||
});
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
@@ -993,44 +975,44 @@ class RustGenerator : public BaseGenerator {
|
||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||
// Move accessor.
|
||||
code_ +=
|
||||
" /// If the union variant matches, return the owned "
|
||||
"/// If the union variant matches, return the owned "
|
||||
"{{U_ELEMENT_TABLE_TYPE}}, setting the union to NONE.";
|
||||
code_ +=
|
||||
" pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> "
|
||||
"pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> "
|
||||
"Option<Box<{{U_ELEMENT_TABLE_TYPE}}>> {";
|
||||
code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {";
|
||||
code_ += " let v = std::mem::replace(self, Self::NONE);";
|
||||
code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {";
|
||||
code_ += " Some(w)";
|
||||
code_ += " } else {";
|
||||
code_ += " unreachable!()";
|
||||
code_ += " }";
|
||||
code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {";
|
||||
code_ += " let v = std::mem::replace(self, Self::NONE);";
|
||||
code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {";
|
||||
code_ += " Some(w)";
|
||||
code_ += " } else {";
|
||||
code_ += " None";
|
||||
code_ += " unreachable!()";
|
||||
code_ += " }";
|
||||
code_ += " } else {";
|
||||
code_ += " None";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
// Immutable reference accessor.
|
||||
code_ +=
|
||||
" /// If the union variant matches, return a reference to the "
|
||||
"/// If the union variant matches, return a reference to the "
|
||||
"{{U_ELEMENT_TABLE_TYPE}}.";
|
||||
code_ +=
|
||||
" pub fn as_{{U_ELEMENT_NAME}}(&self) -> "
|
||||
"pub fn as_{{U_ELEMENT_NAME}}(&self) -> "
|
||||
"Option<&{{U_ELEMENT_TABLE_TYPE}}> {";
|
||||
code_ +=
|
||||
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
||||
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
||||
"{ Some(v.as_ref()) } else { None }";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
// Mutable reference accessor.
|
||||
code_ +=
|
||||
" /// If the union variant matches, return a mutable reference"
|
||||
"/// If the union variant matches, return a mutable reference"
|
||||
" to the {{U_ELEMENT_TABLE_TYPE}}.";
|
||||
code_ +=
|
||||
" pub fn as_{{U_ELEMENT_NAME}}_mut(&mut self) -> "
|
||||
"pub fn as_{{U_ELEMENT_NAME}}_mut(&mut self) -> "
|
||||
"Option<&mut {{U_ELEMENT_TABLE_TYPE}}> {";
|
||||
code_ +=
|
||||
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
||||
" if let Self::{{NATIVE_VARIANT}}(v) = self "
|
||||
"{ Some(v.as_mut()) } else { None }";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
});
|
||||
code_ += "}"; // End union methods impl.
|
||||
}
|
||||
@@ -1600,10 +1582,11 @@ class RustGenerator : public BaseGenerator {
|
||||
// Generates a fully-qualified name getter for use with --gen-name-strings
|
||||
void GenFullyQualifiedNameGetter(const StructDef &struct_def,
|
||||
const std::string &name) {
|
||||
code_ += " pub const fn get_fully_qualified_name() -> &'static str {";
|
||||
code_ += " \"" +
|
||||
struct_def.defined_namespace->GetFullyQualifiedName(name) + "\"";
|
||||
code_ += " }";
|
||||
const std::string fully_qualified_name =
|
||||
struct_def.defined_namespace->GetFullyQualifiedName(name);
|
||||
code_ += " pub const fn get_fully_qualified_name() -> &'static str {";
|
||||
code_ += " \"" + fully_qualified_name + "\"";
|
||||
code_ += " }";
|
||||
code_ += "";
|
||||
}
|
||||
|
||||
@@ -1639,7 +1622,9 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("FIELD_NAME", Name(field));
|
||||
code_.SetValue("BLDR_DEF_VAL", GetDefaultValue(field, kBuilder));
|
||||
code_.SetValue("DISCRIMINANT", UnionTypeFieldName(field));
|
||||
code_.IncrementIdentLevel();
|
||||
cb(field);
|
||||
code_.DecrementIdentLevel();
|
||||
};
|
||||
const auto &fields = struct_def.fields.vec;
|
||||
if (reversed) {
|
||||
@@ -1668,41 +1653,47 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
code_ += "impl<'a> flatbuffers::Follow<'a> for {{STRUCT_NAME}}<'a> {";
|
||||
code_ += " type Inner = {{STRUCT_NAME}}<'a>;";
|
||||
code_ += " #[inline]";
|
||||
code_ += " fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||
code_ += " Self { _tab: flatbuffers::Table { buf, loc } }";
|
||||
code_ += " }";
|
||||
code_ += " type Inner = {{STRUCT_NAME}}<'a>;";
|
||||
code_ += " #[inline]";
|
||||
code_ += " fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
|
||||
code_ += " Self { _tab: flatbuffers::Table { buf, loc } }";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
code_ += "impl<'a> {{STRUCT_NAME}}<'a> {";
|
||||
|
||||
// Generate field id constants.
|
||||
ForAllTableFields(struct_def, [&](const FieldDef &unused) {
|
||||
(void)unused;
|
||||
code_ +=
|
||||
"pub const {{OFFSET_NAME}}: flatbuffers::VOffsetT = "
|
||||
"{{OFFSET_VALUE}};";
|
||||
});
|
||||
code_ += "";
|
||||
|
||||
if (parser_.opts.generate_name_strings) {
|
||||
GenFullyQualifiedNameGetter(struct_def, struct_def.name);
|
||||
}
|
||||
|
||||
code_ += " #[inline]";
|
||||
code_ += " #[inline]";
|
||||
code_ +=
|
||||
" pub fn init_from_table(table: flatbuffers::Table<'a>) -> "
|
||||
" pub fn init_from_table(table: flatbuffers::Table<'a>) -> "
|
||||
"Self {";
|
||||
code_ += " {{STRUCT_NAME}} { _tab: table }";
|
||||
code_ += " }";
|
||||
code_ += " {{STRUCT_NAME}} { _tab: table }";
|
||||
code_ += " }";
|
||||
|
||||
// Generate a convenient create* function that uses the above builder
|
||||
// to create a table in one function call.
|
||||
code_.SetValue("MAYBE_US", struct_def.fields.vec.size() == 0 ? "_" : "");
|
||||
code_.SetValue("MAYBE_LT",
|
||||
TableBuilderArgsNeedsLifetime(struct_def) ? "<'args>" : "");
|
||||
code_ += " #[allow(unused_mut)]";
|
||||
code_ += " pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(";
|
||||
code_ +=
|
||||
" _fbb: "
|
||||
"&'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,";
|
||||
code_ +=
|
||||
" {{MAYBE_US}}args: &'args {{STRUCT_NAME}}Args{{MAYBE_LT}})"
|
||||
" -> flatbuffers::WIPOffset<{{STRUCT_NAME}}<'bldr>> {";
|
||||
code_ += " #[allow(unused_mut)]";
|
||||
code_ += " pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(";
|
||||
code_ += " _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,";
|
||||
code_ += " {{MAYBE_US}}args: &'args {{STRUCT_NAME}}Args{{MAYBE_LT}}";
|
||||
code_ += " ) -> flatbuffers::WIPOffset<{{STRUCT_NAME}}<'bldr>> {";
|
||||
|
||||
code_ += " let mut builder = {{STRUCT_NAME}}Builder::new(_fbb);";
|
||||
code_ += " let mut builder = {{STRUCT_NAME}}Builder::new(_fbb);";
|
||||
for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1;
|
||||
size; size /= 2) {
|
||||
ForAllTableFields(
|
||||
@@ -1713,23 +1704,23 @@ class RustGenerator : public BaseGenerator {
|
||||
return;
|
||||
if (IsOptionalToBuilder(field)) {
|
||||
code_ +=
|
||||
" if let Some(x) = args.{{FIELD_NAME}} "
|
||||
" if let Some(x) = args.{{FIELD_NAME}} "
|
||||
"{ builder.add_{{FIELD_NAME}}(x); }";
|
||||
} else {
|
||||
code_ += " builder.add_{{FIELD_NAME}}(args.{{FIELD_NAME}});";
|
||||
code_ += " builder.add_{{FIELD_NAME}}(args.{{FIELD_NAME}});";
|
||||
}
|
||||
},
|
||||
/*reverse=*/true);
|
||||
}
|
||||
code_ += " builder.finish()";
|
||||
code_ += " }";
|
||||
code_ += " builder.finish()";
|
||||
code_ += " }";
|
||||
code_ += "";
|
||||
// Generate Object API Packer function.
|
||||
if (parser_.opts.generate_object_based_api) {
|
||||
// TODO(cneo): Replace more for loops with ForAllX stuff.
|
||||
// TODO(cneo): Manage indentation with IncrementIdentLevel?
|
||||
code_.SetValue("OBJECT_NAME", NativeName(struct_def));
|
||||
code_ += " pub fn unpack(&self) -> {{OBJECT_NAME}} {";
|
||||
code_ += " pub fn unpack(&self) -> {{OBJECT_NAME}} {";
|
||||
ForAllObjectTableFields(struct_def, [&](const FieldDef &field) {
|
||||
const Type &type = field.value.type;
|
||||
switch (GetFullType(type)) {
|
||||
@@ -1737,7 +1728,7 @@ class RustGenerator : public BaseGenerator {
|
||||
case ftBool:
|
||||
case ftFloat:
|
||||
case ftEnumKey: {
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}();";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}();";
|
||||
return;
|
||||
}
|
||||
case ftUnionKey: return;
|
||||
@@ -1746,27 +1737,22 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("ENUM_NAME", WrapInNameSpace(enum_def));
|
||||
code_.SetValue("NATIVE_ENUM_NAME", NamespacedNativeName(enum_def));
|
||||
code_ +=
|
||||
" let {{FIELD_NAME}} = match "
|
||||
"self.{{FIELD_NAME}}_type() {";
|
||||
code_ +=
|
||||
" {{ENUM_NAME}}::NONE =>"
|
||||
" {{NATIVE_ENUM_NAME}}::NONE,";
|
||||
" let {{FIELD_NAME}} = match self.{{FIELD_NAME}}_type() {";
|
||||
code_ += " {{ENUM_NAME}}::NONE => {{NATIVE_ENUM_NAME}}::NONE,";
|
||||
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
|
||||
code_ +=
|
||||
" {{ENUM_NAME}}::{{VARIANT_NAME}} => "
|
||||
" {{ENUM_NAME}}::{{VARIANT_NAME}} => "
|
||||
"{{NATIVE_ENUM_NAME}}::{{NATIVE_VARIANT}}(Box::new(";
|
||||
code_ += " self.{{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}()";
|
||||
code_ +=
|
||||
" self.{{FIELD_NAME}}_as_"
|
||||
"{{U_ELEMENT_NAME}}()";
|
||||
code_ +=
|
||||
" .expect(\"Invalid union table, "
|
||||
" .expect(\"Invalid union table, "
|
||||
"expected `{{ENUM_NAME}}::{{VARIANT_NAME}}`.\")";
|
||||
code_ += " .unpack()";
|
||||
code_ += " )),";
|
||||
code_ += " .unpack()";
|
||||
code_ += " )),";
|
||||
});
|
||||
// Maybe we shouldn't throw away unknown discriminants?
|
||||
code_ += " _ => {{NATIVE_ENUM_NAME}}::NONE,";
|
||||
code_ += " };";
|
||||
code_ += " _ => {{NATIVE_ENUM_NAME}}::NONE,";
|
||||
code_ += " };";
|
||||
return;
|
||||
}
|
||||
// The rest of the types need special handling based on if the field
|
||||
@@ -1821,32 +1807,25 @@ class RustGenerator : public BaseGenerator {
|
||||
}
|
||||
}
|
||||
if (field.IsOptional()) {
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}().map(|x| {";
|
||||
code_ += " {{EXPR}}";
|
||||
code_ += " });";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}().map(|x| {";
|
||||
code_ += " {{EXPR}}";
|
||||
code_ += " });";
|
||||
} else {
|
||||
code_ += " let {{FIELD_NAME}} = {";
|
||||
code_ += " let x = self.{{FIELD_NAME}}();";
|
||||
code_ += " {{EXPR}}";
|
||||
code_ += " };";
|
||||
code_ += " let {{FIELD_NAME}} = {";
|
||||
code_ += " let x = self.{{FIELD_NAME}}();";
|
||||
code_ += " {{EXPR}}";
|
||||
code_ += " };";
|
||||
}
|
||||
});
|
||||
code_ += " {{OBJECT_NAME}} {";
|
||||
code_ += " {{OBJECT_NAME}} {";
|
||||
ForAllObjectTableFields(struct_def, [&](const FieldDef &field) {
|
||||
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
|
||||
code_ += " {{FIELD_NAME}},";
|
||||
code_ += " {{FIELD_NAME}},";
|
||||
});
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
}
|
||||
|
||||
// Generate field id constants.
|
||||
ForAllTableFields(struct_def, [&](const FieldDef &unused) {
|
||||
(void)unused;
|
||||
code_ +=
|
||||
" pub const {{OFFSET_NAME}}: flatbuffers::VOffsetT = "
|
||||
"{{OFFSET_VALUE}};";
|
||||
});
|
||||
if (struct_def.fields.vec.size() > 0) code_ += "";
|
||||
|
||||
// Generate the accessors. Each has one of two forms:
|
||||
@@ -1864,11 +1843,11 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("RETURN_TYPE",
|
||||
GenTableAccessorFuncReturnType(field, "'a"));
|
||||
|
||||
this->GenComment(field.doc_comment, " ");
|
||||
code_ += " #[inline]";
|
||||
code_ += " pub fn {{FIELD_NAME}}(&self) -> {{RETURN_TYPE}} {";
|
||||
code_ += " " + GenTableAccessorFuncBody(field, "'a");
|
||||
code_ += " }";
|
||||
this->GenComment(field.doc_comment);
|
||||
code_ += "#[inline]";
|
||||
code_ += "pub fn {{FIELD_NAME}}(&self) -> {{RETURN_TYPE}} {";
|
||||
code_ += " " + GenTableAccessorFuncBody(field, "'a");
|
||||
code_ += "}";
|
||||
|
||||
// Generate a comparison function for this field if it is a key.
|
||||
if (field.key) { GenKeyFieldMethods(field); }
|
||||
@@ -1886,24 +1865,24 @@ class RustGenerator : public BaseGenerator {
|
||||
FLATBUFFERS_ASSERT(nested_root); // Guaranteed to exist by parser.
|
||||
|
||||
code_.SetValue("NESTED", WrapInNameSpace(*nested_root));
|
||||
code_ += " pub fn {{FIELD_NAME}}_nested_flatbuffer(&'a self) -> \\";
|
||||
code_ += "pub fn {{FIELD_NAME}}_nested_flatbuffer(&'a self) -> \\";
|
||||
if (field.IsRequired()) {
|
||||
code_ += "{{NESTED}}<'a> {";
|
||||
code_ += " let data = self.{{FIELD_NAME}}();";
|
||||
code_ += " let data = self.{{FIELD_NAME}}();";
|
||||
code_ += " use flatbuffers::Follow;";
|
||||
code_ +=
|
||||
" <flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
|
||||
"::follow(data, 0)";
|
||||
} else {
|
||||
code_ += "Option<{{NESTED}}<'a>> {";
|
||||
code_ += " self.{{FIELD_NAME}}().map(|data| {";
|
||||
code_ += " use flatbuffers::Follow;";
|
||||
code_ +=
|
||||
" <flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
|
||||
"::follow(data, 0)";
|
||||
} else {
|
||||
code_ += "Option<{{NESTED}}<'a>> {";
|
||||
code_ += " self.{{FIELD_NAME}}().map(|data| {";
|
||||
code_ += " use flatbuffers::Follow;";
|
||||
code_ +=
|
||||
" <flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
|
||||
"::follow(data, 0)";
|
||||
code_ += " })";
|
||||
code_ += " })";
|
||||
}
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1913,10 +1892,10 @@ class RustGenerator : public BaseGenerator {
|
||||
ForAllUnionVariantsBesidesNone(
|
||||
*field.value.type.enum_def, [&](const EnumVal &unused) {
|
||||
(void)unused;
|
||||
code_ += " #[inline]";
|
||||
code_ += " #[allow(non_snake_case)]";
|
||||
code_ += "#[inline]";
|
||||
code_ += "#[allow(non_snake_case)]";
|
||||
code_ +=
|
||||
" pub fn {{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}(&self) -> "
|
||||
"pub fn {{FIELD_NAME}}_as_{{U_ELEMENT_NAME}}(&self) -> "
|
||||
"Option<{{U_ELEMENT_TABLE_TYPE}}<'a>> {";
|
||||
// If the user defined schemas name a field that clashes with a
|
||||
// language reserved word, flatc will try to escape the field name
|
||||
@@ -1930,23 +1909,22 @@ class RustGenerator : public BaseGenerator {
|
||||
//
|
||||
// To avoid this problem the type field name is used unescaped here:
|
||||
code_ +=
|
||||
" if self.{{DISCRIMINANT}}() == {{U_ELEMENT_ENUM_TYPE}} {";
|
||||
" if self.{{DISCRIMINANT}}() == {{U_ELEMENT_ENUM_TYPE}} {";
|
||||
|
||||
// The following logic is not tested in the integration test,
|
||||
// as of April 10, 2020
|
||||
if (field.IsRequired()) {
|
||||
code_ += " let u = self.{{FIELD_NAME}}();";
|
||||
code_ +=
|
||||
" Some({{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
|
||||
code_ += " let u = self.{{FIELD_NAME}}();";
|
||||
code_ += " Some({{U_ELEMENT_TABLE_TYPE}}::init_from_table(u))";
|
||||
} else {
|
||||
code_ +=
|
||||
" self.{{FIELD_NAME}}().map("
|
||||
" self.{{FIELD_NAME}}().map("
|
||||
"{{U_ELEMENT_TABLE_TYPE}}::init_from_table)";
|
||||
}
|
||||
code_ += " } else {";
|
||||
code_ += " None";
|
||||
code_ += " }";
|
||||
code_ += " } else {";
|
||||
code_ += " None";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
});
|
||||
});
|
||||
@@ -1988,17 +1966,17 @@ class RustGenerator : public BaseGenerator {
|
||||
"\"{{FIELD_NAME}}_type\", Self::{{UNION_TYPE_OFFSET_NAME}}, "
|
||||
"\"{{FIELD_NAME}}\", Self::{{OFFSET_NAME}}, {{IS_REQ}}, "
|
||||
"|key, v, pos| {";
|
||||
code_ += " match key {";
|
||||
code_ += " match key {";
|
||||
ForAllUnionVariantsBesidesNone(union_def, [&](const EnumVal &unused) {
|
||||
(void)unused;
|
||||
code_ +=
|
||||
" {{U_ELEMENT_ENUM_TYPE}} => v.verify_union_variant::"
|
||||
" {{U_ELEMENT_ENUM_TYPE}} => v.verify_union_variant::"
|
||||
"<flatbuffers::ForwardsUOffset<{{U_ELEMENT_TABLE_TYPE}}>>("
|
||||
"\"{{U_ELEMENT_ENUM_TYPE}}\", pos),";
|
||||
});
|
||||
code_ += " _ => Ok(()),";
|
||||
code_ += " }";
|
||||
code_ += " })?\\";
|
||||
code_ += " _ => Ok(()),";
|
||||
code_ += " }";
|
||||
code_ += " })?\\";
|
||||
});
|
||||
code_ += "\n .finish();";
|
||||
code_ += " Ok(())";
|
||||
@@ -2011,21 +1989,21 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "pub struct {{STRUCT_NAME}}Args{{MAYBE_LT}} {";
|
||||
ForAllTableFields(struct_def, [&](const FieldDef &field) {
|
||||
code_.SetValue("PARAM_TYPE", TableBuilderArgsDefnType(field, "'a"));
|
||||
code_ += " pub {{FIELD_NAME}}: {{PARAM_TYPE}},";
|
||||
code_ += " pub {{FIELD_NAME}}: {{PARAM_TYPE}},";
|
||||
});
|
||||
code_ += "}";
|
||||
|
||||
// Generate an impl of Default for the *Args type:
|
||||
code_ += "impl<'a> Default for {{STRUCT_NAME}}Args{{MAYBE_LT}} {";
|
||||
code_ += " #[inline]";
|
||||
code_ += " fn default() -> Self {";
|
||||
code_ += " {{STRUCT_NAME}}Args {";
|
||||
code_ += " #[inline]";
|
||||
code_ += " fn default() -> Self {";
|
||||
code_ += " {{STRUCT_NAME}}Args {";
|
||||
ForAllTableFields(struct_def, [&](const FieldDef &field) {
|
||||
code_ += " {{FIELD_NAME}}: {{BLDR_DEF_VAL}},\\";
|
||||
code_ += " {{FIELD_NAME}}: {{BLDR_DEF_VAL}},\\";
|
||||
code_ += field.IsRequired() ? " // required field" : "";
|
||||
});
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
|
||||
// Generate a builder struct:
|
||||
@@ -2055,18 +2033,18 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("FIELD_OFFSET", Name(struct_def) + "::" + offset);
|
||||
code_.SetValue("FIELD_TYPE", TableBuilderArgsAddFuncType(field, "'b "));
|
||||
code_.SetValue("FUNC_BODY", TableBuilderArgsAddFuncBody(field));
|
||||
code_ += " #[inline]";
|
||||
code_ += "#[inline]";
|
||||
code_ +=
|
||||
" pub fn add_{{FIELD_NAME}}(&mut self, {{FIELD_NAME}}: "
|
||||
"pub fn add_{{FIELD_NAME}}(&mut self, {{FIELD_NAME}}: "
|
||||
"{{FIELD_TYPE}}) {";
|
||||
if (is_scalar && !field.IsOptional()) {
|
||||
code_ +=
|
||||
" {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD_NAME}}, "
|
||||
" {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD_NAME}}, "
|
||||
"{{BLDR_DEF_VAL}});";
|
||||
} else {
|
||||
code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD_NAME}});";
|
||||
code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD_NAME}});";
|
||||
}
|
||||
code_ += " }";
|
||||
code_ += "}";
|
||||
});
|
||||
|
||||
// Struct initializer (all fields required);
|
||||
@@ -2092,7 +2070,7 @@ class RustGenerator : public BaseGenerator {
|
||||
ForAllTableFields(struct_def, [&](const FieldDef &field) {
|
||||
if (!field.IsRequired()) return;
|
||||
code_ +=
|
||||
" self.fbb_.required(o, {{STRUCT_NAME}}::{{OFFSET_NAME}},"
|
||||
" self.fbb_.required(o, {{STRUCT_NAME}}::{{OFFSET_NAME}},"
|
||||
"\"{{FIELD_NAME}}\");";
|
||||
});
|
||||
code_ += " flatbuffers::WIPOffset::new(o.value())";
|
||||
@@ -2113,30 +2091,29 @@ class RustGenerator : public BaseGenerator {
|
||||
"&\"InvalidFlatbuffer: Union discriminant"
|
||||
" does not match value.\"");
|
||||
|
||||
code_ += " match self.{{DISCRIMINANT}}() {";
|
||||
code_ += " match self.{{DISCRIMINANT}}() {";
|
||||
ForAllUnionVariantsBesidesNone(
|
||||
*field.value.type.enum_def, [&](const EnumVal &unused) {
|
||||
(void)unused;
|
||||
code_ += " {{U_ELEMENT_ENUM_TYPE}} => {";
|
||||
code_ += " {{U_ELEMENT_ENUM_TYPE}} => {";
|
||||
code_ +=
|
||||
" if let Some(x) = "
|
||||
" if let Some(x) = "
|
||||
"self.{{FIELD_NAME}}_as_"
|
||||
"{{U_ELEMENT_NAME}}() {";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &x)";
|
||||
code_ += " } else {";
|
||||
code_ +=
|
||||
" ds.field(\"{{FIELD_NAME}}\", {{UNION_ERR}})";
|
||||
code_ += " }";
|
||||
code_ += " },";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &x)";
|
||||
code_ += " } else {";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", {{UNION_ERR}})";
|
||||
code_ += " }";
|
||||
code_ += " },";
|
||||
});
|
||||
code_ += " _ => {";
|
||||
code_ += " let x: Option<()> = None;";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &x)";
|
||||
code_ += " },";
|
||||
code_ += " };";
|
||||
code_ += " _ => {";
|
||||
code_ += " let x: Option<()> = None;";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &x)";
|
||||
code_ += " },";
|
||||
code_ += " };";
|
||||
} else {
|
||||
// Most fields.
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &self.{{FIELD_NAME}}());";
|
||||
code_ += " ds.field(\"{{FIELD_NAME}}\", &self.{{FIELD_NAME}}());";
|
||||
}
|
||||
});
|
||||
code_ += " ds.finish()";
|
||||
@@ -2156,7 +2133,7 @@ class RustGenerator : public BaseGenerator {
|
||||
// Union objects combine both the union discriminant and value, so we
|
||||
// skip making a field for the discriminant.
|
||||
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
|
||||
code_ += " pub {{FIELD_NAME}}: {{FIELD_OBJECT_TYPE}},";
|
||||
code_ += "pub {{FIELD_NAME}}: {{FIELD_OBJECT_TYPE}},";
|
||||
});
|
||||
code_ += "}";
|
||||
|
||||
@@ -2166,7 +2143,7 @@ class RustGenerator : public BaseGenerator {
|
||||
ForAllObjectTableFields(table, [&](const FieldDef &field) {
|
||||
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
|
||||
std::string default_value = GetDefaultValue(field, kObject);
|
||||
code_ += " {{FIELD_NAME}}: " + default_value + ",";
|
||||
code_ += " {{FIELD_NAME}}: " + default_value + ",";
|
||||
});
|
||||
code_ += " }";
|
||||
code_ += " }";
|
||||
@@ -2190,7 +2167,7 @@ class RustGenerator : public BaseGenerator {
|
||||
case ftBool:
|
||||
case ftFloat:
|
||||
case ftEnumKey: {
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}};";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}};";
|
||||
return;
|
||||
}
|
||||
case ftUnionKey: return; // Generate union type with union value.
|
||||
@@ -2198,9 +2175,9 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("SNAKE_CASE_ENUM_NAME",
|
||||
MakeSnakeCase(Name(*field.value.type.enum_def)));
|
||||
code_ +=
|
||||
" let {{FIELD_NAME}}_type = "
|
||||
" let {{FIELD_NAME}}_type = "
|
||||
"self.{{FIELD_NAME}}.{{SNAKE_CASE_ENUM_NAME}}_type();";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}.pack(_fbb);";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}.pack(_fbb);";
|
||||
return;
|
||||
}
|
||||
// The rest of the types require special casing around optionalness
|
||||
@@ -2213,14 +2190,13 @@ class RustGenerator : public BaseGenerator {
|
||||
// Hold the struct in a variable so we can reference it.
|
||||
if (field.IsRequired()) {
|
||||
code_ +=
|
||||
" let {{FIELD_NAME}}_tmp = "
|
||||
"Some(self.{{FIELD_NAME}}.pack());";
|
||||
" let {{FIELD_NAME}}_tmp = Some(self.{{FIELD_NAME}}.pack());";
|
||||
} else {
|
||||
code_ +=
|
||||
" let {{FIELD_NAME}}_tmp = self.{{FIELD_NAME}}"
|
||||
" let {{FIELD_NAME}}_tmp = self.{{FIELD_NAME}}"
|
||||
".as_ref().map(|x| x.pack());";
|
||||
}
|
||||
code_ += " let {{FIELD_NAME}} = {{FIELD_NAME}}_tmp.as_ref();";
|
||||
code_ += " let {{FIELD_NAME}} = {{FIELD_NAME}}_tmp.as_ref();";
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -2274,7 +2250,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " {{STRUCT_NAME}}::create(_fbb, &{{STRUCT_NAME}}Args{";
|
||||
ForAllObjectTableFields(table, [&](const FieldDef &field) {
|
||||
(void)field; // Unused.
|
||||
code_ += " {{FIELD_NAME}},";
|
||||
code_ += " {{FIELD_NAME}},";
|
||||
});
|
||||
code_ += " })";
|
||||
code_ += " }";
|
||||
@@ -2288,21 +2264,23 @@ class RustGenerator : public BaseGenerator {
|
||||
if (field.deprecated) continue;
|
||||
code_.SetValue("FIELD_NAME", Name(field));
|
||||
code_.SetValue("FIELD_OBJECT_TYPE", ObjectFieldType(field, true));
|
||||
code_.IncrementIdentLevel();
|
||||
cb(field);
|
||||
code_.DecrementIdentLevel();
|
||||
}
|
||||
}
|
||||
void MapNativeTableField(const FieldDef &field, const std::string &expr) {
|
||||
if (field.IsOptional()) {
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}.as_ref().map(|x|{";
|
||||
code_ += " " + expr;
|
||||
code_ += " });";
|
||||
code_ += " let {{FIELD_NAME}} = self.{{FIELD_NAME}}.as_ref().map(|x|{";
|
||||
code_ += " " + expr;
|
||||
code_ += " });";
|
||||
} else {
|
||||
// For some reason Args has optional types for required fields.
|
||||
// TODO(cneo): Fix this... but its a breaking change?
|
||||
code_ += " let {{FIELD_NAME}} = Some({";
|
||||
code_ += " let x = &self.{{FIELD_NAME}};";
|
||||
code_ += " " + expr;
|
||||
code_ += " });";
|
||||
code_ += " let {{FIELD_NAME}} = Some({";
|
||||
code_ += " let x = &self.{{FIELD_NAME}};";
|
||||
code_ += " " + expr;
|
||||
code_ += " });";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2314,20 +2292,20 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue("KEY_TYPE", GenTableAccessorFuncReturnType(field, ""));
|
||||
code_.SetValue("REF", IsString(field.value.type) ? "" : "&");
|
||||
|
||||
code_ += " #[inline]";
|
||||
code_ += "#[inline]";
|
||||
code_ +=
|
||||
" pub fn key_compare_less_than(&self, o: &{{STRUCT_NAME}}) -> "
|
||||
" bool {";
|
||||
code_ += " self.{{FIELD_NAME}}() < o.{{FIELD_NAME}}()";
|
||||
code_ += " }";
|
||||
"pub fn key_compare_less_than(&self, o: &{{STRUCT_NAME}}) -> "
|
||||
"bool {";
|
||||
code_ += " self.{{FIELD_NAME}}() < o.{{FIELD_NAME}}()";
|
||||
code_ += "}";
|
||||
code_ += "";
|
||||
code_ += " #[inline]";
|
||||
code_ += "#[inline]";
|
||||
code_ +=
|
||||
" pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
|
||||
" ::std::cmp::Ordering {";
|
||||
code_ += " let key = self.{{FIELD_NAME}}();";
|
||||
code_ += " key.cmp({{REF}}val)";
|
||||
code_ += " }";
|
||||
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
|
||||
"::std::cmp::Ordering {";
|
||||
code_ += " let key = self.{{FIELD_NAME}}();";
|
||||
code_ += " key.cmp({{REF}}val)";
|
||||
code_ += "}";
|
||||
}
|
||||
|
||||
// Generate functions for accessing the root table object. This function
|
||||
@@ -2553,7 +2531,9 @@ class RustGenerator : public BaseGenerator {
|
||||
code_.SetValue(
|
||||
"REF",
|
||||
IsStruct(field.value.type) || IsArray(field.value.type) ? "&" : "");
|
||||
code_.IncrementIdentLevel();
|
||||
cb(field);
|
||||
code_.DecrementIdentLevel();
|
||||
const size_t size = InlineSize(field.value.type);
|
||||
offset_to_field += size + field.padding;
|
||||
}
|
||||
@@ -2592,7 +2572,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " f.debug_struct(\"{{STRUCT_NAME}}\")";
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &unused) {
|
||||
(void)unused;
|
||||
code_ += " .field(\"{{FIELD_NAME}}\", &self.{{FIELD_NAME}}())";
|
||||
code_ += " .field(\"{{FIELD_NAME}}\", &self.{{FIELD_NAME}}())";
|
||||
});
|
||||
code_ += " .finish()";
|
||||
code_ += " }";
|
||||
@@ -2663,13 +2643,13 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " pub fn new(";
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &unused) {
|
||||
(void)unused;
|
||||
code_ += " {{FIELD_NAME}}: {{REF}}{{FIELD_TYPE}},";
|
||||
code_ += " {{FIELD_NAME}}: {{REF}}{{FIELD_TYPE}},";
|
||||
});
|
||||
code_ += " ) -> Self {";
|
||||
code_ += " let mut s = Self([0; {{STRUCT_SIZE}}]);";
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &unused) {
|
||||
(void)unused;
|
||||
code_ += " s.set_{{FIELD_NAME}}({{FIELD_NAME}});";
|
||||
code_ += " s.set_{{FIELD_NAME}}({{FIELD_NAME}});";
|
||||
});
|
||||
code_ += " s";
|
||||
code_ += " }";
|
||||
@@ -2681,12 +2661,12 @@ class RustGenerator : public BaseGenerator {
|
||||
|
||||
// Generate accessor methods for the struct.
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &field) {
|
||||
this->GenComment(field.doc_comment, " ");
|
||||
this->GenComment(field.doc_comment);
|
||||
// Getter.
|
||||
if (IsStruct(field.value.type)) {
|
||||
code_ += " pub fn {{FIELD_NAME}}(&self) -> &{{FIELD_TYPE}} {";
|
||||
code_ += "pub fn {{FIELD_NAME}}(&self) -> &{{FIELD_TYPE}} {";
|
||||
code_ +=
|
||||
" unsafe {"
|
||||
" unsafe {"
|
||||
" &*(self.0[{{FIELD_OFFSET}}..].as_ptr() as *const"
|
||||
" {{FIELD_TYPE}}) }";
|
||||
} else if (IsArray(field.value.type)) {
|
||||
@@ -2694,31 +2674,31 @@ class RustGenerator : public BaseGenerator {
|
||||
NumToString(field.value.type.fixed_length));
|
||||
code_.SetValue("ARRAY_ITEM", GetTypeGet(field.value.type.VectorType()));
|
||||
code_ +=
|
||||
" pub fn {{FIELD_NAME}}(&'a self) -> "
|
||||
"pub fn {{FIELD_NAME}}(&'a self) -> "
|
||||
"flatbuffers::Array<'a, {{ARRAY_ITEM}}, {{ARRAY_SIZE}}> {";
|
||||
code_ += " flatbuffers::Array::follow(&self.0, {{FIELD_OFFSET}})";
|
||||
code_ += " flatbuffers::Array::follow(&self.0, {{FIELD_OFFSET}})";
|
||||
} else {
|
||||
code_ += " pub fn {{FIELD_NAME}}(&self) -> {{FIELD_TYPE}} {";
|
||||
code_ += "pub fn {{FIELD_NAME}}(&self) -> {{FIELD_TYPE}} {";
|
||||
code_ +=
|
||||
" let mut mem = core::mem::MaybeUninit::"
|
||||
" let mut mem = core::mem::MaybeUninit::"
|
||||
"<{{FIELD_TYPE}}>::uninit();";
|
||||
code_ += " unsafe {";
|
||||
code_ += " core::ptr::copy_nonoverlapping(";
|
||||
code_ += " self.0[{{FIELD_OFFSET}}..].as_ptr(),";
|
||||
code_ += " mem.as_mut_ptr() as *mut u8,";
|
||||
code_ += " core::mem::size_of::<{{FIELD_TYPE}}>(),";
|
||||
code_ += " );";
|
||||
code_ += " mem.assume_init()";
|
||||
code_ += " }.from_little_endian()";
|
||||
code_ += " unsafe {";
|
||||
code_ += " core::ptr::copy_nonoverlapping(";
|
||||
code_ += " self.0[{{FIELD_OFFSET}}..].as_ptr(),";
|
||||
code_ += " mem.as_mut_ptr() as *mut u8,";
|
||||
code_ += " core::mem::size_of::<{{FIELD_TYPE}}>(),";
|
||||
code_ += " );";
|
||||
code_ += " mem.assume_init()";
|
||||
code_ += " }.from_little_endian()";
|
||||
}
|
||||
code_ += " }\n";
|
||||
code_ += "}\n";
|
||||
// Setter.
|
||||
if (IsStruct(field.value.type)) {
|
||||
code_.SetValue("FIELD_SIZE", NumToString(InlineSize(field.value.type)));
|
||||
code_ += " #[allow(clippy::identity_op)]"; // If FIELD_OFFSET=0.
|
||||
code_ += " pub fn set_{{FIELD_NAME}}(&mut self, x: &{{FIELD_TYPE}}) {";
|
||||
code_ += "#[allow(clippy::identity_op)]"; // If FIELD_OFFSET=0.
|
||||
code_ += "pub fn set_{{FIELD_NAME}}(&mut self, x: &{{FIELD_TYPE}}) {";
|
||||
code_ +=
|
||||
" self.0[{{FIELD_OFFSET}}..{{FIELD_OFFSET}} + {{FIELD_SIZE}}]"
|
||||
" self.0[{{FIELD_OFFSET}}..{{FIELD_OFFSET}} + {{FIELD_SIZE}}]"
|
||||
".copy_from_slice(&x.0)";
|
||||
} else if (IsArray(field.value.type)) {
|
||||
if (GetFullType(field.value.type) == ftArrayOfBuiltin) {
|
||||
@@ -2728,36 +2708,35 @@ class RustGenerator : public BaseGenerator {
|
||||
"ARRAY_ITEM_SIZE",
|
||||
NumToString(InlineSize(field.value.type.VectorType())));
|
||||
code_ +=
|
||||
" pub fn set_{{FIELD_NAME}}(&mut self, items: &{{FIELD_TYPE}}) "
|
||||
"pub fn set_{{FIELD_NAME}}(&mut self, items: &{{FIELD_TYPE}}) "
|
||||
"{";
|
||||
code_ +=
|
||||
" flatbuffers::emplace_scalar_array(&mut self.0, "
|
||||
" flatbuffers::emplace_scalar_array(&mut self.0, "
|
||||
"{{FIELD_OFFSET}}, items);";
|
||||
} else {
|
||||
code_.SetValue("FIELD_SIZE",
|
||||
NumToString(InlineSize(field.value.type)));
|
||||
code_ +=
|
||||
" pub fn set_{{FIELD_NAME}}(&mut self, x: &{{FIELD_TYPE}}) {";
|
||||
code_ += " unsafe {";
|
||||
code_ += " std::ptr::copy(";
|
||||
code_ += " x.as_ptr() as *const u8,";
|
||||
code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),";
|
||||
code_ += " {{FIELD_SIZE}},";
|
||||
code_ += " );";
|
||||
code_ += " }";
|
||||
code_ += "pub fn set_{{FIELD_NAME}}(&mut self, x: &{{FIELD_TYPE}}) {";
|
||||
code_ += " unsafe {";
|
||||
code_ += " std::ptr::copy(";
|
||||
code_ += " x.as_ptr() as *const u8,";
|
||||
code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),";
|
||||
code_ += " {{FIELD_SIZE}},";
|
||||
code_ += " );";
|
||||
code_ += " }";
|
||||
}
|
||||
} else {
|
||||
code_ += " pub fn set_{{FIELD_NAME}}(&mut self, x: {{FIELD_TYPE}}) {";
|
||||
code_ += " let x_le = x.to_little_endian();";
|
||||
code_ += " unsafe {";
|
||||
code_ += " core::ptr::copy_nonoverlapping(";
|
||||
code_ += " &x_le as *const {{FIELD_TYPE}} as *const u8,";
|
||||
code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),";
|
||||
code_ += " core::mem::size_of::<{{FIELD_TYPE}}>(),";
|
||||
code_ += " );";
|
||||
code_ += " }";
|
||||
code_ += "pub fn set_{{FIELD_NAME}}(&mut self, x: {{FIELD_TYPE}}) {";
|
||||
code_ += " let x_le = x.to_little_endian();";
|
||||
code_ += " unsafe {";
|
||||
code_ += " core::ptr::copy_nonoverlapping(";
|
||||
code_ += " &x_le as *const {{FIELD_TYPE}} as *const u8,";
|
||||
code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),";
|
||||
code_ += " core::mem::size_of::<{{FIELD_TYPE}}>(),";
|
||||
code_ += " );";
|
||||
code_ += " }";
|
||||
}
|
||||
code_ += " }\n";
|
||||
code_ += "}\n";
|
||||
|
||||
// Generate a comparison function for this field if it is a key.
|
||||
if (field.key) { GenKeyFieldMethods(field); }
|
||||
@@ -2772,15 +2751,15 @@ class RustGenerator : public BaseGenerator {
|
||||
if (IsArray(field.value.type)) {
|
||||
if (GetFullType(field.value.type) == ftArrayOfStruct) {
|
||||
code_ +=
|
||||
" {{FIELD_NAME}}: { let {{FIELD_NAME}} = "
|
||||
" {{FIELD_NAME}}: { let {{FIELD_NAME}} = "
|
||||
"self.{{FIELD_NAME}}(); flatbuffers::array_init(|i| "
|
||||
"{{FIELD_NAME}}.get(i).unpack()) },";
|
||||
} else {
|
||||
code_ += " {{FIELD_NAME}}: self.{{FIELD_NAME}}().into(),";
|
||||
code_ += " {{FIELD_NAME}}: self.{{FIELD_NAME}}().into(),";
|
||||
}
|
||||
} else {
|
||||
std::string unpack = IsStruct(field.value.type) ? ".unpack()" : "";
|
||||
code_ += " {{FIELD_NAME}}: self.{{FIELD_NAME}}()" + unpack + ",";
|
||||
code_ += " {{FIELD_NAME}}: self.{{FIELD_NAME}}()" + unpack + ",";
|
||||
}
|
||||
});
|
||||
code_ += " }";
|
||||
@@ -2797,7 +2776,7 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += "pub struct {{NATIVE_STRUCT_NAME}} {";
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &field) {
|
||||
(void)field; // unused.
|
||||
code_ += " pub {{FIELD_NAME}}: {{FIELD_OBJECT_TYPE}},";
|
||||
code_ += "pub {{FIELD_NAME}}: {{FIELD_OBJECT_TYPE}},";
|
||||
});
|
||||
code_ += "}";
|
||||
// The `pack` method that turns the native struct into its Flatbuffers
|
||||
@@ -2807,17 +2786,17 @@ class RustGenerator : public BaseGenerator {
|
||||
code_ += " {{STRUCT_NAME}}::new(";
|
||||
ForAllStructFields(struct_def, [&](const FieldDef &field) {
|
||||
if (IsStruct(field.value.type)) {
|
||||
code_ += " &self.{{FIELD_NAME}}.pack(),";
|
||||
code_ += " &self.{{FIELD_NAME}}.pack(),";
|
||||
} else if (IsArray(field.value.type)) {
|
||||
if (GetFullType(field.value.type) == ftArrayOfStruct) {
|
||||
code_ +=
|
||||
" &flatbuffers::array_init(|i| "
|
||||
" &flatbuffers::array_init(|i| "
|
||||
"self.{{FIELD_NAME}}[i].pack()),";
|
||||
} else {
|
||||
code_ += " &self.{{FIELD_NAME}},";
|
||||
code_ += " &self.{{FIELD_NAME}},";
|
||||
}
|
||||
} else {
|
||||
code_ += " self.{{FIELD_NAME}},";
|
||||
code_ += " self.{{FIELD_NAME}},";
|
||||
}
|
||||
});
|
||||
code_ += " )";
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
mod test_enum_generated;
|
||||
pub use self::test_enum_generated::*;
|
||||
mod nested_struct_generated;
|
||||
pub use self::nested_struct_generated::*;
|
||||
mod array_struct_generated;
|
||||
pub use self::array_struct_generated::*;
|
||||
mod array_table_generated;
|
||||
pub use self::array_table_generated::*;
|
||||
} // example
|
||||
mod test_enum_generated;
|
||||
pub use self::test_enum_generated::*;
|
||||
mod nested_struct_generated;
|
||||
pub use self::nested_struct_generated::*;
|
||||
mod array_struct_generated;
|
||||
pub use self::array_struct_generated::*;
|
||||
mod array_table_generated;
|
||||
pub use self::array_table_generated::*;
|
||||
} // example
|
||||
} // my_game
|
||||
|
||||
@@ -93,9 +93,9 @@ impl<'a> ArrayStruct {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayStruct"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayStruct"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<f32>::uninit();
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct ArrayTable<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for ArrayTable<'a> {
|
||||
type Inner = ArrayTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = ArrayTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ArrayTable<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayTable"
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ArrayTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ArrayTableArgs<'args>) -> flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.ArrayTable"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayTableT {
|
||||
let a = self.a().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
ArrayTableT {
|
||||
a,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ArrayTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ArrayTableArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<ArrayTable<'bldr>> {
|
||||
let mut builder = ArrayTableBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ArrayTableT {
|
||||
let a = self.a().map(|x| {
|
||||
x.unpack()
|
||||
});
|
||||
ArrayTableT {
|
||||
a,
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<&'a ArrayStruct> {
|
||||
@@ -69,12 +71,12 @@ pub struct ArrayTableArgs<'a> {
|
||||
pub a: Option<&'a ArrayStruct>,
|
||||
}
|
||||
impl<'a> Default for ArrayTableArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ArrayTableArgs {
|
||||
a: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ArrayTableArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct ArrayTableBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -87,9 +87,9 @@ impl<'a> NestedStruct {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.NestedStruct"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.NestedStruct"
|
||||
}
|
||||
|
||||
pub fn a(&'a self) -> flatbuffers::Array<'a, i32, 2> {
|
||||
flatbuffers::Array::follow(&self.0, 0)
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
} // my_game
|
||||
mod table_a_generated;
|
||||
pub use self::table_a_generated::*;
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableB<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableB<'a> {
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableB<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableBArgs<'a> {
|
||||
pub a: Option<flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableBArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableBBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -78,9 +78,9 @@ impl<'a> Unused {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = core::mem::MaybeUninit::<i32>::uninit();
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableA<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableA<'a> {
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableA<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableAArgs<'a> {
|
||||
pub b: Option<flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableABuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
} // my_game
|
||||
mod table_a_generated;
|
||||
pub use self::table_a_generated::*;
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableB<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableB<'a> {
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableB<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableBArgs<'a> {
|
||||
pub a: Option<flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableBArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableBBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -78,9 +78,9 @@ impl<'a> Unused {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = core::mem::MaybeUninit::<i32>::uninit();
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableA<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableA<'a> {
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableA<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableAArgs<'a> {
|
||||
pub b: Option<flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableABuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,46 +12,48 @@ pub struct KeywordsInTable<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for KeywordsInTable<'a> {
|
||||
type Inner = KeywordsInTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = KeywordsInTable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> KeywordsInTable<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"KeywordsInTable"
|
||||
}
|
||||
pub const VT_IS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_PRIVATE: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_TYPE_: flatbuffers::VOffsetT = 8;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
KeywordsInTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args KeywordsInTableArgs) -> flatbuffers::WIPOffset<KeywordsInTable<'bldr>> {
|
||||
let mut builder = KeywordsInTableBuilder::new(_fbb);
|
||||
builder.add_type_(args.type_);
|
||||
builder.add_private(args.private);
|
||||
builder.add_is(args.is);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"KeywordsInTable"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> KeywordsInTableT {
|
||||
let is = self.is();
|
||||
let private = self.private();
|
||||
let type_ = self.type_();
|
||||
KeywordsInTableT {
|
||||
is,
|
||||
private,
|
||||
type_,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
KeywordsInTable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args KeywordsInTableArgs
|
||||
) -> flatbuffers::WIPOffset<KeywordsInTable<'bldr>> {
|
||||
let mut builder = KeywordsInTableBuilder::new(_fbb);
|
||||
builder.add_type_(args.type_);
|
||||
builder.add_private(args.private);
|
||||
builder.add_is(args.is);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> KeywordsInTableT {
|
||||
let is = self.is();
|
||||
let private = self.private();
|
||||
let type_ = self.type_();
|
||||
KeywordsInTableT {
|
||||
is,
|
||||
private,
|
||||
type_,
|
||||
}
|
||||
pub const VT_IS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_PRIVATE: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_TYPE_: flatbuffers::VOffsetT = 8;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn is(&self) -> ABC {
|
||||
@@ -87,14 +89,14 @@ pub struct KeywordsInTableArgs {
|
||||
pub type_: i32,
|
||||
}
|
||||
impl<'a> Default for KeywordsInTableArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
KeywordsInTableArgs {
|
||||
is: ABC::void,
|
||||
private: public::NONE,
|
||||
type_: 0,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
KeywordsInTableArgs {
|
||||
is: ABC::void,
|
||||
private: public::NONE,
|
||||
type_: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct KeywordsInTableBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -1,53 +1,53 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod my_game {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
pub mod example {
|
||||
use super::*;
|
||||
mod color_generated;
|
||||
pub use self::color_generated::*;
|
||||
mod race_generated;
|
||||
pub use self::race_generated::*;
|
||||
mod any_generated;
|
||||
pub use self::any_generated::*;
|
||||
mod any_unique_aliases_generated;
|
||||
pub use self::any_unique_aliases_generated::*;
|
||||
mod any_ambiguous_aliases_generated;
|
||||
pub use self::any_ambiguous_aliases_generated::*;
|
||||
mod test_generated;
|
||||
pub use self::test_generated::*;
|
||||
mod test_simple_table_with_enum_generated;
|
||||
pub use self::test_simple_table_with_enum_generated::*;
|
||||
mod vec_3_generated;
|
||||
pub use self::vec_3_generated::*;
|
||||
mod ability_generated;
|
||||
pub use self::ability_generated::*;
|
||||
mod struct_of_structs_generated;
|
||||
pub use self::struct_of_structs_generated::*;
|
||||
mod stat_generated;
|
||||
pub use self::stat_generated::*;
|
||||
mod referrable_generated;
|
||||
pub use self::referrable_generated::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
mod type_aliases_generated;
|
||||
pub use self::type_aliases_generated::*;
|
||||
} // example
|
||||
pub mod example_2 {
|
||||
use super::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
} // example_2
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
mod in_parent_namespace_generated;
|
||||
pub use self::in_parent_namespace_generated::*;
|
||||
mod color_generated;
|
||||
pub use self::color_generated::*;
|
||||
mod race_generated;
|
||||
pub use self::race_generated::*;
|
||||
mod any_generated;
|
||||
pub use self::any_generated::*;
|
||||
mod any_unique_aliases_generated;
|
||||
pub use self::any_unique_aliases_generated::*;
|
||||
mod any_ambiguous_aliases_generated;
|
||||
pub use self::any_ambiguous_aliases_generated::*;
|
||||
mod test_generated;
|
||||
pub use self::test_generated::*;
|
||||
mod test_simple_table_with_enum_generated;
|
||||
pub use self::test_simple_table_with_enum_generated::*;
|
||||
mod vec_3_generated;
|
||||
pub use self::vec_3_generated::*;
|
||||
mod ability_generated;
|
||||
pub use self::ability_generated::*;
|
||||
mod struct_of_structs_generated;
|
||||
pub use self::struct_of_structs_generated::*;
|
||||
mod stat_generated;
|
||||
pub use self::stat_generated::*;
|
||||
mod referrable_generated;
|
||||
pub use self::referrable_generated::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
mod type_aliases_generated;
|
||||
pub use self::type_aliases_generated::*;
|
||||
} // example
|
||||
pub mod example_2 {
|
||||
use super::*;
|
||||
mod monster_generated;
|
||||
pub use self::monster_generated::*;
|
||||
} // example_2
|
||||
pub mod other_name_space {
|
||||
use super::*;
|
||||
mod from_include_generated;
|
||||
pub use self::from_include_generated::*;
|
||||
mod unused_generated;
|
||||
pub use self::unused_generated::*;
|
||||
mod table_b_generated;
|
||||
pub use self::table_b_generated::*;
|
||||
} // other_name_space
|
||||
mod in_parent_namespace_generated;
|
||||
pub use self::in_parent_namespace_generated::*;
|
||||
} // my_game
|
||||
mod table_a_generated;
|
||||
pub use self::table_a_generated::*;
|
||||
|
||||
@@ -81,9 +81,9 @@ impl<'a> Ability {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Ability"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Ability"
|
||||
}
|
||||
|
||||
pub fn id(&self) -> u32 {
|
||||
let mut mem = core::mem::MaybeUninit::<u32>::uninit();
|
||||
@@ -109,12 +109,12 @@ impl<'a> Ability {
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
|
||||
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
|
||||
self.id() < o.id()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
|
||||
pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
|
||||
let key = self.id();
|
||||
key.cmp(&val)
|
||||
}
|
||||
|
||||
@@ -13,333 +13,335 @@ pub struct Monster<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Monster<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Monster"
|
||||
}
|
||||
pub const VT_POS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_MANA: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_HP: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_TEST_TYPE: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_TEST: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_TEST4: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_TESTARRAYOFSTRING: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_TESTARRAYOFTABLES: flatbuffers::VOffsetT = 26;
|
||||
pub const VT_ENEMY: flatbuffers::VOffsetT = 28;
|
||||
pub const VT_TESTNESTEDFLATBUFFER: flatbuffers::VOffsetT = 30;
|
||||
pub const VT_TESTEMPTY: flatbuffers::VOffsetT = 32;
|
||||
pub const VT_TESTBOOL: flatbuffers::VOffsetT = 34;
|
||||
pub const VT_TESTHASHS32_FNV1: flatbuffers::VOffsetT = 36;
|
||||
pub const VT_TESTHASHU32_FNV1: flatbuffers::VOffsetT = 38;
|
||||
pub const VT_TESTHASHS64_FNV1: flatbuffers::VOffsetT = 40;
|
||||
pub const VT_TESTHASHU64_FNV1: flatbuffers::VOffsetT = 42;
|
||||
pub const VT_TESTHASHS32_FNV1A: flatbuffers::VOffsetT = 44;
|
||||
pub const VT_TESTHASHU32_FNV1A: flatbuffers::VOffsetT = 46;
|
||||
pub const VT_TESTHASHS64_FNV1A: flatbuffers::VOffsetT = 48;
|
||||
pub const VT_TESTHASHU64_FNV1A: flatbuffers::VOffsetT = 50;
|
||||
pub const VT_TESTARRAYOFBOOLS: flatbuffers::VOffsetT = 52;
|
||||
pub const VT_TESTF: flatbuffers::VOffsetT = 54;
|
||||
pub const VT_TESTF2: flatbuffers::VOffsetT = 56;
|
||||
pub const VT_TESTF3: flatbuffers::VOffsetT = 58;
|
||||
pub const VT_TESTARRAYOFSTRING2: flatbuffers::VOffsetT = 60;
|
||||
pub const VT_TESTARRAYOFSORTEDSTRUCT: flatbuffers::VOffsetT = 62;
|
||||
pub const VT_FLEX: flatbuffers::VOffsetT = 64;
|
||||
pub const VT_TEST5: flatbuffers::VOffsetT = 66;
|
||||
pub const VT_VECTOR_OF_LONGS: flatbuffers::VOffsetT = 68;
|
||||
pub const VT_VECTOR_OF_DOUBLES: flatbuffers::VOffsetT = 70;
|
||||
pub const VT_PARENT_NAMESPACE_TEST: flatbuffers::VOffsetT = 72;
|
||||
pub const VT_VECTOR_OF_REFERRABLES: flatbuffers::VOffsetT = 74;
|
||||
pub const VT_SINGLE_WEAK_REFERENCE: flatbuffers::VOffsetT = 76;
|
||||
pub const VT_VECTOR_OF_WEAK_REFERENCES: flatbuffers::VOffsetT = 78;
|
||||
pub const VT_VECTOR_OF_STRONG_REFERRABLES: flatbuffers::VOffsetT = 80;
|
||||
pub const VT_CO_OWNING_REFERENCE: flatbuffers::VOffsetT = 82;
|
||||
pub const VT_VECTOR_OF_CO_OWNING_REFERENCES: flatbuffers::VOffsetT = 84;
|
||||
pub const VT_NON_OWNING_REFERENCE: flatbuffers::VOffsetT = 86;
|
||||
pub const VT_VECTOR_OF_NON_OWNING_REFERENCES: flatbuffers::VOffsetT = 88;
|
||||
pub const VT_ANY_UNIQUE_TYPE: flatbuffers::VOffsetT = 90;
|
||||
pub const VT_ANY_UNIQUE: flatbuffers::VOffsetT = 92;
|
||||
pub const VT_ANY_AMBIGUOUS_TYPE: flatbuffers::VOffsetT = 94;
|
||||
pub const VT_ANY_AMBIGUOUS: flatbuffers::VOffsetT = 96;
|
||||
pub const VT_VECTOR_OF_ENUMS: flatbuffers::VOffsetT = 98;
|
||||
pub const VT_SIGNED_ENUM: flatbuffers::VOffsetT = 100;
|
||||
pub const VT_TESTREQUIREDNESTEDFLATBUFFER: flatbuffers::VOffsetT = 102;
|
||||
pub const VT_SCALAR_KEY_SORTED_TABLES: flatbuffers::VOffsetT = 104;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MonsterArgs<'args>) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
builder.add_non_owning_reference(args.non_owning_reference);
|
||||
builder.add_co_owning_reference(args.co_owning_reference);
|
||||
builder.add_single_weak_reference(args.single_weak_reference);
|
||||
builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
|
||||
builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
|
||||
builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
|
||||
builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
|
||||
if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
|
||||
if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
|
||||
if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
|
||||
if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
|
||||
if let Some(x) = args.any_unique { builder.add_any_unique(x); }
|
||||
if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
|
||||
if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
|
||||
if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
|
||||
if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
|
||||
if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
|
||||
if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
|
||||
if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
|
||||
if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
|
||||
if let Some(x) = args.test5 { builder.add_test5(x); }
|
||||
if let Some(x) = args.flex { builder.add_flex(x); }
|
||||
if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
|
||||
if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
|
||||
builder.add_testf3(args.testf3);
|
||||
builder.add_testf2(args.testf2);
|
||||
builder.add_testf(args.testf);
|
||||
if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
|
||||
builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
|
||||
builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
|
||||
builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
|
||||
builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
|
||||
if let Some(x) = args.testempty { builder.add_testempty(x); }
|
||||
if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
|
||||
if let Some(x) = args.enemy { builder.add_enemy(x); }
|
||||
if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
|
||||
if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
|
||||
if let Some(x) = args.test4 { builder.add_test4(x); }
|
||||
if let Some(x) = args.test { builder.add_test(x); }
|
||||
if let Some(x) = args.inventory { builder.add_inventory(x); }
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
if let Some(x) = args.pos { builder.add_pos(x); }
|
||||
builder.add_hp(args.hp);
|
||||
builder.add_mana(args.mana);
|
||||
builder.add_signed_enum(args.signed_enum);
|
||||
builder.add_any_ambiguous_type(args.any_ambiguous_type);
|
||||
builder.add_any_unique_type(args.any_unique_type);
|
||||
builder.add_testbool(args.testbool);
|
||||
builder.add_test_type(args.test_type);
|
||||
builder.add_color(args.color);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Monster"
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MonsterArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
builder.add_non_owning_reference(args.non_owning_reference);
|
||||
builder.add_co_owning_reference(args.co_owning_reference);
|
||||
builder.add_single_weak_reference(args.single_weak_reference);
|
||||
builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
|
||||
builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
|
||||
builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
|
||||
builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
|
||||
if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
|
||||
if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
|
||||
if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
|
||||
if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
|
||||
if let Some(x) = args.any_unique { builder.add_any_unique(x); }
|
||||
if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
|
||||
if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
|
||||
if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
|
||||
if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
|
||||
if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
|
||||
if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
|
||||
if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
|
||||
if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
|
||||
if let Some(x) = args.test5 { builder.add_test5(x); }
|
||||
if let Some(x) = args.flex { builder.add_flex(x); }
|
||||
if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
|
||||
if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
|
||||
builder.add_testf3(args.testf3);
|
||||
builder.add_testf2(args.testf2);
|
||||
builder.add_testf(args.testf);
|
||||
if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
|
||||
builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
|
||||
builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
|
||||
builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
|
||||
builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
|
||||
if let Some(x) = args.testempty { builder.add_testempty(x); }
|
||||
if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
|
||||
if let Some(x) = args.enemy { builder.add_enemy(x); }
|
||||
if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
|
||||
if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
|
||||
if let Some(x) = args.test4 { builder.add_test4(x); }
|
||||
if let Some(x) = args.test { builder.add_test(x); }
|
||||
if let Some(x) = args.inventory { builder.add_inventory(x); }
|
||||
if let Some(x) = args.name { builder.add_name(x); }
|
||||
if let Some(x) = args.pos { builder.add_pos(x); }
|
||||
builder.add_hp(args.hp);
|
||||
builder.add_mana(args.mana);
|
||||
builder.add_signed_enum(args.signed_enum);
|
||||
builder.add_any_ambiguous_type(args.any_ambiguous_type);
|
||||
builder.add_any_unique_type(args.any_unique_type);
|
||||
builder.add_testbool(args.testbool);
|
||||
builder.add_test_type(args.test_type);
|
||||
builder.add_color(args.color);
|
||||
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;
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_TEST_TYPE: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_TEST: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_TEST4: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_TESTARRAYOFSTRING: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_TESTARRAYOFTABLES: flatbuffers::VOffsetT = 26;
|
||||
pub const VT_ENEMY: flatbuffers::VOffsetT = 28;
|
||||
pub const VT_TESTNESTEDFLATBUFFER: flatbuffers::VOffsetT = 30;
|
||||
pub const VT_TESTEMPTY: flatbuffers::VOffsetT = 32;
|
||||
pub const VT_TESTBOOL: flatbuffers::VOffsetT = 34;
|
||||
pub const VT_TESTHASHS32_FNV1: flatbuffers::VOffsetT = 36;
|
||||
pub const VT_TESTHASHU32_FNV1: flatbuffers::VOffsetT = 38;
|
||||
pub const VT_TESTHASHS64_FNV1: flatbuffers::VOffsetT = 40;
|
||||
pub const VT_TESTHASHU64_FNV1: flatbuffers::VOffsetT = 42;
|
||||
pub const VT_TESTHASHS32_FNV1A: flatbuffers::VOffsetT = 44;
|
||||
pub const VT_TESTHASHU32_FNV1A: flatbuffers::VOffsetT = 46;
|
||||
pub const VT_TESTHASHS64_FNV1A: flatbuffers::VOffsetT = 48;
|
||||
pub const VT_TESTHASHU64_FNV1A: flatbuffers::VOffsetT = 50;
|
||||
pub const VT_TESTARRAYOFBOOLS: flatbuffers::VOffsetT = 52;
|
||||
pub const VT_TESTF: flatbuffers::VOffsetT = 54;
|
||||
pub const VT_TESTF2: flatbuffers::VOffsetT = 56;
|
||||
pub const VT_TESTF3: flatbuffers::VOffsetT = 58;
|
||||
pub const VT_TESTARRAYOFSTRING2: flatbuffers::VOffsetT = 60;
|
||||
pub const VT_TESTARRAYOFSORTEDSTRUCT: flatbuffers::VOffsetT = 62;
|
||||
pub const VT_FLEX: flatbuffers::VOffsetT = 64;
|
||||
pub const VT_TEST5: flatbuffers::VOffsetT = 66;
|
||||
pub const VT_VECTOR_OF_LONGS: flatbuffers::VOffsetT = 68;
|
||||
pub const VT_VECTOR_OF_DOUBLES: flatbuffers::VOffsetT = 70;
|
||||
pub const VT_PARENT_NAMESPACE_TEST: flatbuffers::VOffsetT = 72;
|
||||
pub const VT_VECTOR_OF_REFERRABLES: flatbuffers::VOffsetT = 74;
|
||||
pub const VT_SINGLE_WEAK_REFERENCE: flatbuffers::VOffsetT = 76;
|
||||
pub const VT_VECTOR_OF_WEAK_REFERENCES: flatbuffers::VOffsetT = 78;
|
||||
pub const VT_VECTOR_OF_STRONG_REFERRABLES: flatbuffers::VOffsetT = 80;
|
||||
pub const VT_CO_OWNING_REFERENCE: flatbuffers::VOffsetT = 82;
|
||||
pub const VT_VECTOR_OF_CO_OWNING_REFERENCES: flatbuffers::VOffsetT = 84;
|
||||
pub const VT_NON_OWNING_REFERENCE: flatbuffers::VOffsetT = 86;
|
||||
pub const VT_VECTOR_OF_NON_OWNING_REFERENCES: flatbuffers::VOffsetT = 88;
|
||||
pub const VT_ANY_UNIQUE_TYPE: flatbuffers::VOffsetT = 90;
|
||||
pub const VT_ANY_UNIQUE: flatbuffers::VOffsetT = 92;
|
||||
pub const VT_ANY_AMBIGUOUS_TYPE: flatbuffers::VOffsetT = 94;
|
||||
pub const VT_ANY_AMBIGUOUS: flatbuffers::VOffsetT = 96;
|
||||
pub const VT_VECTOR_OF_ENUMS: flatbuffers::VOffsetT = 98;
|
||||
pub const VT_SIGNED_ENUM: flatbuffers::VOffsetT = 100;
|
||||
pub const VT_TESTREQUIREDNESTEDFLATBUFFER: flatbuffers::VOffsetT = 102;
|
||||
pub const VT_SCALAR_KEY_SORTED_TABLES: flatbuffers::VOffsetT = 104;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn pos(&self) -> Option<&'a Vec3> {
|
||||
@@ -358,12 +360,12 @@ impl<'a> Monster<'a> {
|
||||
self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()
|
||||
}
|
||||
#[inline]
|
||||
pub fn key_compare_less_than(&self, o: &Monster) -> bool {
|
||||
pub fn key_compare_less_than(&self, o: &Monster) -> bool {
|
||||
self.name() < o.name()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
|
||||
pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
|
||||
let key = self.name();
|
||||
key.cmp(val)
|
||||
}
|
||||
@@ -789,61 +791,61 @@ pub struct MonsterArgs<'a> {
|
||||
pub scalar_key_sorted_tables: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Stat<'a>>>>>,
|
||||
}
|
||||
impl<'a> Default for MonsterArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
pos: None,
|
||||
mana: 150,
|
||||
hp: 100,
|
||||
name: None, // required field
|
||||
inventory: None,
|
||||
color: Color::Blue,
|
||||
test_type: Any::NONE,
|
||||
test: None,
|
||||
test4: None,
|
||||
testarrayofstring: None,
|
||||
testarrayoftables: None,
|
||||
enemy: None,
|
||||
testnestedflatbuffer: None,
|
||||
testempty: None,
|
||||
testbool: false,
|
||||
testhashs32_fnv1: 0,
|
||||
testhashu32_fnv1: 0,
|
||||
testhashs64_fnv1: 0,
|
||||
testhashu64_fnv1: 0,
|
||||
testhashs32_fnv1a: 0,
|
||||
testhashu32_fnv1a: 0,
|
||||
testhashs64_fnv1a: 0,
|
||||
testhashu64_fnv1a: 0,
|
||||
testarrayofbools: None,
|
||||
testf: 3.14159,
|
||||
testf2: 3.0,
|
||||
testf3: 0.0,
|
||||
testarrayofstring2: None,
|
||||
testarrayofsortedstruct: None,
|
||||
flex: None,
|
||||
test5: None,
|
||||
vector_of_longs: None,
|
||||
vector_of_doubles: None,
|
||||
parent_namespace_test: None,
|
||||
vector_of_referrables: None,
|
||||
single_weak_reference: 0,
|
||||
vector_of_weak_references: None,
|
||||
vector_of_strong_referrables: None,
|
||||
co_owning_reference: 0,
|
||||
vector_of_co_owning_references: None,
|
||||
non_owning_reference: 0,
|
||||
vector_of_non_owning_references: None,
|
||||
any_unique_type: AnyUniqueAliases::NONE,
|
||||
any_unique: None,
|
||||
any_ambiguous_type: AnyAmbiguousAliases::NONE,
|
||||
any_ambiguous: None,
|
||||
vector_of_enums: None,
|
||||
signed_enum: Race::None,
|
||||
testrequirednestedflatbuffer: None,
|
||||
scalar_key_sorted_tables: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
pos: None,
|
||||
mana: 150,
|
||||
hp: 100,
|
||||
name: None, // required field
|
||||
inventory: None,
|
||||
color: Color::Blue,
|
||||
test_type: Any::NONE,
|
||||
test: None,
|
||||
test4: None,
|
||||
testarrayofstring: None,
|
||||
testarrayoftables: None,
|
||||
enemy: None,
|
||||
testnestedflatbuffer: None,
|
||||
testempty: None,
|
||||
testbool: false,
|
||||
testhashs32_fnv1: 0,
|
||||
testhashu32_fnv1: 0,
|
||||
testhashs64_fnv1: 0,
|
||||
testhashu64_fnv1: 0,
|
||||
testhashs32_fnv1a: 0,
|
||||
testhashu32_fnv1a: 0,
|
||||
testhashs64_fnv1a: 0,
|
||||
testhashu64_fnv1a: 0,
|
||||
testarrayofbools: None,
|
||||
testf: 3.14159,
|
||||
testf2: 3.0,
|
||||
testf3: 0.0,
|
||||
testarrayofstring2: None,
|
||||
testarrayofsortedstruct: None,
|
||||
flex: None,
|
||||
test5: None,
|
||||
vector_of_longs: None,
|
||||
vector_of_doubles: None,
|
||||
parent_namespace_test: None,
|
||||
vector_of_referrables: None,
|
||||
single_weak_reference: 0,
|
||||
vector_of_weak_references: None,
|
||||
vector_of_strong_referrables: None,
|
||||
co_owning_reference: 0,
|
||||
vector_of_co_owning_references: None,
|
||||
non_owning_reference: 0,
|
||||
vector_of_non_owning_references: None,
|
||||
any_unique_type: AnyUniqueAliases::NONE,
|
||||
any_unique: None,
|
||||
any_ambiguous_type: AnyAmbiguousAliases::NONE,
|
||||
any_ambiguous: None,
|
||||
vector_of_enums: None,
|
||||
signed_enum: Race::None,
|
||||
testrequirednestedflatbuffer: None,
|
||||
scalar_key_sorted_tables: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct MonsterBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,50 +12,52 @@ pub struct Referrable<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Referrable<'a> {
|
||||
type Inner = Referrable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Referrable<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Referrable<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Referrable"
|
||||
}
|
||||
pub const VT_ID: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Referrable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ReferrableArgs) -> flatbuffers::WIPOffset<Referrable<'bldr>> {
|
||||
let mut builder = ReferrableBuilder::new(_fbb);
|
||||
builder.add_id(args.id);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Referrable"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ReferrableT {
|
||||
let id = self.id();
|
||||
ReferrableT {
|
||||
id,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Referrable { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ReferrableArgs
|
||||
) -> flatbuffers::WIPOffset<Referrable<'bldr>> {
|
||||
let mut builder = ReferrableBuilder::new(_fbb);
|
||||
builder.add_id(args.id);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ReferrableT {
|
||||
let id = self.id();
|
||||
ReferrableT {
|
||||
id,
|
||||
}
|
||||
pub const VT_ID: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> u64 {
|
||||
self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()
|
||||
}
|
||||
#[inline]
|
||||
pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
|
||||
pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
|
||||
self.id() < o.id()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
|
||||
pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
|
||||
let key = self.id();
|
||||
key.cmp(&val)
|
||||
}
|
||||
@@ -77,12 +79,12 @@ pub struct ReferrableArgs {
|
||||
pub id: u64,
|
||||
}
|
||||
impl<'a> Default for ReferrableArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ReferrableArgs {
|
||||
id: 0,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ReferrableArgs {
|
||||
id: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct ReferrableBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,48 +12,50 @@ pub struct Stat<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Stat<'a> {
|
||||
type Inner = Stat<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Stat<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Stat<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Stat"
|
||||
}
|
||||
pub const VT_ID: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_VAL: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_COUNT: flatbuffers::VOffsetT = 8;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Stat { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args StatArgs<'args>) -> flatbuffers::WIPOffset<Stat<'bldr>> {
|
||||
let mut builder = StatBuilder::new(_fbb);
|
||||
builder.add_val(args.val);
|
||||
if let Some(x) = args.id { builder.add_id(x); }
|
||||
builder.add_count(args.count);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Stat"
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Stat { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args StatArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Stat<'bldr>> {
|
||||
let mut builder = StatBuilder::new(_fbb);
|
||||
builder.add_val(args.val);
|
||||
if let Some(x) = args.id { builder.add_id(x); }
|
||||
builder.add_count(args.count);
|
||||
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;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn id(&self) -> Option<&'a str> {
|
||||
@@ -68,12 +70,12 @@ impl<'a> Stat<'a> {
|
||||
self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()
|
||||
}
|
||||
#[inline]
|
||||
pub fn key_compare_less_than(&self, o: &Stat) -> bool {
|
||||
pub fn key_compare_less_than(&self, o: &Stat) -> bool {
|
||||
self.count() < o.count()
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
|
||||
pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
|
||||
let key = self.count();
|
||||
key.cmp(&val)
|
||||
}
|
||||
@@ -99,14 +101,14 @@ pub struct StatArgs<'a> {
|
||||
pub count: u16,
|
||||
}
|
||||
impl<'a> Default for StatArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
StatArgs {
|
||||
id: None,
|
||||
val: 0,
|
||||
count: 0,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
StatArgs {
|
||||
id: None,
|
||||
val: 0,
|
||||
count: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct StatBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -84,15 +84,15 @@ impl<'a> StructOfStructs {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.StructOfStructs"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.StructOfStructs"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> &Ability {
|
||||
unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
|
||||
}
|
||||
|
||||
#[allow(clippy::identity_op)]
|
||||
#[allow(clippy::identity_op)]
|
||||
pub fn set_a(&mut self, x: &Ability) {
|
||||
self.0[0..0 + 8].copy_from_slice(&x.0)
|
||||
}
|
||||
@@ -101,7 +101,7 @@ impl<'a> StructOfStructs {
|
||||
unsafe { &*(self.0[8..].as_ptr() as *const Test) }
|
||||
}
|
||||
|
||||
#[allow(clippy::identity_op)]
|
||||
#[allow(clippy::identity_op)]
|
||||
pub fn set_b(&mut self, x: &Test) {
|
||||
self.0[8..8 + 4].copy_from_slice(&x.0)
|
||||
}
|
||||
@@ -110,7 +110,7 @@ impl<'a> StructOfStructs {
|
||||
unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
|
||||
}
|
||||
|
||||
#[allow(clippy::identity_op)]
|
||||
#[allow(clippy::identity_op)]
|
||||
pub fn set_c(&mut self, x: &Ability) {
|
||||
self.0[12..12 + 8].copy_from_slice(&x.0)
|
||||
}
|
||||
|
||||
@@ -81,9 +81,9 @@ impl<'a> Test {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Test"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Test"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i16 {
|
||||
let mut mem = core::mem::MaybeUninit::<i16>::uninit();
|
||||
|
||||
@@ -12,38 +12,40 @@ pub struct TestSimpleTableWithEnum<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> {
|
||||
type Inner = TestSimpleTableWithEnum<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TestSimpleTableWithEnum<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TestSimpleTableWithEnum<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.TestSimpleTableWithEnum"
|
||||
}
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TestSimpleTableWithEnum { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TestSimpleTableWithEnumArgs) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
|
||||
let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
|
||||
builder.add_color(args.color);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.TestSimpleTableWithEnum"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TestSimpleTableWithEnumT {
|
||||
let color = self.color();
|
||||
TestSimpleTableWithEnumT {
|
||||
color,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TestSimpleTableWithEnum { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TestSimpleTableWithEnumArgs
|
||||
) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
|
||||
let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
|
||||
builder.add_color(args.color);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TestSimpleTableWithEnumT {
|
||||
let color = self.color();
|
||||
TestSimpleTableWithEnumT {
|
||||
color,
|
||||
}
|
||||
pub const VT_COLOR: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn color(&self) -> Color {
|
||||
@@ -67,12 +69,12 @@ pub struct TestSimpleTableWithEnumArgs {
|
||||
pub color: Color,
|
||||
}
|
||||
impl<'a> Default for TestSimpleTableWithEnumArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TestSimpleTableWithEnumArgs {
|
||||
color: Color::Green,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TestSimpleTableWithEnumArgs {
|
||||
color: Color::Green,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,86 +12,88 @@ pub struct TypeAliases<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TypeAliases<'a> {
|
||||
type Inner = TypeAliases<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TypeAliases<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TypeAliases<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.TypeAliases"
|
||||
}
|
||||
pub const VT_I8_: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_U8_: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_I16_: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_U16_: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_I32_: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_U32_: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_I64_: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_U64_: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_F32_: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_F64_: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_V8: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_VF64: flatbuffers::VOffsetT = 26;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TypeAliases { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TypeAliasesArgs<'args>) -> flatbuffers::WIPOffset<TypeAliases<'bldr>> {
|
||||
let mut builder = TypeAliasesBuilder::new(_fbb);
|
||||
builder.add_f64_(args.f64_);
|
||||
builder.add_u64_(args.u64_);
|
||||
builder.add_i64_(args.i64_);
|
||||
if let Some(x) = args.vf64 { builder.add_vf64(x); }
|
||||
if let Some(x) = args.v8 { builder.add_v8(x); }
|
||||
builder.add_f32_(args.f32_);
|
||||
builder.add_u32_(args.u32_);
|
||||
builder.add_i32_(args.i32_);
|
||||
builder.add_u16_(args.u16_);
|
||||
builder.add_i16_(args.i16_);
|
||||
builder.add_u8_(args.u8_);
|
||||
builder.add_i8_(args.i8_);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.TypeAliases"
|
||||
}
|
||||
|
||||
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,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TypeAliases { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TypeAliasesArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TypeAliases<'bldr>> {
|
||||
let mut builder = TypeAliasesBuilder::new(_fbb);
|
||||
builder.add_f64_(args.f64_);
|
||||
builder.add_u64_(args.u64_);
|
||||
builder.add_i64_(args.i64_);
|
||||
if let Some(x) = args.vf64 { builder.add_vf64(x); }
|
||||
if let Some(x) = args.v8 { builder.add_v8(x); }
|
||||
builder.add_f32_(args.f32_);
|
||||
builder.add_u32_(args.u32_);
|
||||
builder.add_i32_(args.i32_);
|
||||
builder.add_u16_(args.u16_);
|
||||
builder.add_i16_(args.i16_);
|
||||
builder.add_u8_(args.u8_);
|
||||
builder.add_i8_(args.i8_);
|
||||
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;
|
||||
pub const VT_U16_: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_I32_: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_U32_: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_I64_: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_U64_: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_F32_: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_F64_: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_V8: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_VF64: flatbuffers::VOffsetT = 26;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn i8_(&self) -> i8 {
|
||||
@@ -181,23 +183,23 @@ pub struct TypeAliasesArgs<'a> {
|
||||
pub vf64: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, f64>>>,
|
||||
}
|
||||
impl<'a> Default for TypeAliasesArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TypeAliasesArgs {
|
||||
i8_: 0,
|
||||
u8_: 0,
|
||||
i16_: 0,
|
||||
u16_: 0,
|
||||
i32_: 0,
|
||||
u32_: 0,
|
||||
i64_: 0,
|
||||
u64_: 0,
|
||||
f32_: 0.0,
|
||||
f64_: 0.0,
|
||||
v8: None,
|
||||
vf64: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TypeAliasesArgs {
|
||||
i8_: 0,
|
||||
u8_: 0,
|
||||
i16_: 0,
|
||||
u16_: 0,
|
||||
i32_: 0,
|
||||
u32_: 0,
|
||||
i64_: 0,
|
||||
u64_: 0,
|
||||
f32_: 0.0,
|
||||
f64_: 0.0,
|
||||
v8: None,
|
||||
vf64: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TypeAliasesBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -93,9 +93,9 @@ impl<'a> Vec3 {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Vec3"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example.Vec3"
|
||||
}
|
||||
|
||||
pub fn x(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<f32>::uninit();
|
||||
@@ -216,7 +216,7 @@ impl<'a> Vec3 {
|
||||
unsafe { &*(self.0[26..].as_ptr() as *const Test) }
|
||||
}
|
||||
|
||||
#[allow(clippy::identity_op)]
|
||||
#[allow(clippy::identity_op)]
|
||||
pub fn set_test3(&mut self, x: &Test) {
|
||||
self.0[26..26 + 4].copy_from_slice(&x.0)
|
||||
}
|
||||
|
||||
@@ -12,34 +12,36 @@ pub struct Monster<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Monster<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example2.Monster"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
_args: &'args MonsterArgs) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Example2.Monster"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> MonsterT {
|
||||
MonsterT {
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
Monster { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
_args: &'args MonsterArgs
|
||||
) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
let mut builder = MonsterBuilder::new(_fbb);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> MonsterT {
|
||||
MonsterT {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Verifiable for Monster<'_> {
|
||||
@@ -56,11 +58,11 @@ impl flatbuffers::Verifiable for Monster<'_> {
|
||||
pub struct MonsterArgs {
|
||||
}
|
||||
impl<'a> Default for MonsterArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MonsterArgs {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct MonsterBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,34 +12,36 @@ pub struct InParentNamespace<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for InParentNamespace<'a> {
|
||||
type Inner = InParentNamespace<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = InParentNamespace<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> InParentNamespace<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.InParentNamespace"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
InParentNamespace { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
_args: &'args InParentNamespaceArgs) -> flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
|
||||
let mut builder = InParentNamespaceBuilder::new(_fbb);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.InParentNamespace"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> InParentNamespaceT {
|
||||
InParentNamespaceT {
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
InParentNamespace { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
_args: &'args InParentNamespaceArgs
|
||||
) -> flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
|
||||
let mut builder = InParentNamespaceBuilder::new(_fbb);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> InParentNamespaceT {
|
||||
InParentNamespaceT {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Verifiable for InParentNamespace<'_> {
|
||||
@@ -56,11 +58,11 @@ impl flatbuffers::Verifiable for InParentNamespace<'_> {
|
||||
pub struct InParentNamespaceArgs {
|
||||
}
|
||||
impl<'a> Default for InParentNamespaceArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
InParentNamespaceArgs {
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
InParentNamespaceArgs {
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct InParentNamespaceBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableB<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableB<'a> {
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableB<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableB<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.TableB"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableB { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableBArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableB<'bldr>> {
|
||||
let mut builder = TableBBuilder::new(_fbb);
|
||||
if let Some(x) = args.a { builder.add_a(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableBT {
|
||||
let a = self.a().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableBT {
|
||||
a,
|
||||
}
|
||||
pub const VT_A: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn a(&self) -> Option<super::super::TableA<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableBArgs<'a> {
|
||||
pub a: Option<flatbuffers::WIPOffset<super::super::TableA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableBArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableBArgs {
|
||||
a: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableBBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -78,9 +78,9 @@ impl<'a> Unused {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.OtherNameSpace.Unused"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = core::mem::MaybeUninit::<i32>::uninit();
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct TableA<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableA<'a> {
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableA<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"TableA"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableAArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableA<'bldr>> {
|
||||
let mut builder = TableABuilder::new(_fbb);
|
||||
if let Some(x) = args.b { builder.add_b(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableAT {
|
||||
let b = self.b().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableAT {
|
||||
b,
|
||||
}
|
||||
pub const VT_B: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct TableAArgs<'a> {
|
||||
pub b: Option<flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableAArgs {
|
||||
b: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableABuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,76 +12,78 @@ pub struct MoreDefaults<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for MoreDefaults<'a> {
|
||||
type Inner = MoreDefaults<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = MoreDefaults<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> MoreDefaults<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MoreDefaults"
|
||||
}
|
||||
pub const VT_INTS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_FLOATS: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_EMPTY_STRING: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_SOME_STRING: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_ABCS: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_BOOLS: flatbuffers::VOffsetT = 14;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
MoreDefaults { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MoreDefaultsArgs<'args>) -> flatbuffers::WIPOffset<MoreDefaults<'bldr>> {
|
||||
let mut builder = MoreDefaultsBuilder::new(_fbb);
|
||||
if let Some(x) = args.bools { builder.add_bools(x); }
|
||||
if let Some(x) = args.abcs { builder.add_abcs(x); }
|
||||
if let Some(x) = args.some_string { builder.add_some_string(x); }
|
||||
if let Some(x) = args.empty_string { builder.add_empty_string(x); }
|
||||
if let Some(x) = args.floats { builder.add_floats(x); }
|
||||
if let Some(x) = args.ints { builder.add_ints(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MoreDefaults"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> MoreDefaultsT {
|
||||
let ints = {
|
||||
let x = self.ints();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let floats = {
|
||||
let x = self.floats();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let empty_string = {
|
||||
let x = self.empty_string();
|
||||
x.to_string()
|
||||
};
|
||||
let some_string = {
|
||||
let x = self.some_string();
|
||||
x.to_string()
|
||||
};
|
||||
let abcs = {
|
||||
let x = self.abcs();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let bools = {
|
||||
let x = self.bools();
|
||||
x.to_vec()
|
||||
};
|
||||
MoreDefaultsT {
|
||||
ints,
|
||||
floats,
|
||||
empty_string,
|
||||
some_string,
|
||||
abcs,
|
||||
bools,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
MoreDefaults { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args MoreDefaultsArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<MoreDefaults<'bldr>> {
|
||||
let mut builder = MoreDefaultsBuilder::new(_fbb);
|
||||
if let Some(x) = args.bools { builder.add_bools(x); }
|
||||
if let Some(x) = args.abcs { builder.add_abcs(x); }
|
||||
if let Some(x) = args.some_string { builder.add_some_string(x); }
|
||||
if let Some(x) = args.empty_string { builder.add_empty_string(x); }
|
||||
if let Some(x) = args.floats { builder.add_floats(x); }
|
||||
if let Some(x) = args.ints { builder.add_ints(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> MoreDefaultsT {
|
||||
let ints = {
|
||||
let x = self.ints();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let floats = {
|
||||
let x = self.floats();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let empty_string = {
|
||||
let x = self.empty_string();
|
||||
x.to_string()
|
||||
};
|
||||
let some_string = {
|
||||
let x = self.some_string();
|
||||
x.to_string()
|
||||
};
|
||||
let abcs = {
|
||||
let x = self.abcs();
|
||||
x.into_iter().collect()
|
||||
};
|
||||
let bools = {
|
||||
let x = self.bools();
|
||||
x.to_vec()
|
||||
};
|
||||
MoreDefaultsT {
|
||||
ints,
|
||||
floats,
|
||||
empty_string,
|
||||
some_string,
|
||||
abcs,
|
||||
bools,
|
||||
}
|
||||
pub const VT_INTS: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_FLOATS: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_EMPTY_STRING: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_SOME_STRING: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_ABCS: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_BOOLS: flatbuffers::VOffsetT = 14;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn ints(&self) -> flatbuffers::Vector<'a, i32> {
|
||||
@@ -135,17 +137,17 @@ pub struct MoreDefaultsArgs<'a> {
|
||||
pub bools: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, bool>>>,
|
||||
}
|
||||
impl<'a> Default for MoreDefaultsArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MoreDefaultsArgs {
|
||||
ints: None,
|
||||
floats: None,
|
||||
empty_string: None,
|
||||
some_string: None,
|
||||
abcs: None,
|
||||
bools: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
MoreDefaultsArgs {
|
||||
ints: None,
|
||||
floats: None,
|
||||
empty_string: None,
|
||||
some_string: None,
|
||||
abcs: None,
|
||||
bools: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct MoreDefaultsBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -1,24 +1,24 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod namespace_a {
|
||||
use super::*;
|
||||
pub mod namespace_b {
|
||||
use super::*;
|
||||
pub mod namespace_b {
|
||||
use super::*;
|
||||
mod union_in_nested_ns_generated;
|
||||
pub use self::union_in_nested_ns_generated::*;
|
||||
mod enum_in_nested_ns_generated;
|
||||
pub use self::enum_in_nested_ns_generated::*;
|
||||
mod table_in_nested_ns_generated;
|
||||
pub use self::table_in_nested_ns_generated::*;
|
||||
mod struct_in_nested_ns_generated;
|
||||
pub use self::struct_in_nested_ns_generated::*;
|
||||
} // namespace_b
|
||||
mod table_in_first_ns_generated;
|
||||
pub use self::table_in_first_ns_generated::*;
|
||||
mod second_table_in_a_generated;
|
||||
pub use self::second_table_in_a_generated::*;
|
||||
mod union_in_nested_ns_generated;
|
||||
pub use self::union_in_nested_ns_generated::*;
|
||||
mod enum_in_nested_ns_generated;
|
||||
pub use self::enum_in_nested_ns_generated::*;
|
||||
mod table_in_nested_ns_generated;
|
||||
pub use self::table_in_nested_ns_generated::*;
|
||||
mod struct_in_nested_ns_generated;
|
||||
pub use self::struct_in_nested_ns_generated::*;
|
||||
} // namespace_b
|
||||
mod table_in_first_ns_generated;
|
||||
pub use self::table_in_first_ns_generated::*;
|
||||
mod second_table_in_a_generated;
|
||||
pub use self::second_table_in_a_generated::*;
|
||||
} // namespace_a
|
||||
pub mod namespace_c {
|
||||
use super::*;
|
||||
mod table_in_c_generated;
|
||||
pub use self::table_in_c_generated::*;
|
||||
use super::*;
|
||||
mod table_in_c_generated;
|
||||
pub use self::table_in_c_generated::*;
|
||||
} // namespace_c
|
||||
|
||||
@@ -81,9 +81,9 @@ impl<'a> StructInNestedNS {
|
||||
s
|
||||
}
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.StructInNestedNS"
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.StructInNestedNS"
|
||||
}
|
||||
|
||||
pub fn a(&self) -> i32 {
|
||||
let mut mem = core::mem::MaybeUninit::<i32>::uninit();
|
||||
|
||||
@@ -12,38 +12,40 @@ pub struct TableInNestedNS<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> {
|
||||
type Inner = TableInNestedNS<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableInNestedNS<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableInNestedNS<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.TableInNestedNS"
|
||||
}
|
||||
pub const VT_FOO: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInNestedNS { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableInNestedNSArgs) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
|
||||
let mut builder = TableInNestedNSBuilder::new(_fbb);
|
||||
builder.add_foo(args.foo);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.NamespaceB.TableInNestedNS"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableInNestedNST {
|
||||
let foo = self.foo();
|
||||
TableInNestedNST {
|
||||
foo,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInNestedNS { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableInNestedNSArgs
|
||||
) -> flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
|
||||
let mut builder = TableInNestedNSBuilder::new(_fbb);
|
||||
builder.add_foo(args.foo);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableInNestedNST {
|
||||
let foo = self.foo();
|
||||
TableInNestedNST {
|
||||
foo,
|
||||
}
|
||||
pub const VT_FOO: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn foo(&self) -> i32 {
|
||||
@@ -67,12 +69,12 @@ pub struct TableInNestedNSArgs {
|
||||
pub foo: i32,
|
||||
}
|
||||
impl<'a> Default for TableInNestedNSArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableInNestedNSArgs {
|
||||
foo: 0,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableInNestedNSArgs {
|
||||
foo: 0,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableInNestedNSBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,40 +12,42 @@ pub struct SecondTableInA<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for SecondTableInA<'a> {
|
||||
type Inner = SecondTableInA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = SecondTableInA<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> SecondTableInA<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.SecondTableInA"
|
||||
}
|
||||
pub const VT_REFER_TO_C: flatbuffers::VOffsetT = 4;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
SecondTableInA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args SecondTableInAArgs<'args>) -> flatbuffers::WIPOffset<SecondTableInA<'bldr>> {
|
||||
let mut builder = SecondTableInABuilder::new(_fbb);
|
||||
if let Some(x) = args.refer_to_c { builder.add_refer_to_c(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.SecondTableInA"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> SecondTableInAT {
|
||||
let refer_to_c = self.refer_to_c().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
SecondTableInAT {
|
||||
refer_to_c,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
SecondTableInA { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args SecondTableInAArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<SecondTableInA<'bldr>> {
|
||||
let mut builder = SecondTableInABuilder::new(_fbb);
|
||||
if let Some(x) = args.refer_to_c { builder.add_refer_to_c(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> SecondTableInAT {
|
||||
let refer_to_c = self.refer_to_c().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
SecondTableInAT {
|
||||
refer_to_c,
|
||||
}
|
||||
pub const VT_REFER_TO_C: flatbuffers::VOffsetT = 4;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refer_to_c(&self) -> Option<super::namespace_c::TableInC<'a>> {
|
||||
@@ -69,12 +71,12 @@ pub struct SecondTableInAArgs<'a> {
|
||||
pub refer_to_c: Option<flatbuffers::WIPOffset<super::namespace_c::TableInC<'a>>>,
|
||||
}
|
||||
impl<'a> Default for SecondTableInAArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
SecondTableInAArgs {
|
||||
refer_to_c: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
SecondTableInAArgs {
|
||||
refer_to_c: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct SecondTableInABuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -12,64 +12,66 @@ pub struct TableInFirstNS<'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 } }
|
||||
}
|
||||
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 fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.TableInFirstNS"
|
||||
}
|
||||
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;
|
||||
|
||||
#[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 const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceA.TableInFirstNS"
|
||||
}
|
||||
|
||||
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 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,
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn foo_table(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
|
||||
@@ -131,16 +133,16 @@ pub struct TableInFirstNSArgs<'a> {
|
||||
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,
|
||||
}
|
||||
#[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>,
|
||||
|
||||
@@ -12,46 +12,48 @@ pub struct TableInC<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for TableInC<'a> {
|
||||
type Inner = TableInC<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = TableInC<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> TableInC<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceC.TableInC"
|
||||
}
|
||||
pub const VT_REFER_TO_A1: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_REFER_TO_A2: flatbuffers::VOffsetT = 6;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInC { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableInCArgs<'args>) -> flatbuffers::WIPOffset<TableInC<'bldr>> {
|
||||
let mut builder = TableInCBuilder::new(_fbb);
|
||||
if let Some(x) = args.refer_to_a2 { builder.add_refer_to_a2(x); }
|
||||
if let Some(x) = args.refer_to_a1 { builder.add_refer_to_a1(x); }
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"NamespaceC.TableInC"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableInCT {
|
||||
let refer_to_a1 = self.refer_to_a1().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
let refer_to_a2 = self.refer_to_a2().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableInCT {
|
||||
refer_to_a1,
|
||||
refer_to_a2,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
TableInC { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args TableInCArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<TableInC<'bldr>> {
|
||||
let mut builder = TableInCBuilder::new(_fbb);
|
||||
if let Some(x) = args.refer_to_a2 { builder.add_refer_to_a2(x); }
|
||||
if let Some(x) = args.refer_to_a1 { builder.add_refer_to_a1(x); }
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> TableInCT {
|
||||
let refer_to_a1 = self.refer_to_a1().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
let refer_to_a2 = self.refer_to_a2().map(|x| {
|
||||
Box::new(x.unpack())
|
||||
});
|
||||
TableInCT {
|
||||
refer_to_a1,
|
||||
refer_to_a2,
|
||||
}
|
||||
pub const VT_REFER_TO_A1: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_REFER_TO_A2: flatbuffers::VOffsetT = 6;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn refer_to_a1(&self) -> Option<super::namespace_a::TableInFirstNS<'a>> {
|
||||
@@ -81,13 +83,13 @@ pub struct TableInCArgs<'a> {
|
||||
pub refer_to_a2: Option<flatbuffers::WIPOffset<super::namespace_a::SecondTableInA<'a>>>,
|
||||
}
|
||||
impl<'a> Default for TableInCArgs<'a> {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableInCArgs {
|
||||
refer_to_a1: None,
|
||||
refer_to_a2: None,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
TableInCArgs {
|
||||
refer_to_a1: None,
|
||||
refer_to_a2: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct TableInCBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
// Automatically generated by the Flatbuffers compiler. Do not modify.
|
||||
pub mod optional_scalars {
|
||||
use super::*;
|
||||
mod optional_byte_generated;
|
||||
pub use self::optional_byte_generated::*;
|
||||
mod scalar_stuff_generated;
|
||||
pub use self::scalar_stuff_generated::*;
|
||||
use super::*;
|
||||
mod optional_byte_generated;
|
||||
pub use self::optional_byte_generated::*;
|
||||
mod scalar_stuff_generated;
|
||||
pub use self::scalar_stuff_generated::*;
|
||||
} // optional_scalars
|
||||
|
||||
@@ -12,178 +12,180 @@ pub struct ScalarStuff<'a> {
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for ScalarStuff<'a> {
|
||||
type Inner = ScalarStuff<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
type Inner = ScalarStuff<'a>;
|
||||
#[inline]
|
||||
fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: flatbuffers::Table { buf, loc } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ScalarStuff<'a> {
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"optional_scalars.ScalarStuff"
|
||||
}
|
||||
pub const VT_JUST_I8: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_MAYBE_I8: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_DEFAULT_I8: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_JUST_U8: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_MAYBE_U8: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_DEFAULT_U8: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_JUST_I16: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_MAYBE_I16: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_DEFAULT_I16: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_JUST_U16: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_MAYBE_U16: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_DEFAULT_U16: flatbuffers::VOffsetT = 26;
|
||||
pub const VT_JUST_I32: flatbuffers::VOffsetT = 28;
|
||||
pub const VT_MAYBE_I32: flatbuffers::VOffsetT = 30;
|
||||
pub const VT_DEFAULT_I32: flatbuffers::VOffsetT = 32;
|
||||
pub const VT_JUST_U32: flatbuffers::VOffsetT = 34;
|
||||
pub const VT_MAYBE_U32: flatbuffers::VOffsetT = 36;
|
||||
pub const VT_DEFAULT_U32: flatbuffers::VOffsetT = 38;
|
||||
pub const VT_JUST_I64: flatbuffers::VOffsetT = 40;
|
||||
pub const VT_MAYBE_I64: flatbuffers::VOffsetT = 42;
|
||||
pub const VT_DEFAULT_I64: flatbuffers::VOffsetT = 44;
|
||||
pub const VT_JUST_U64: flatbuffers::VOffsetT = 46;
|
||||
pub const VT_MAYBE_U64: flatbuffers::VOffsetT = 48;
|
||||
pub const VT_DEFAULT_U64: flatbuffers::VOffsetT = 50;
|
||||
pub const VT_JUST_F32: flatbuffers::VOffsetT = 52;
|
||||
pub const VT_MAYBE_F32: flatbuffers::VOffsetT = 54;
|
||||
pub const VT_DEFAULT_F32: flatbuffers::VOffsetT = 56;
|
||||
pub const VT_JUST_F64: flatbuffers::VOffsetT = 58;
|
||||
pub const VT_MAYBE_F64: flatbuffers::VOffsetT = 60;
|
||||
pub const VT_DEFAULT_F64: flatbuffers::VOffsetT = 62;
|
||||
pub const VT_JUST_BOOL: flatbuffers::VOffsetT = 64;
|
||||
pub const VT_MAYBE_BOOL: flatbuffers::VOffsetT = 66;
|
||||
pub const VT_DEFAULT_BOOL: flatbuffers::VOffsetT = 68;
|
||||
pub const VT_JUST_ENUM: flatbuffers::VOffsetT = 70;
|
||||
pub const VT_MAYBE_ENUM: flatbuffers::VOffsetT = 72;
|
||||
pub const VT_DEFAULT_ENUM: flatbuffers::VOffsetT = 74;
|
||||
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ScalarStuff { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ScalarStuffArgs) -> flatbuffers::WIPOffset<ScalarStuff<'bldr>> {
|
||||
let mut builder = ScalarStuffBuilder::new(_fbb);
|
||||
builder.add_default_f64(args.default_f64);
|
||||
if let Some(x) = args.maybe_f64 { builder.add_maybe_f64(x); }
|
||||
builder.add_just_f64(args.just_f64);
|
||||
builder.add_default_u64(args.default_u64);
|
||||
if let Some(x) = args.maybe_u64 { builder.add_maybe_u64(x); }
|
||||
builder.add_just_u64(args.just_u64);
|
||||
builder.add_default_i64(args.default_i64);
|
||||
if let Some(x) = args.maybe_i64 { builder.add_maybe_i64(x); }
|
||||
builder.add_just_i64(args.just_i64);
|
||||
builder.add_default_f32(args.default_f32);
|
||||
if let Some(x) = args.maybe_f32 { builder.add_maybe_f32(x); }
|
||||
builder.add_just_f32(args.just_f32);
|
||||
builder.add_default_u32(args.default_u32);
|
||||
if let Some(x) = args.maybe_u32 { builder.add_maybe_u32(x); }
|
||||
builder.add_just_u32(args.just_u32);
|
||||
builder.add_default_i32(args.default_i32);
|
||||
if let Some(x) = args.maybe_i32 { builder.add_maybe_i32(x); }
|
||||
builder.add_just_i32(args.just_i32);
|
||||
builder.add_default_u16(args.default_u16);
|
||||
if let Some(x) = args.maybe_u16 { builder.add_maybe_u16(x); }
|
||||
builder.add_just_u16(args.just_u16);
|
||||
builder.add_default_i16(args.default_i16);
|
||||
if let Some(x) = args.maybe_i16 { builder.add_maybe_i16(x); }
|
||||
builder.add_just_i16(args.just_i16);
|
||||
builder.add_default_enum(args.default_enum);
|
||||
if let Some(x) = args.maybe_enum { builder.add_maybe_enum(x); }
|
||||
builder.add_just_enum(args.just_enum);
|
||||
builder.add_default_bool(args.default_bool);
|
||||
if let Some(x) = args.maybe_bool { builder.add_maybe_bool(x); }
|
||||
builder.add_just_bool(args.just_bool);
|
||||
builder.add_default_u8(args.default_u8);
|
||||
if let Some(x) = args.maybe_u8 { builder.add_maybe_u8(x); }
|
||||
builder.add_just_u8(args.just_u8);
|
||||
builder.add_default_i8(args.default_i8);
|
||||
if let Some(x) = args.maybe_i8 { builder.add_maybe_i8(x); }
|
||||
builder.add_just_i8(args.just_i8);
|
||||
builder.finish()
|
||||
}
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"optional_scalars.ScalarStuff"
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ScalarStuffT {
|
||||
let just_i8 = self.just_i8();
|
||||
let maybe_i8 = self.maybe_i8();
|
||||
let default_i8 = self.default_i8();
|
||||
let just_u8 = self.just_u8();
|
||||
let maybe_u8 = self.maybe_u8();
|
||||
let default_u8 = self.default_u8();
|
||||
let just_i16 = self.just_i16();
|
||||
let maybe_i16 = self.maybe_i16();
|
||||
let default_i16 = self.default_i16();
|
||||
let just_u16 = self.just_u16();
|
||||
let maybe_u16 = self.maybe_u16();
|
||||
let default_u16 = self.default_u16();
|
||||
let just_i32 = self.just_i32();
|
||||
let maybe_i32 = self.maybe_i32();
|
||||
let default_i32 = self.default_i32();
|
||||
let just_u32 = self.just_u32();
|
||||
let maybe_u32 = self.maybe_u32();
|
||||
let default_u32 = self.default_u32();
|
||||
let just_i64 = self.just_i64();
|
||||
let maybe_i64 = self.maybe_i64();
|
||||
let default_i64 = self.default_i64();
|
||||
let just_u64 = self.just_u64();
|
||||
let maybe_u64 = self.maybe_u64();
|
||||
let default_u64 = self.default_u64();
|
||||
let just_f32 = self.just_f32();
|
||||
let maybe_f32 = self.maybe_f32();
|
||||
let default_f32 = self.default_f32();
|
||||
let just_f64 = self.just_f64();
|
||||
let maybe_f64 = self.maybe_f64();
|
||||
let default_f64 = self.default_f64();
|
||||
let just_bool = self.just_bool();
|
||||
let maybe_bool = self.maybe_bool();
|
||||
let default_bool = self.default_bool();
|
||||
let just_enum = self.just_enum();
|
||||
let maybe_enum = self.maybe_enum();
|
||||
let default_enum = self.default_enum();
|
||||
ScalarStuffT {
|
||||
just_i8,
|
||||
maybe_i8,
|
||||
default_i8,
|
||||
just_u8,
|
||||
maybe_u8,
|
||||
default_u8,
|
||||
just_i16,
|
||||
maybe_i16,
|
||||
default_i16,
|
||||
just_u16,
|
||||
maybe_u16,
|
||||
default_u16,
|
||||
just_i32,
|
||||
maybe_i32,
|
||||
default_i32,
|
||||
just_u32,
|
||||
maybe_u32,
|
||||
default_u32,
|
||||
just_i64,
|
||||
maybe_i64,
|
||||
default_i64,
|
||||
just_u64,
|
||||
maybe_u64,
|
||||
default_u64,
|
||||
just_f32,
|
||||
maybe_f32,
|
||||
default_f32,
|
||||
just_f64,
|
||||
maybe_f64,
|
||||
default_f64,
|
||||
just_bool,
|
||||
maybe_bool,
|
||||
default_bool,
|
||||
just_enum,
|
||||
maybe_enum,
|
||||
default_enum,
|
||||
}
|
||||
#[inline]
|
||||
pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
ScalarStuff { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
|
||||
args: &'args ScalarStuffArgs
|
||||
) -> flatbuffers::WIPOffset<ScalarStuff<'bldr>> {
|
||||
let mut builder = ScalarStuffBuilder::new(_fbb);
|
||||
builder.add_default_f64(args.default_f64);
|
||||
if let Some(x) = args.maybe_f64 { builder.add_maybe_f64(x); }
|
||||
builder.add_just_f64(args.just_f64);
|
||||
builder.add_default_u64(args.default_u64);
|
||||
if let Some(x) = args.maybe_u64 { builder.add_maybe_u64(x); }
|
||||
builder.add_just_u64(args.just_u64);
|
||||
builder.add_default_i64(args.default_i64);
|
||||
if let Some(x) = args.maybe_i64 { builder.add_maybe_i64(x); }
|
||||
builder.add_just_i64(args.just_i64);
|
||||
builder.add_default_f32(args.default_f32);
|
||||
if let Some(x) = args.maybe_f32 { builder.add_maybe_f32(x); }
|
||||
builder.add_just_f32(args.just_f32);
|
||||
builder.add_default_u32(args.default_u32);
|
||||
if let Some(x) = args.maybe_u32 { builder.add_maybe_u32(x); }
|
||||
builder.add_just_u32(args.just_u32);
|
||||
builder.add_default_i32(args.default_i32);
|
||||
if let Some(x) = args.maybe_i32 { builder.add_maybe_i32(x); }
|
||||
builder.add_just_i32(args.just_i32);
|
||||
builder.add_default_u16(args.default_u16);
|
||||
if let Some(x) = args.maybe_u16 { builder.add_maybe_u16(x); }
|
||||
builder.add_just_u16(args.just_u16);
|
||||
builder.add_default_i16(args.default_i16);
|
||||
if let Some(x) = args.maybe_i16 { builder.add_maybe_i16(x); }
|
||||
builder.add_just_i16(args.just_i16);
|
||||
builder.add_default_enum(args.default_enum);
|
||||
if let Some(x) = args.maybe_enum { builder.add_maybe_enum(x); }
|
||||
builder.add_just_enum(args.just_enum);
|
||||
builder.add_default_bool(args.default_bool);
|
||||
if let Some(x) = args.maybe_bool { builder.add_maybe_bool(x); }
|
||||
builder.add_just_bool(args.just_bool);
|
||||
builder.add_default_u8(args.default_u8);
|
||||
if let Some(x) = args.maybe_u8 { builder.add_maybe_u8(x); }
|
||||
builder.add_just_u8(args.just_u8);
|
||||
builder.add_default_i8(args.default_i8);
|
||||
if let Some(x) = args.maybe_i8 { builder.add_maybe_i8(x); }
|
||||
builder.add_just_i8(args.just_i8);
|
||||
builder.finish()
|
||||
}
|
||||
|
||||
pub fn unpack(&self) -> ScalarStuffT {
|
||||
let just_i8 = self.just_i8();
|
||||
let maybe_i8 = self.maybe_i8();
|
||||
let default_i8 = self.default_i8();
|
||||
let just_u8 = self.just_u8();
|
||||
let maybe_u8 = self.maybe_u8();
|
||||
let default_u8 = self.default_u8();
|
||||
let just_i16 = self.just_i16();
|
||||
let maybe_i16 = self.maybe_i16();
|
||||
let default_i16 = self.default_i16();
|
||||
let just_u16 = self.just_u16();
|
||||
let maybe_u16 = self.maybe_u16();
|
||||
let default_u16 = self.default_u16();
|
||||
let just_i32 = self.just_i32();
|
||||
let maybe_i32 = self.maybe_i32();
|
||||
let default_i32 = self.default_i32();
|
||||
let just_u32 = self.just_u32();
|
||||
let maybe_u32 = self.maybe_u32();
|
||||
let default_u32 = self.default_u32();
|
||||
let just_i64 = self.just_i64();
|
||||
let maybe_i64 = self.maybe_i64();
|
||||
let default_i64 = self.default_i64();
|
||||
let just_u64 = self.just_u64();
|
||||
let maybe_u64 = self.maybe_u64();
|
||||
let default_u64 = self.default_u64();
|
||||
let just_f32 = self.just_f32();
|
||||
let maybe_f32 = self.maybe_f32();
|
||||
let default_f32 = self.default_f32();
|
||||
let just_f64 = self.just_f64();
|
||||
let maybe_f64 = self.maybe_f64();
|
||||
let default_f64 = self.default_f64();
|
||||
let just_bool = self.just_bool();
|
||||
let maybe_bool = self.maybe_bool();
|
||||
let default_bool = self.default_bool();
|
||||
let just_enum = self.just_enum();
|
||||
let maybe_enum = self.maybe_enum();
|
||||
let default_enum = self.default_enum();
|
||||
ScalarStuffT {
|
||||
just_i8,
|
||||
maybe_i8,
|
||||
default_i8,
|
||||
just_u8,
|
||||
maybe_u8,
|
||||
default_u8,
|
||||
just_i16,
|
||||
maybe_i16,
|
||||
default_i16,
|
||||
just_u16,
|
||||
maybe_u16,
|
||||
default_u16,
|
||||
just_i32,
|
||||
maybe_i32,
|
||||
default_i32,
|
||||
just_u32,
|
||||
maybe_u32,
|
||||
default_u32,
|
||||
just_i64,
|
||||
maybe_i64,
|
||||
default_i64,
|
||||
just_u64,
|
||||
maybe_u64,
|
||||
default_u64,
|
||||
just_f32,
|
||||
maybe_f32,
|
||||
default_f32,
|
||||
just_f64,
|
||||
maybe_f64,
|
||||
default_f64,
|
||||
just_bool,
|
||||
maybe_bool,
|
||||
default_bool,
|
||||
just_enum,
|
||||
maybe_enum,
|
||||
default_enum,
|
||||
}
|
||||
pub const VT_JUST_I8: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_MAYBE_I8: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_DEFAULT_I8: flatbuffers::VOffsetT = 8;
|
||||
pub const VT_JUST_U8: flatbuffers::VOffsetT = 10;
|
||||
pub const VT_MAYBE_U8: flatbuffers::VOffsetT = 12;
|
||||
pub const VT_DEFAULT_U8: flatbuffers::VOffsetT = 14;
|
||||
pub const VT_JUST_I16: flatbuffers::VOffsetT = 16;
|
||||
pub const VT_MAYBE_I16: flatbuffers::VOffsetT = 18;
|
||||
pub const VT_DEFAULT_I16: flatbuffers::VOffsetT = 20;
|
||||
pub const VT_JUST_U16: flatbuffers::VOffsetT = 22;
|
||||
pub const VT_MAYBE_U16: flatbuffers::VOffsetT = 24;
|
||||
pub const VT_DEFAULT_U16: flatbuffers::VOffsetT = 26;
|
||||
pub const VT_JUST_I32: flatbuffers::VOffsetT = 28;
|
||||
pub const VT_MAYBE_I32: flatbuffers::VOffsetT = 30;
|
||||
pub const VT_DEFAULT_I32: flatbuffers::VOffsetT = 32;
|
||||
pub const VT_JUST_U32: flatbuffers::VOffsetT = 34;
|
||||
pub const VT_MAYBE_U32: flatbuffers::VOffsetT = 36;
|
||||
pub const VT_DEFAULT_U32: flatbuffers::VOffsetT = 38;
|
||||
pub const VT_JUST_I64: flatbuffers::VOffsetT = 40;
|
||||
pub const VT_MAYBE_I64: flatbuffers::VOffsetT = 42;
|
||||
pub const VT_DEFAULT_I64: flatbuffers::VOffsetT = 44;
|
||||
pub const VT_JUST_U64: flatbuffers::VOffsetT = 46;
|
||||
pub const VT_MAYBE_U64: flatbuffers::VOffsetT = 48;
|
||||
pub const VT_DEFAULT_U64: flatbuffers::VOffsetT = 50;
|
||||
pub const VT_JUST_F32: flatbuffers::VOffsetT = 52;
|
||||
pub const VT_MAYBE_F32: flatbuffers::VOffsetT = 54;
|
||||
pub const VT_DEFAULT_F32: flatbuffers::VOffsetT = 56;
|
||||
pub const VT_JUST_F64: flatbuffers::VOffsetT = 58;
|
||||
pub const VT_MAYBE_F64: flatbuffers::VOffsetT = 60;
|
||||
pub const VT_DEFAULT_F64: flatbuffers::VOffsetT = 62;
|
||||
pub const VT_JUST_BOOL: flatbuffers::VOffsetT = 64;
|
||||
pub const VT_MAYBE_BOOL: flatbuffers::VOffsetT = 66;
|
||||
pub const VT_DEFAULT_BOOL: flatbuffers::VOffsetT = 68;
|
||||
pub const VT_JUST_ENUM: flatbuffers::VOffsetT = 70;
|
||||
pub const VT_MAYBE_ENUM: flatbuffers::VOffsetT = 72;
|
||||
pub const VT_DEFAULT_ENUM: flatbuffers::VOffsetT = 74;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn just_i8(&self) -> i8 {
|
||||
@@ -417,47 +419,47 @@ pub struct ScalarStuffArgs {
|
||||
pub default_enum: OptionalByte,
|
||||
}
|
||||
impl<'a> Default for ScalarStuffArgs {
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ScalarStuffArgs {
|
||||
just_i8: 0,
|
||||
maybe_i8: None,
|
||||
default_i8: 42,
|
||||
just_u8: 0,
|
||||
maybe_u8: None,
|
||||
default_u8: 42,
|
||||
just_i16: 0,
|
||||
maybe_i16: None,
|
||||
default_i16: 42,
|
||||
just_u16: 0,
|
||||
maybe_u16: None,
|
||||
default_u16: 42,
|
||||
just_i32: 0,
|
||||
maybe_i32: None,
|
||||
default_i32: 42,
|
||||
just_u32: 0,
|
||||
maybe_u32: None,
|
||||
default_u32: 42,
|
||||
just_i64: 0,
|
||||
maybe_i64: None,
|
||||
default_i64: 42,
|
||||
just_u64: 0,
|
||||
maybe_u64: None,
|
||||
default_u64: 42,
|
||||
just_f32: 0.0,
|
||||
maybe_f32: None,
|
||||
default_f32: 42.0,
|
||||
just_f64: 0.0,
|
||||
maybe_f64: None,
|
||||
default_f64: 42.0,
|
||||
just_bool: false,
|
||||
maybe_bool: None,
|
||||
default_bool: true,
|
||||
just_enum: OptionalByte::None,
|
||||
maybe_enum: None,
|
||||
default_enum: OptionalByte::One,
|
||||
}
|
||||
#[inline]
|
||||
fn default() -> Self {
|
||||
ScalarStuffArgs {
|
||||
just_i8: 0,
|
||||
maybe_i8: None,
|
||||
default_i8: 42,
|
||||
just_u8: 0,
|
||||
maybe_u8: None,
|
||||
default_u8: 42,
|
||||
just_i16: 0,
|
||||
maybe_i16: None,
|
||||
default_i16: 42,
|
||||
just_u16: 0,
|
||||
maybe_u16: None,
|
||||
default_u16: 42,
|
||||
just_i32: 0,
|
||||
maybe_i32: None,
|
||||
default_i32: 42,
|
||||
just_u32: 0,
|
||||
maybe_u32: None,
|
||||
default_u32: 42,
|
||||
just_i64: 0,
|
||||
maybe_i64: None,
|
||||
default_i64: 42,
|
||||
just_u64: 0,
|
||||
maybe_u64: None,
|
||||
default_u64: 42,
|
||||
just_f32: 0.0,
|
||||
maybe_f32: None,
|
||||
default_f32: 42.0,
|
||||
just_f64: 0.0,
|
||||
maybe_f64: None,
|
||||
default_f64: 42.0,
|
||||
just_bool: false,
|
||||
maybe_bool: None,
|
||||
default_bool: true,
|
||||
just_enum: OptionalByte::None,
|
||||
maybe_enum: None,
|
||||
default_enum: OptionalByte::One,
|
||||
}
|
||||
}
|
||||
}
|
||||
pub struct ScalarStuffBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
|
||||
Reference in New Issue
Block a user