forked from BigfootDev/flatbuffers
Fixes unused imports in Rust code generator (#8828)
* Fixes unused imports in Rust code generator * Regenerates generated schemas
This commit is contained in:
@@ -1,13 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MIN_COLOR: i8 = 0;
|
||||
@@ -47,8 +40,8 @@ impl Color {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for Color {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Color {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
if let Some(name) = self.variant_name() {
|
||||
f.write_str(name)
|
||||
} else {
|
||||
@@ -56,24 +49,24 @@ impl core::fmt::Debug for Color {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for Color {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Color {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Push for Color {
|
||||
impl ::flatbuffers::Push for Color {
|
||||
type Output = Color;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); }
|
||||
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::EndianScalar for Color {
|
||||
impl ::flatbuffers::EndianScalar for Color {
|
||||
type Scalar = i8;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> i8 {
|
||||
@@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for Color {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for Color {
|
||||
impl<'a> ::flatbuffers::Verifiable for Color {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
i8::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for Color {}
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Color {}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
|
||||
pub const ENUM_MIN_EQUIPMENT: u8 = 0;
|
||||
@@ -43,8 +36,8 @@ impl Equipment {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for Equipment {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Equipment {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
if let Some(name) = self.variant_name() {
|
||||
f.write_str(name)
|
||||
} else {
|
||||
@@ -52,24 +45,24 @@ impl core::fmt::Debug for Equipment {
|
||||
}
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for Equipment {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Equipment {
|
||||
type Inner = Self;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
let b = unsafe { flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
|
||||
Self(b)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Push for Equipment {
|
||||
impl ::flatbuffers::Push for Equipment {
|
||||
type Output = Equipment;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
|
||||
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::EndianScalar for Equipment {
|
||||
impl ::flatbuffers::EndianScalar for Equipment {
|
||||
type Scalar = u8;
|
||||
#[inline]
|
||||
fn to_little_endian(self) -> u8 {
|
||||
@@ -83,17 +76,16 @@ impl flatbuffers::EndianScalar for Equipment {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for Equipment {
|
||||
impl<'a> ::flatbuffers::Verifiable for Equipment {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
u8::run_verifier(v, pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for Equipment {}
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Equipment {}
|
||||
pub struct EquipmentUnionTableOffset {}
|
||||
|
||||
#[allow(clippy::upper_case_acronyms)]
|
||||
@@ -101,7 +93,7 @@ pub struct EquipmentUnionTableOffset {}
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum EquipmentT {
|
||||
NONE,
|
||||
Weapon(Box<WeaponT>),
|
||||
Weapon(alloc::boxed::Box<WeaponT>),
|
||||
}
|
||||
impl Default for EquipmentT {
|
||||
fn default() -> Self {
|
||||
@@ -115,16 +107,16 @@ impl EquipmentT {
|
||||
Self::Weapon(_) => Equipment::Weapon,
|
||||
}
|
||||
}
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>) -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>> {
|
||||
match self {
|
||||
Self::NONE => None,
|
||||
Self::Weapon(v) => Some(v.pack(fbb).as_union_value()),
|
||||
}
|
||||
}
|
||||
/// If the union variant matches, return the owned WeaponT, setting the union to NONE.
|
||||
pub fn take_weapon(&mut self) -> Option<Box<WeaponT>> {
|
||||
pub fn take_weapon(&mut self) -> Option<alloc::boxed::Box<WeaponT>> {
|
||||
if let Self::Weapon(_) = self {
|
||||
let v = core::mem::replace(self, Self::NONE);
|
||||
let v = ::core::mem::replace(self, Self::NONE);
|
||||
if let Self::Weapon(w) = v {
|
||||
Some(w)
|
||||
} else {
|
||||
|
||||
@@ -1,54 +1,47 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
pub enum MonsterOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct Monster<'a> {
|
||||
pub _tab: flatbuffers::Table<'a>,
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
|
||||
type Inner = Monster<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Monster<'a> {
|
||||
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;
|
||||
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;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Monster"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
pub unsafe 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, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args MonsterArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Monster<'bldr>> {
|
||||
) -> ::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); }
|
||||
@@ -70,7 +63,7 @@ impl<'a> Monster<'a> {
|
||||
let mana = self.mana();
|
||||
let hp = self.hp();
|
||||
let name = self.name().map(|x| {
|
||||
x.to_string()
|
||||
alloc::string::ToString::to_string(x)
|
||||
});
|
||||
let inventory = self.inventory().map(|x| {
|
||||
x.into_iter().collect()
|
||||
@@ -81,7 +74,7 @@ impl<'a> Monster<'a> {
|
||||
});
|
||||
let equipped = match self.equipped_type() {
|
||||
Equipment::NONE => EquipmentT::NONE,
|
||||
Equipment::Weapon => EquipmentT::Weapon(Box::new(
|
||||
Equipment::Weapon => EquipmentT::Weapon(alloc::boxed::Box::new(
|
||||
self.equipped_as_weapon()
|
||||
.expect("Invalid union table, expected `Equipment::Weapon`.")
|
||||
.unpack()
|
||||
@@ -130,14 +123,14 @@ impl<'a> Monster<'a> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn inventory(&self) -> Option<flatbuffers::Vector<'a, u8>> {
|
||||
pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn color(&self) -> Color {
|
||||
@@ -147,11 +140,11 @@ impl<'a> Monster<'a> {
|
||||
unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
|
||||
}
|
||||
#[inline]
|
||||
pub fn weapons(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
|
||||
pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn equipped_type(&self) -> Equipment {
|
||||
@@ -161,18 +154,18 @@ impl<'a> Monster<'a> {
|
||||
unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
|
||||
}
|
||||
#[inline]
|
||||
pub fn equipped(&self) -> Option<flatbuffers::Table<'a>> {
|
||||
pub fn equipped(&self) -> Option<::flatbuffers::Table<'a>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn path(&self) -> Option<flatbuffers::Vector<'a, Vec3>> {
|
||||
pub fn path(&self) -> Option<::flatbuffers::Vector<'a, Vec3>> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
|
||||
}
|
||||
#[inline]
|
||||
#[allow(non_snake_case)]
|
||||
@@ -191,27 +184,26 @@ impl<'a> Monster<'a> {
|
||||
|
||||
}
|
||||
|
||||
impl flatbuffers::Verifiable for Monster<'_> {
|
||||
impl ::flatbuffers::Verifiable for Monster<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<Vec3>("pos", Self::VT_POS, false)?
|
||||
.visit_field::<i16>("mana", Self::VT_MANA, false)?
|
||||
.visit_field::<i16>("hp", Self::VT_HP, false)?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
|
||||
.visit_field::<Color>("color", Self::VT_COLOR, false)?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Weapon>>>>("weapons", Self::VT_WEAPONS, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Weapon>>>>("weapons", Self::VT_WEAPONS, false)?
|
||||
.visit_union::<Equipment, _>("equipped_type", Self::VT_EQUIPPED_TYPE, "equipped", Self::VT_EQUIPPED, false, |key, v, pos| {
|
||||
match key {
|
||||
Equipment::Weapon => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Weapon>>("Equipment::Weapon", pos),
|
||||
Equipment::Weapon => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Weapon>>("Equipment::Weapon", pos),
|
||||
_ => Ok(()),
|
||||
}
|
||||
})?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Vec3>>>("path", Self::VT_PATH, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Vec3>>>("path", Self::VT_PATH, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
@@ -220,13 +212,13 @@ pub struct MonsterArgs<'a> {
|
||||
pub pos: Option<&'a Vec3>,
|
||||
pub mana: i16,
|
||||
pub hp: i16,
|
||||
pub name: Option<flatbuffers::WIPOffset<&'a str>>,
|
||||
pub inventory: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
|
||||
pub name: Option<::flatbuffers::WIPOffset<&'a str>>,
|
||||
pub inventory: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>,
|
||||
pub color: Color,
|
||||
pub weapons: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Weapon<'a>>>>>,
|
||||
pub weapons: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>>>,
|
||||
pub equipped_type: Equipment,
|
||||
pub equipped: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
|
||||
pub path: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Vec3>>>,
|
||||
pub equipped: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
|
||||
pub path: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Vec3>>>,
|
||||
}
|
||||
impl<'a> Default for MonsterArgs<'a> {
|
||||
#[inline]
|
||||
@@ -246,11 +238,11 @@ impl<'a> Default for MonsterArgs<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MonsterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_pos(&mut self, pos: &Vec3) {
|
||||
self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
|
||||
@@ -264,35 +256,35 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
||||
self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
|
||||
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_inventory(&mut self, inventory: flatbuffers::WIPOffset<flatbuffers::Vector<'b , u8>>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
|
||||
pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_color(&mut self, color: Color) {
|
||||
self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_weapons(&mut self, weapons: flatbuffers::WIPOffset<flatbuffers::Vector<'b , flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
|
||||
pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
|
||||
self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_equipped(&mut self, equipped: flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
|
||||
pub fn add_equipped(&mut self, equipped: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_path(&mut self, path: flatbuffers::WIPOffset<flatbuffers::Vector<'b , Vec3>>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
|
||||
pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Vec3>>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
MonsterBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -300,14 +292,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> flatbuffers::WIPOffset<Monster<'a>> {
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
flatbuffers::WIPOffset::new(o.value())
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for Monster<'_> {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Monster<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("Monster");
|
||||
ds.field("pos", &self.pos());
|
||||
ds.field("mana", &self.mana());
|
||||
@@ -340,12 +332,12 @@ pub struct MonsterT {
|
||||
pub pos: Option<Vec3T>,
|
||||
pub mana: i16,
|
||||
pub hp: i16,
|
||||
pub name: Option<String>,
|
||||
pub inventory: Option<Vec<u8>>,
|
||||
pub name: Option<alloc::string::String>,
|
||||
pub inventory: Option<alloc::vec::Vec<u8>>,
|
||||
pub color: Color,
|
||||
pub weapons: Option<Vec<WeaponT>>,
|
||||
pub weapons: Option<alloc::vec::Vec<WeaponT>>,
|
||||
pub equipped: EquipmentT,
|
||||
pub path: Option<Vec<Vec3T>>,
|
||||
pub path: Option<alloc::vec::Vec<Vec3T>>,
|
||||
}
|
||||
impl Default for MonsterT {
|
||||
fn default() -> Self {
|
||||
@@ -363,10 +355,10 @@ impl Default for MonsterT {
|
||||
}
|
||||
}
|
||||
impl MonsterT {
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> flatbuffers::WIPOffset<Monster<'b>> {
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<Monster<'b>> {
|
||||
let pos_tmp = self.pos.as_ref().map(|x| x.pack());
|
||||
let pos = pos_tmp.as_ref();
|
||||
let mana = self.mana;
|
||||
@@ -379,12 +371,12 @@ impl MonsterT {
|
||||
});
|
||||
let color = self.color;
|
||||
let weapons = self.weapons.as_ref().map(|x|{
|
||||
let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
|
||||
let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
|
||||
});
|
||||
let equipped_type = self.equipped.equipment_type();
|
||||
let equipped = self.equipped.pack(_fbb);
|
||||
let path = self.path.as_ref().map(|x|{
|
||||
let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
|
||||
let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
|
||||
});
|
||||
Monster::create(_fbb, &MonsterArgs{
|
||||
pos,
|
||||
@@ -407,8 +399,8 @@ impl MonsterT {
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_monster_unchecked`.
|
||||
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
|
||||
flatbuffers::root::<Monster>(buf)
|
||||
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::root::<Monster>(buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies that a buffer of bytes contains a size prefixed
|
||||
@@ -417,8 +409,8 @@ pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFl
|
||||
/// catch every error, or be maximally performant. For the
|
||||
/// previous, unchecked, behavior use
|
||||
/// `size_prefixed_root_as_monster_unchecked`.
|
||||
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuffers::InvalidFlatbuffer> {
|
||||
flatbuffers::size_prefixed_root::<Monster>(buf)
|
||||
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::size_prefixed_root::<Monster>(buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies, with the given options, that a buffer of bytes
|
||||
@@ -428,10 +420,10 @@ pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, flatbuff
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_monster_unchecked`.
|
||||
pub fn root_as_monster_with_opts<'b, 'o>(
|
||||
opts: &'o flatbuffers::VerifierOptions,
|
||||
opts: &'o ::flatbuffers::VerifierOptions,
|
||||
buf: &'b [u8],
|
||||
) -> Result<Monster<'b>, flatbuffers::InvalidFlatbuffer> {
|
||||
flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
|
||||
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Verifies, with the given verifier options, that a buffer of
|
||||
@@ -441,33 +433,33 @@ pub fn root_as_monster_with_opts<'b, 'o>(
|
||||
/// previous, unchecked, behavior use
|
||||
/// `root_as_monster_unchecked`.
|
||||
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
|
||||
opts: &'o flatbuffers::VerifierOptions,
|
||||
opts: &'o ::flatbuffers::VerifierOptions,
|
||||
buf: &'b [u8],
|
||||
) -> Result<Monster<'b>, flatbuffers::InvalidFlatbuffer> {
|
||||
flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
|
||||
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
|
||||
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
|
||||
}
|
||||
#[inline]
|
||||
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
|
||||
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
||||
unsafe { flatbuffers::root_unchecked::<Monster>(buf) }
|
||||
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
|
||||
}
|
||||
#[inline]
|
||||
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
|
||||
/// # Safety
|
||||
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
|
||||
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
|
||||
unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
|
||||
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(
|
||||
fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
root: flatbuffers::WIPOffset<Monster<'a>>) {
|
||||
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
|
||||
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
root: ::flatbuffers::WIPOffset<Monster<'a>>) {
|
||||
fbb.finish(root, None);
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset<Monster<'a>>) {
|
||||
pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Monster<'a>>) {
|
||||
fbb.finish_size_prefixed(root, None);
|
||||
}
|
||||
|
||||
@@ -1,13 +1,6 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
// struct Vec3, aligned to 4
|
||||
#[repr(transparent)]
|
||||
@@ -18,8 +11,8 @@ impl Default for Vec3 {
|
||||
Self([0; 12])
|
||||
}
|
||||
}
|
||||
impl core::fmt::Debug for Vec3 {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Vec3 {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
|
||||
f.debug_struct("Vec3")
|
||||
.field("x", &self.x())
|
||||
.field("y", &self.y())
|
||||
@@ -28,40 +21,39 @@ impl core::fmt::Debug for Vec3 {
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::SimpleToVerifyInSlice for Vec3 {}
|
||||
impl<'a> flatbuffers::Follow<'a> for Vec3 {
|
||||
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
|
||||
type Inner = &'a Vec3;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { <&'a Vec3>::follow(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'a> flatbuffers::Follow<'a> for &'a Vec3 {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
|
||||
type Inner = &'a Vec3;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
unsafe { flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
|
||||
unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
|
||||
}
|
||||
}
|
||||
impl<'b> flatbuffers::Push for Vec3 {
|
||||
impl<'b> ::flatbuffers::Push for Vec3 {
|
||||
type Output = Vec3;
|
||||
#[inline]
|
||||
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as flatbuffers::Push>::size()) };
|
||||
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
|
||||
dst.copy_from_slice(src);
|
||||
}
|
||||
#[inline]
|
||||
fn alignment() -> flatbuffers::PushAlignment {
|
||||
flatbuffers::PushAlignment::new(4)
|
||||
fn alignment() -> ::flatbuffers::PushAlignment {
|
||||
::flatbuffers::PushAlignment::new(4)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Verifiable for Vec3 {
|
||||
impl<'a> ::flatbuffers::Verifiable for Vec3 {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
@@ -85,88 +77,88 @@ impl<'a> Vec3 {
|
||||
}
|
||||
|
||||
pub fn x(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
EndianScalar::from_little_endian(unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[0..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_x(&mut self, x: f32) {
|
||||
let x_le = x.to_little_endian();
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[0..].as_mut_ptr(),
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn y(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
EndianScalar::from_little_endian(unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[4..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_y(&mut self, x: f32) {
|
||||
let x_le = x.to_little_endian();
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[4..].as_mut_ptr(),
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
pub fn z(&self) -> f32 {
|
||||
let mut mem = core::mem::MaybeUninit::<<f32 as EndianScalar>::Scalar>::uninit();
|
||||
let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
EndianScalar::from_little_endian(unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::flatbuffers::EndianScalar::from_little_endian(unsafe {
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
self.0[8..].as_ptr(),
|
||||
mem.as_mut_ptr() as *mut u8,
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
mem.assume_init()
|
||||
})
|
||||
}
|
||||
|
||||
pub fn set_z(&mut self, x: f32) {
|
||||
let x_le = x.to_little_endian();
|
||||
let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);
|
||||
// Safety:
|
||||
// Created from a valid Table for this object
|
||||
// Which contains a valid value in this slot
|
||||
unsafe {
|
||||
core::ptr::copy_nonoverlapping(
|
||||
::core::ptr::copy_nonoverlapping(
|
||||
&x_le as *const _ as *const u8,
|
||||
self.0[8..].as_mut_ptr(),
|
||||
core::mem::size_of::<<f32 as EndianScalar>::Scalar>(),
|
||||
::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +1,39 @@
|
||||
// automatically generated by the FlatBuffers compiler, do not modify
|
||||
// @generated
|
||||
extern crate alloc;
|
||||
extern crate flatbuffers;
|
||||
use alloc::boxed::Box;
|
||||
use alloc::string::{String, ToString};
|
||||
use alloc::vec::Vec;
|
||||
use core::mem;
|
||||
use core::cmp::Ordering;
|
||||
use self::flatbuffers::{EndianScalar, Follow};
|
||||
use super::*;
|
||||
pub enum WeaponOffset {}
|
||||
#[derive(Copy, Clone, PartialEq)]
|
||||
|
||||
pub struct Weapon<'a> {
|
||||
pub _tab: flatbuffers::Table<'a>,
|
||||
pub _tab: ::flatbuffers::Table<'a>,
|
||||
}
|
||||
|
||||
impl<'a> flatbuffers::Follow<'a> for Weapon<'a> {
|
||||
impl<'a> ::flatbuffers::Follow<'a> for Weapon<'a> {
|
||||
type Inner = Weapon<'a>;
|
||||
#[inline]
|
||||
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
|
||||
Self { _tab: unsafe { flatbuffers::Table::new(buf, loc) } }
|
||||
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Weapon<'a> {
|
||||
pub const VT_NAME: flatbuffers::VOffsetT = 4;
|
||||
pub const VT_DAMAGE: flatbuffers::VOffsetT = 6;
|
||||
pub const VT_NAME: ::flatbuffers::VOffsetT = 4;
|
||||
pub const VT_DAMAGE: ::flatbuffers::VOffsetT = 6;
|
||||
|
||||
pub const fn get_fully_qualified_name() -> &'static str {
|
||||
"MyGame.Sample.Weapon"
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self {
|
||||
pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
|
||||
Weapon { _tab: table }
|
||||
}
|
||||
#[allow(unused_mut)]
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: ::flatbuffers::Allocator + 'bldr>(
|
||||
_fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,
|
||||
args: &'args WeaponArgs<'args>
|
||||
) -> flatbuffers::WIPOffset<Weapon<'bldr>> {
|
||||
) -> ::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);
|
||||
@@ -49,7 +42,7 @@ impl<'a> Weapon<'a> {
|
||||
|
||||
pub fn unpack(&self) -> WeaponT {
|
||||
let name = self.name().map(|x| {
|
||||
x.to_string()
|
||||
alloc::string::ToString::to_string(x)
|
||||
});
|
||||
let damage = self.damage();
|
||||
WeaponT {
|
||||
@@ -63,7 +56,7 @@ impl<'a> Weapon<'a> {
|
||||
// Safety:
|
||||
// Created from valid Table for this object
|
||||
// which contains a valid value in this slot
|
||||
unsafe { self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
|
||||
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
|
||||
}
|
||||
#[inline]
|
||||
pub fn damage(&self) -> i16 {
|
||||
@@ -74,21 +67,20 @@ impl<'a> Weapon<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
impl flatbuffers::Verifiable for Weapon<'_> {
|
||||
impl ::flatbuffers::Verifiable for Weapon<'_> {
|
||||
#[inline]
|
||||
fn run_verifier(
|
||||
v: &mut flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), flatbuffers::InvalidFlatbuffer> {
|
||||
use self::flatbuffers::Verifiable;
|
||||
v: &mut ::flatbuffers::Verifier, pos: usize
|
||||
) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
|
||||
v.visit_table(pos)?
|
||||
.visit_field::<flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
|
||||
.visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
|
||||
.visit_field::<i16>("damage", Self::VT_DAMAGE, false)?
|
||||
.finish();
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
pub struct WeaponArgs<'a> {
|
||||
pub name: Option<flatbuffers::WIPOffset<&'a str>>,
|
||||
pub name: Option<::flatbuffers::WIPOffset<&'a str>>,
|
||||
pub damage: i16,
|
||||
}
|
||||
impl<'a> Default for WeaponArgs<'a> {
|
||||
@@ -101,21 +93,21 @@ impl<'a> Default for WeaponArgs<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub struct WeaponBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
pub struct WeaponBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
|
||||
fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
|
||||
start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
|
||||
}
|
||||
impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
||||
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
||||
#[inline]
|
||||
pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
|
||||
pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
|
||||
self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
|
||||
}
|
||||
#[inline]
|
||||
pub fn add_damage(&mut self, damage: i16) {
|
||||
self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
|
||||
}
|
||||
#[inline]
|
||||
pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
|
||||
pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
|
||||
let start = _fbb.start_table();
|
||||
WeaponBuilder {
|
||||
fbb_: _fbb,
|
||||
@@ -123,14 +115,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
|
||||
}
|
||||
}
|
||||
#[inline]
|
||||
pub fn finish(self) -> flatbuffers::WIPOffset<Weapon<'a>> {
|
||||
pub fn finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
|
||||
let o = self.fbb_.end_table(self.start_);
|
||||
flatbuffers::WIPOffset::new(o.value())
|
||||
::flatbuffers::WIPOffset::new(o.value())
|
||||
}
|
||||
}
|
||||
|
||||
impl core::fmt::Debug for Weapon<'_> {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
impl ::core::fmt::Debug for Weapon<'_> {
|
||||
fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
|
||||
let mut ds = f.debug_struct("Weapon");
|
||||
ds.field("name", &self.name());
|
||||
ds.field("damage", &self.damage());
|
||||
@@ -140,7 +132,7 @@ impl core::fmt::Debug for Weapon<'_> {
|
||||
#[non_exhaustive]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub struct WeaponT {
|
||||
pub name: Option<String>,
|
||||
pub name: Option<alloc::string::String>,
|
||||
pub damage: i16,
|
||||
}
|
||||
impl Default for WeaponT {
|
||||
@@ -152,10 +144,10 @@ impl Default for WeaponT {
|
||||
}
|
||||
}
|
||||
impl WeaponT {
|
||||
pub fn pack<'b, A: flatbuffers::Allocator + 'b>(
|
||||
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
|
||||
&self,
|
||||
_fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> flatbuffers::WIPOffset<Weapon<'b>> {
|
||||
_fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
|
||||
) -> ::flatbuffers::WIPOffset<Weapon<'b>> {
|
||||
let name = self.name.as_ref().map(|x|{
|
||||
_fbb.create_string(x)
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user