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