diff --git a/rust/flatbuffers/Cargo.toml b/rust/flatbuffers/Cargo.toml index 241ac2b99b8..ca4023ef214 100644 --- a/rust/flatbuffers/Cargo.toml +++ b/rust/flatbuffers/Cargo.toml @@ -9,7 +9,7 @@ homepage = "https://google.github.io/flatbuffers/" repository = "https://github.com/google/flatbuffers" keywords = ["flatbuffers", "serialization", "zero-copy"] categories = ["encoding", "data-structures", "memory-management"] -rust = "1.51" +rust-version = "1.51" [features] default = ["std"] diff --git a/rust/flatbuffers/build.rs b/rust/flatbuffers/build.rs index c13ed1da485..ed82da90992 100644 --- a/rust/flatbuffers/build.rs +++ b/rust/flatbuffers/build.rs @@ -1,4 +1,4 @@ -use rustc_version::{version_meta, Channel}; +use rustc_version::{Channel, version_meta}; fn main() { let version_meta = version_meta().unwrap(); @@ -6,6 +6,7 @@ fn main() { // To use nightly features we declare this and then we can use // #[cfg(nightly)] // for nightly only features + println!("cargo:rustc-check-cfg=cfg(nightly)"); if version_meta.channel == Channel::Nightly { println!("cargo:rustc-cfg=nightly") } diff --git a/rust/flexbuffers/src/builder/ser.rs b/rust/flexbuffers/src/builder/ser.rs index 4d8fe53e382..68ef018af7c 100644 --- a/rust/flexbuffers/src/builder/ser.rs +++ b/rust/flexbuffers/src/builder/ser.rs @@ -222,7 +222,7 @@ impl<'a> ser::Serializer for &'a mut FlexbufferSerializer { type Ok = (); type Error = Error; fn is_human_readable(&self) -> bool { - cfg!(serialize_human_readable) + cfg!(feature = "serialize_human_readable") } fn serialize_bool(self, v: bool) -> Result { self.builder.push(v); diff --git a/rust/flexbuffers/src/reader/de.rs b/rust/flexbuffers/src/reader/de.rs index ed2b8158e79..e6e31ed1d32 100644 --- a/rust/flexbuffers/src/reader/de.rs +++ b/rust/flexbuffers/src/reader/de.rs @@ -163,7 +163,7 @@ impl<'de> VariantAccess<'de> for Reader<&'de [u8]> { impl<'de> Deserializer<'de> for Reader<&'de [u8]> { type Error = DeserializationError; fn is_human_readable(&self) -> bool { - cfg!(deserialize_human_readable) + cfg!(feature = "deserialize_human_readable") } fn deserialize_any(self, visitor: V) -> Result diff --git a/rust/flexbuffers/src/reader/mod.rs b/rust/flexbuffers/src/reader/mod.rs index 8e9c247c255..d723a4a9066 100644 --- a/rust/flexbuffers/src/reader/mod.rs +++ b/rust/flexbuffers/src/reader/mod.rs @@ -26,7 +26,7 @@ mod serialize; mod vector; pub use de::DeserializationError; pub use iter::ReaderIterator; -pub use map::{MapReader, MapReaderIndexer}; +pub use map::MapReader; pub use vector::VectorReader; /// All the possible errors when reading a flexbuffer. diff --git a/samples/rust_generated/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs index 19e8445a58f..1f75ed74f89 100644 --- a/samples/rust_generated/my_game/sample/color_generated.rs +++ b/samples/rust_generated/my_game/sample/color_generated.rs @@ -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 = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(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) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(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 {} diff --git a/samples/rust_generated/my_game/sample/equipment_generated.rs b/samples/rust_generated/my_game/sample/equipment_generated.rs index 375db7f6d41..34d0014249b 100644 --- a/samples/rust_generated/my_game/sample/equipment_generated.rs +++ b/samples/rust_generated/my_game/sample/equipment_generated.rs @@ -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 = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(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) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(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), + Weapon(alloc::boxed::Box), } 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> { + 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> { + pub fn take_weapon(&mut self) -> Option> { 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 { diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs index 34405c474f4..82643de809c 100644 --- a/samples/rust_generated/my_game/sample/monster_generated.rs +++ b/samples/rust_generated/my_game/sample/monster_generated.rs @@ -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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::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> { + ) -> ::flatbuffers::WIPOffset> { 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::>(Monster::VT_NAME, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)} } #[inline] - pub fn inventory(&self) -> Option> { + 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::>>(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::(Monster::VT_COLOR, Some(Color::Blue)).unwrap()} } #[inline] - pub fn weapons(&self) -> Option>>> { + pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_WEAPONS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_WEAPONS, None)} } #[inline] pub fn equipped_type(&self) -> Equipment { @@ -161,18 +154,18 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()} } #[inline] - pub fn equipped(&self) -> Option> { + 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::>>(Monster::VT_EQUIPPED, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)} } #[inline] - pub fn path(&self) -> Option> { + 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::>>(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::("pos", Self::VT_POS, false)? .visit_field::("mana", Self::VT_MANA, false)? .visit_field::("hp", Self::VT_HP, false)? - .visit_field::>("name", Self::VT_NAME, false)? - .visit_field::>>("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", Self::VT_COLOR, false)? - .visit_field::>>>("weapons", Self::VT_WEAPONS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("weapons", Self::VT_WEAPONS, false)? .visit_union::("equipped_type", Self::VT_EQUIPPED_TYPE, "equipped", Self::VT_EQUIPPED, false, |key, v, pos| { match key { - Equipment::Weapon => v.verify_union_variant::>("Equipment::Weapon", pos), + Equipment::Weapon => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Equipment::Weapon", pos), _ => Ok(()), } })? - .visit_field::>>("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>, - pub inventory: Option>>, + pub name: Option<::flatbuffers::WIPOffset<&'a str>>, + pub inventory: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, pub color: Color, - pub weapons: Option>>>>, + pub weapons: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub equipped_type: Equipment, - pub equipped: Option>, - pub path: Option>>, + 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, +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::(Monster::VT_HP, hp, 100); } #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(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>) { - self.fbb_.push_slot_always::>(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::(Monster::VT_COLOR, color, Color::Blue); } #[inline] - pub fn add_weapons(&mut self, weapons: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_WEAPONS, weapons); + pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + 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::(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE); } #[inline] - pub fn add_equipped(&mut self, equipped: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(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>) { - self.fbb_.push_slot_always::>(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> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { 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, pub mana: i16, pub hp: i16, - pub name: Option, - pub inventory: Option>, + pub name: Option, + pub inventory: Option>, pub color: Color, - pub weapons: Option>, + pub weapons: Option>, pub equipped: EquipmentT, - pub path: Option>, + pub path: Option>, } 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { 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 { - flatbuffers::root::(buf) +pub fn root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -417,8 +409,8 @@ pub fn root_as_monster(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::size_prefixed_root::(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( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(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, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(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 { - flatbuffers::root_unchecked::(buf) + ::flatbuffers::root_unchecked::(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 { - flatbuffers::size_prefixed_root_unchecked::(buf) + ::flatbuffers::size_prefixed_root_unchecked::(buf) } #[inline] -pub fn finish_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>) { +pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>) { 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>) { +pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, None); } diff --git a/samples/rust_generated/my_game/sample/vec_3_generated.rs b/samples/rust_generated/my_game/sample/vec_3_generated.rs index bc5e52a6751..300755d7991 100644 --- a/samples/rust_generated/my_game/sample/vec_3_generated.rs +++ b/samples/rust_generated/my_game/sample/vec_3_generated.rs @@ -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,40 @@ 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 { <&'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 { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(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 = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -85,88 +78,88 @@ impl<'a> Vec3 { } pub fn x(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn y(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn z(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs index e61c2637d0b..0f74a7dc02a 100644 --- a/samples/rust_generated/my_game/sample/weapon_generated.rs +++ b/samples/rust_generated/my_game/sample/weapon_generated.rs @@ -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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::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> { + ) -> ::flatbuffers::WIPOffset> { 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::>(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::>("name", Self::VT_NAME, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)? .visit_field::("damage", Self::VT_DAMAGE, false)? .finish(); Ok(()) } } pub struct WeaponArgs<'a> { - pub name: Option>, + 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, +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::>(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::(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> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { 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, + pub name: Option, 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let name = self.name.as_ref().map(|x|{ _fbb.create_string(x) }); diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp index b8811c6f3ff..f5b89338525 100644 --- a/src/idl_gen_rust.cpp +++ b/src/idl_gen_rust.cpp @@ -374,18 +374,11 @@ class RustGenerator : public BaseGenerator { code_ += "// " + std::string(FlatBuffersGeneratedWarning()); code_ += "// @generated"; code_ += "extern crate alloc;"; - code_ += "extern crate flatbuffers;"; - code_ += "use alloc::boxed::Box;"; - code_ += "use alloc::string::{String, ToString};"; - code_ += "use alloc::vec::Vec;"; - code_ += "use core::mem;"; - code_ += "use core::cmp::Ordering;"; if (parser_.opts.rust_serialize) { code_ += "extern crate serde;"; code_ += "use self::serde::ser::{Serialize, Serializer, SerializeStruct};"; } - code_ += "use self::flatbuffers::{EndianScalar, Follow};"; code_ += "use super::*;"; cur_name_space_ = symbol.defined_namespace; gen_symbol(symbol); @@ -428,8 +421,9 @@ class RustGenerator : public BaseGenerator { // structs, and tables) and output them to a single file. bool GenerateOneFile() { code_.Clear(); - code_ += "// " + std::string(FlatBuffersGeneratedWarning()) + "\n\n"; + code_ += "// " + std::string(FlatBuffersGeneratedWarning()); code_ += "// @generated"; + code_ += "extern crate alloc;"; assert(!cur_name_space_); @@ -725,7 +719,7 @@ class RustGenerator : public BaseGenerator { // constants but in camel case. code_ += "#[allow(non_upper_case_globals)]"; code_ += "mod bitflags_{{ENUM_NAMESPACE}} {"; - code_ += " flatbuffers::bitflags::bitflags! {"; + code_ += " ::flatbuffers::bitflags::bitflags! {"; GenComment(enum_def.doc_comment, " "); code_ += " #[derive(Default, Debug, Clone, Copy, PartialEq)]"; code_ += " {{ACCESS_TYPE}} struct {{ENUM_TY}}: {{BASE_TYPE}} {"; @@ -799,10 +793,10 @@ class RustGenerator : public BaseGenerator { code_ += "}"; // Generate Debug. Unknown variants are printed like "". - code_ += "impl core::fmt::Debug for {{ENUM_TY}} {"; + code_ += "impl ::core::fmt::Debug for {{ENUM_TY}} {"; code_ += - " fn fmt(&self, f: &mut core::fmt::Formatter) ->" - " core::fmt::Result {"; + " fn fmt(&self, f: &mut ::core::fmt::Formatter) ->" + " ::core::fmt::Result {"; code_ += " if let Some(name) = self.variant_name() {"; code_ += " f.write_str(name)"; code_ += " } else {"; @@ -836,12 +830,12 @@ class RustGenerator : public BaseGenerator { } // Generate Follow and Push so we can serialize and stuff. - code_ += "impl<'a> flatbuffers::Follow<'a> for {{ENUM_TY}} {"; + code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{ENUM_TY}} {"; code_ += " type Inner = Self;"; code_ += " #[inline]"; code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {"; code_ += - " let b = flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc);"; + " let b = ::flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc);"; if (IsBitFlagsEnum(enum_def)) { code_ += " Self::from_bits_retain(b)"; } else { @@ -850,17 +844,17 @@ class RustGenerator : public BaseGenerator { code_ += " }"; code_ += "}"; code_ += ""; - code_ += "impl flatbuffers::Push for {{ENUM_TY}} {"; + code_ += "impl ::flatbuffers::Push for {{ENUM_TY}} {"; code_ += " type Output = {{ENUM_TY}};"; code_ += " #[inline]"; code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {"; code_ += - " flatbuffers::emplace_scalar::<{{BASE_TYPE}}>(dst, " + " ::flatbuffers::emplace_scalar::<{{BASE_TYPE}}>(dst, " "{{INTO_BASE}});"; code_ += " }"; code_ += "}"; code_ += ""; - code_ += "impl flatbuffers::EndianScalar for {{ENUM_TY}} {"; + code_ += "impl ::flatbuffers::EndianScalar for {{ENUM_TY}} {"; code_ += " type Scalar = {{BASE_TYPE}};"; code_ += " #[inline]"; code_ += " fn to_little_endian(self) -> {{BASE_TYPE}} {"; @@ -880,18 +874,17 @@ class RustGenerator : public BaseGenerator { code_ += ""; // Generate verifier - deferring to the base type. - code_ += "impl<'a> flatbuffers::Verifiable for {{ENUM_TY}} {"; + code_ += "impl<'a> ::flatbuffers::Verifiable for {{ENUM_TY}} {"; code_ += " #[inline]"; code_ += " fn run_verifier("; - code_ += " v: &mut flatbuffers::Verifier, pos: usize"; - code_ += " ) -> Result<(), flatbuffers::InvalidFlatbuffer> {"; - code_ += " use self::flatbuffers::Verifiable;"; + code_ += " v: &mut ::flatbuffers::Verifier, pos: usize"; + code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {"; code_ += " {{BASE_TYPE}}::run_verifier(v, pos)"; code_ += " }"; code_ += "}"; code_ += ""; // Enums are basically integers. - code_ += "impl flatbuffers::SimpleToVerifyInSlice for {{ENUM_TY}} {}"; + code_ += "impl ::flatbuffers::SimpleToVerifyInSlice for {{ENUM_TY}} {}"; if (enum_def.is_union) { // Generate typesafe offset(s) for unions @@ -934,7 +927,8 @@ class RustGenerator : public BaseGenerator { code_ += "{{ACCESS_TYPE}} enum {{ENUM_OTY}} {"; code_ += " NONE,"; ForAllUnionObjectVariantsBesidesNone(enum_def, [&] { - code_ += "{{NATIVE_VARIANT}}(Box<{{U_ELEMENT_TABLE_TYPE}}>),"; + code_ += + "{{NATIVE_VARIANT}}(alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>),"; }); code_ += "}"; // Generate Default (NONE). @@ -961,9 +955,9 @@ class RustGenerator : public BaseGenerator { code_ += " }"; // Pack flatbuffers union value code_ += - " pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut " - "flatbuffers::FlatBufferBuilder<'b, A>)" - " -> Option>" + " pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut " + "::flatbuffers::FlatBufferBuilder<'b, A>)" + " -> Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>" " {"; code_ += " match self {"; code_ += " Self::NONE => None,"; @@ -982,9 +976,9 @@ class RustGenerator : public BaseGenerator { "{{U_ELEMENT_TABLE_TYPE}}, setting the union to NONE."; code_ += "pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> " - "Option> {"; + "Option> {"; code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {"; - code_ += " let v = core::mem::replace(self, Self::NONE);"; + code_ += " let v = ::core::mem::replace(self, Self::NONE);"; code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {"; code_ += " Some(w)"; code_ += " } else {"; @@ -1073,7 +1067,9 @@ class RustGenerator : public BaseGenerator { // TODO: Escape strings? const std::string defval = field.IsRequired() ? "\"\"" : "\"" + field.value.constant + "\""; - if (context == kObject) return defval + ".to_string()"; + if (context == kObject) { + return "alloc::string::ToString::to_string(" + defval + ")"; + } if (context == kAccessor) return "&" + defval; FLATBUFFERS_ASSERT(false); return "INVALID_CODE_GENERATION"; @@ -1123,11 +1119,11 @@ class RustGenerator : public BaseGenerator { return IsOptionalToBuilder(field) ? "Option<" + s + ">" : s; }; auto WrapVector = [&](std::string ty) { - return WrapOption("flatbuffers::WIPOffset>"); }; auto WrapUOffsetsVector = [&](std::string ty) { - return WrapVector("flatbuffers::ForwardsUOffset<" + ty + ">"); + return WrapVector("::flatbuffers::ForwardsUOffset<" + ty + ">"); }; switch (GetFullType(type)) { @@ -1142,18 +1138,19 @@ class RustGenerator : public BaseGenerator { } case ftTable: { const auto typname = WrapInNameSpace(*type.struct_def); - return WrapOption("flatbuffers::WIPOffset<" + typname + "<" + lifetime + - ">>"); + return WrapOption("::flatbuffers::WIPOffset<" + typname + "<" + + lifetime + ">>"); } case ftString: { - return WrapOption("flatbuffers::WIPOffset<&" + lifetime + " str>"); + return WrapOption("::flatbuffers::WIPOffset<&" + lifetime + " str>"); } case ftEnumKey: case ftUnionKey: { return WrapOption(WrapInNameSpace(*type.enum_def)); } case ftUnionValue: { - return "Option>"; + return "Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>" + ">"; } case ftVectorOfInteger: @@ -1178,7 +1175,7 @@ class RustGenerator : public BaseGenerator { return WrapUOffsetsVector("&" + lifetime + " str"); } case ftVectorOfUnionValue: { - return WrapUOffsetsVector("flatbuffers::Table<" + lifetime + ">"); + return WrapUOffsetsVector("::flatbuffers::Table<" + lifetime + ">"); } case ftArrayOfEnum: case ftArrayOfStruct: @@ -1201,7 +1198,7 @@ class RustGenerator : public BaseGenerator { break; } case ftString: { - ty = "String"; + ty = "alloc::string::String"; break; } case ftStruct: { @@ -1211,7 +1208,8 @@ class RustGenerator : public BaseGenerator { case ftTable: { // Since Tables can contain themselves, Box is required to avoid // infinite types. - ty = "Box<" + NamespacedNativeName(*type.struct_def) + ">"; + ty = + "alloc::boxed::Box<" + NamespacedNativeName(*type.struct_def) + ">"; break; } case ftUnionKey: { @@ -1229,23 +1227,24 @@ class RustGenerator : public BaseGenerator { } // Vectors are in tables and are optional case ftVectorOfEnumKey: { - ty = "Vec<" + WrapInNameSpace(*type.VectorType().enum_def) + ">"; + ty = "alloc::vec::Vec<" + WrapInNameSpace(*type.VectorType().enum_def) + + ">"; break; } case ftVectorOfInteger: case ftVectorOfBool: case ftVectorOfFloat: { - ty = "Vec<" + GetTypeBasic(type.VectorType()) + ">"; + ty = "alloc::vec::Vec<" + GetTypeBasic(type.VectorType()) + ">"; break; } case ftVectorOfString: { - ty = "Vec"; + ty = "alloc::vec::Vec"; break; } case ftVectorOfTable: case ftVectorOfStruct: { ty = NamespacedNativeName(*type.VectorType().struct_def); - ty = "Vec<" + ty + ">"; + ty = "alloc::vec::Vec<" + ty + ">"; break; } case ftVectorOfUnionValue: { @@ -1282,35 +1281,35 @@ class RustGenerator : public BaseGenerator { switch (GetFullType(field.value.type)) { case ftVectorOfStruct: { const auto typname = WrapInNameSpace(*type.struct_def); - return "flatbuffers::WIPOffset>"; + return "::flatbuffers::WIPOffset<::flatbuffers::Vector<" + lifetime + + ", " + typname + ">>"; } case ftVectorOfTable: { const auto typname = WrapInNameSpace(*type.struct_def); - return "flatbuffers::WIPOffset>>>"; } case ftVectorOfInteger: case ftVectorOfBool: case ftVectorOfFloat: { const auto typname = GetTypeBasic(type.VectorType()); - return "flatbuffers::WIPOffset>"; + return "::flatbuffers::WIPOffset<::flatbuffers::Vector<" + lifetime + + ", " + typname + ">>"; } case ftVectorOfString: { - return "flatbuffers::WIPOffset>>"; + return "::flatbuffers::WIPOffset<::flatbuffers::Vector<" + lifetime + + ", ::flatbuffers::ForwardsUOffset<&" + lifetime + " str>>>"; } case ftVectorOfEnumKey: { const auto typname = WrapInNameSpace(*type.enum_def); - return "flatbuffers::WIPOffset>"; + return "::flatbuffers::WIPOffset<::flatbuffers::Vector<" + lifetime + + ", " + typname + ">>"; } case ftVectorOfUnionValue: { - return "flatbuffers::WIPOffset>>"; + return "::flatbuffers::WIPOffset<::flatbuffers::Vector<" + lifetime + + ", ::flatbuffers::ForwardsUOffset<::flatbuffers::Table<" + + lifetime + ">>>"; } case ftEnumKey: case ftUnionKey: { @@ -1323,7 +1322,7 @@ class RustGenerator : public BaseGenerator { } case ftTable: { const auto typname = WrapInNameSpace(*type.struct_def); - return "flatbuffers::WIPOffset<" + typname + "<" + lifetime + ">>"; + return "::flatbuffers::WIPOffset<" + typname + "<" + lifetime + ">>"; } case ftInteger: case ftBool: @@ -1331,24 +1330,24 @@ class RustGenerator : public BaseGenerator { return GetTypeBasic(type); } case ftString: { - return "flatbuffers::WIPOffset<&" + lifetime + " str>"; + return "::flatbuffers::WIPOffset<&" + lifetime + " str>"; } case ftUnionValue: { - return "flatbuffers::WIPOffset"; + return "::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>"; } case ftArrayOfBuiltin: { const auto typname = GetTypeBasic(type.VectorType()); - return "flatbuffers::Array<" + lifetime + ", " + typname + ", " + + return "::flatbuffers::Array<" + lifetime + ", " + typname + ", " + NumToString(type.fixed_length) + ">"; } case ftArrayOfEnum: { const auto typname = WrapInNameSpace(*type.enum_def); - return "flatbuffers::Array<" + lifetime + ", " + typname + ", " + + return "::flatbuffers::Array<" + lifetime + ", " + typname + ", " + NumToString(type.fixed_length) + ">"; } case ftArrayOfStruct: { const auto typname = WrapInNameSpace(*type.struct_def); - return "flatbuffers::Array<" + lifetime + ", " + typname + ", " + + return "::flatbuffers::Array<" + lifetime + ", " + typname + ", " + NumToString(type.fixed_length) + ">"; } } @@ -1382,7 +1381,7 @@ class RustGenerator : public BaseGenerator { } case ftTable: { const auto typname = WrapInNameSpace(*type.struct_def); - return "self.fbb_.push_slot_always::>"; } @@ -1396,7 +1395,7 @@ class RustGenerator : public BaseGenerator { case ftVectorOfTable: case ftVectorOfString: case ftVectorOfUnionValue: { - return "self.fbb_.push_slot_always::>"; + return "self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>"; } case ftArrayOfEnum: case ftArrayOfStruct: @@ -1435,7 +1434,7 @@ class RustGenerator : public BaseGenerator { } case ftUnionValue: { - return WrapOption("flatbuffers::Table<" + lifetime + ">"); + return WrapOption("::flatbuffers::Table<" + lifetime + ">"); } case ftString: { return WrapOption("&" + lifetime + " str"); @@ -1444,28 +1443,28 @@ class RustGenerator : public BaseGenerator { case ftVectorOfBool: case ftVectorOfFloat: { const auto typname = GetTypeBasic(type.VectorType()); - return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname + + return WrapOption("::flatbuffers::Vector<" + lifetime + ", " + typname + ">"); } case ftVectorOfEnumKey: { const auto typname = WrapInNameSpace(*type.enum_def); - return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname + + return WrapOption("::flatbuffers::Vector<" + lifetime + ", " + typname + ">"); } case ftVectorOfStruct: { const auto typname = WrapInNameSpace(*type.struct_def); - return WrapOption("flatbuffers::Vector<" + lifetime + ", " + typname + + return WrapOption("::flatbuffers::Vector<" + lifetime + ", " + typname + ">"); } case ftVectorOfTable: { const auto typname = WrapInNameSpace(*type.struct_def); - return WrapOption("flatbuffers::Vector<" + lifetime + - ", flatbuffers::ForwardsUOffset<" + typname + "<" + + return WrapOption("::flatbuffers::Vector<" + lifetime + + ", ::flatbuffers::ForwardsUOffset<" + typname + "<" + lifetime + ">>>"); } case ftVectorOfString: { - return WrapOption("flatbuffers::Vector<" + lifetime + - ", flatbuffers::ForwardsUOffset<&" + lifetime + + return WrapOption("::flatbuffers::Vector<" + lifetime + + ", ::flatbuffers::ForwardsUOffset<&" + lifetime + " str>>"); } case ftVectorOfUnionValue: { @@ -1488,13 +1487,13 @@ class RustGenerator : public BaseGenerator { // IsVector... This can be made iterative? const auto WrapForwardsUOffset = [](std::string ty) -> std::string { - return "flatbuffers::ForwardsUOffset<" + ty + ">"; + return "::flatbuffers::ForwardsUOffset<" + ty + ">"; }; const auto WrapVector = [&](std::string ty) -> std::string { - return "flatbuffers::Vector<" + lifetime + ", " + ty + ">"; + return "::flatbuffers::Vector<" + lifetime + ", " + ty + ">"; }; const auto WrapArray = [&](std::string ty, uint16_t length) -> std::string { - return "flatbuffers::Array<" + lifetime + ", " + ty + ", " + + return "::flatbuffers::Array<" + lifetime + ", " + ty + ", " + NumToString(length) + ">"; }; switch (GetFullType(type)) { @@ -1515,7 +1514,7 @@ class RustGenerator : public BaseGenerator { return WrapForwardsUOffset(typname); } case ftUnionValue: { - return WrapForwardsUOffset("flatbuffers::Table<" + lifetime + ">"); + return WrapForwardsUOffset("::flatbuffers::Table<" + lifetime + ">"); } case ftString: { return WrapForwardsUOffset("&str"); @@ -1651,14 +1650,14 @@ class RustGenerator : public BaseGenerator { GenComment(struct_def.doc_comment); code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}<'a> {"; - code_ += " pub _tab: flatbuffers::Table<'a>,"; + code_ += " pub _tab: ::flatbuffers::Table<'a>,"; code_ += "}"; code_ += ""; - code_ += "impl<'a> flatbuffers::Follow<'a> for {{STRUCT_TY}}<'a> {"; + code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}}<'a> {"; code_ += " type Inner = {{STRUCT_TY}}<'a>;"; code_ += " #[inline]"; code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {"; - code_ += " Self { _tab: flatbuffers::Table::new(buf, loc) }"; + code_ += " Self { _tab: ::flatbuffers::Table::new(buf, loc) }"; code_ += " }"; code_ += "}"; code_ += ""; @@ -1668,7 +1667,7 @@ class RustGenerator : public BaseGenerator { ForAllTableFields(struct_def, [&](const FieldDef &unused) { (void)unused; code_ += - "pub const {{OFFSET_NAME}}: flatbuffers::VOffsetT = " + "pub const {{OFFSET_NAME}}: ::flatbuffers::VOffsetT = " "{{OFFSET_VALUE}};"; }); code_ += ""; @@ -1679,7 +1678,7 @@ class RustGenerator : public BaseGenerator { code_ += " #[inline]"; code_ += - " pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> " + " pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> " "Self {"; code_ += " {{STRUCT_TY}} { _tab: table }"; code_ += " }"; @@ -1692,11 +1691,11 @@ class RustGenerator : public BaseGenerator { code_ += " #[allow(unused_mut)]"; code_ += " pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: " - "flatbuffers::Allocator + 'bldr>("; + "::flatbuffers::Allocator + 'bldr>("; code_ += - " _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr, A>,"; + " _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,"; code_ += " {{MAYBE_US}}args: &'args {{STRUCT_TY}}Args{{MAYBE_LT}}"; - code_ += " ) -> flatbuffers::WIPOffset<{{STRUCT_TY}}<'bldr>> {"; + code_ += " ) -> ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'bldr>> {"; code_ += " let mut builder = {{STRUCT_TY}}Builder::new(_fbb);"; for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1; @@ -1749,7 +1748,8 @@ class RustGenerator : public BaseGenerator { ForAllUnionObjectVariantsBesidesNone(enum_def, [&] { code_ += " {{ENUM_TY}}::{{VARIANT_NAME}} => " - "{{NATIVE_ENUM_NAME}}::{{NATIVE_VARIANT}}(Box::new("; + "{{NATIVE_ENUM_NAME}}::{{NATIVE_VARIANT}}(alloc::boxed::Box::" + "new("; code_ += " self.{{FIELD}}_as_{{U_ELEMENT_NAME}}()"; code_ += " .expect(\"Invalid union table, " @@ -1765,7 +1765,7 @@ class RustGenerator : public BaseGenerator { // The rest of the types need special handling based on if the field // is optional or not. case ftString: { - code_.SetValue("EXPR", "x.to_string()"); + code_.SetValue("EXPR", "alloc::string::ToString::to_string(x)"); break; } case ftStruct: { @@ -1773,7 +1773,7 @@ class RustGenerator : public BaseGenerator { break; } case ftTable: { - code_.SetValue("EXPR", "Box::new(x.unpack())"); + code_.SetValue("EXPR", "alloc::boxed::Box::new(x.unpack())"); break; } case ftVectorOfInteger: @@ -1784,7 +1784,9 @@ class RustGenerator : public BaseGenerator { break; } case ftVectorOfString: { - code_.SetValue("EXPR", "x.iter().map(|s| s.to_string()).collect()"); + code_.SetValue("EXPR", + "x.iter().map(|s| " + "alloc::string::ToString::to_string(s)).collect()"); break; } case ftVectorOfStruct: @@ -1870,22 +1872,22 @@ class RustGenerator : public BaseGenerator { if (field.IsRequired()) { code_ += "{{NESTED}}<'a> {"; code_ += " let data = self.{{FIELD}}();"; - code_ += " use flatbuffers::Follow;"; + code_ += " use ::flatbuffers::Follow;"; code_ += " // Safety:"; code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid flatbuffer in this slot"; code_ += - " unsafe { >>" + " unsafe { <::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>" "::follow(data.bytes(), 0) }"; } else { code_ += "Option<{{NESTED}}<'a>> {"; code_ += " self.{{FIELD}}().map(|data| {"; - code_ += " use flatbuffers::Follow;"; + code_ += " use ::flatbuffers::Follow;"; code_ += " // Safety:"; code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid flatbuffer in this slot"; code_ += - " unsafe { >>" + " unsafe { <::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>" "::follow(data.bytes(), 0) }"; code_ += " })"; } @@ -1949,12 +1951,11 @@ class RustGenerator : public BaseGenerator { code_ += ""; // Generate Verifier; - code_ += "impl flatbuffers::Verifiable for {{STRUCT_TY}}<'_> {"; + code_ += "impl ::flatbuffers::Verifiable for {{STRUCT_TY}}<'_> {"; code_ += " #[inline]"; code_ += " fn run_verifier("; - code_ += " v: &mut flatbuffers::Verifier, pos: usize"; - code_ += " ) -> Result<(), flatbuffers::InvalidFlatbuffer> {"; - code_ += " use self::flatbuffers::Verifiable;"; + code_ += " v: &mut ::flatbuffers::Verifier, pos: usize"; + code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {"; code_ += " v.visit_table(pos)?\\"; // Escape newline and insert it onthe next line so we can end the builder // with a nice semicolon. @@ -1987,7 +1988,7 @@ class RustGenerator : public BaseGenerator { (void)unused; code_ += " {{U_ELEMENT_ENUM_TYPE}} => v.verify_union_variant::" - ">(" + "<::flatbuffers::ForwardsUOffset<{{U_ELEMENT_TABLE_TYPE}}>>(" "\"{{U_ELEMENT_ENUM_TYPE}}\", pos),"; }); code_ += " _ => Ok(()),"; @@ -2095,16 +2096,16 @@ class RustGenerator : public BaseGenerator { // Generate a builder struct: code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}Builder<'a: 'b, 'b, A: " - "flatbuffers::Allocator + 'a> {"; - code_ += " fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,"; + "::flatbuffers::Allocator + 'a> {"; + code_ += " fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,"; code_ += - " start_: flatbuffers::WIPOffset<" - "flatbuffers::TableUnfinishedWIPOffset>,"; + " start_: ::flatbuffers::WIPOffset<" + "::flatbuffers::TableUnfinishedWIPOffset>,"; code_ += "}"; // Generate builder functions: code_ += - "impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> " + "impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> " "{{STRUCT_TY}}Builder<'a, " "'b, A> {"; ForAllTableFields(struct_def, [&](const FieldDef &field) { @@ -2141,7 +2142,8 @@ class RustGenerator : public BaseGenerator { // Struct initializer (all fields required); code_ += " #[inline]"; code_ += - " pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> " + " pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) " + "-> " "{{STRUCT_TY}}Builder<'a, 'b, A> {"; code_.SetValue("NUM_FIELDS", NumToString(struct_def.fields.vec.size())); code_ += " let start = _fbb.start_table();"; @@ -2155,7 +2157,7 @@ class RustGenerator : public BaseGenerator { code_ += " #[inline]"; code_ += " pub fn finish(self) -> " - "flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>> {"; + "::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>> {"; code_ += " let o = self.fbb_.end_table(self.start_);"; ForAllTableFields(struct_def, [&](const FieldDef &field) { @@ -2164,15 +2166,15 @@ class RustGenerator : public BaseGenerator { " self.fbb_.required(o, {{STRUCT_TY}}::{{OFFSET_NAME}}," "\"{{FIELD}}\");"; }); - code_ += " flatbuffers::WIPOffset::new(o.value())"; + code_ += " ::flatbuffers::WIPOffset::new(o.value())"; code_ += " }"; code_ += "}"; code_ += ""; - code_ += "impl core::fmt::Debug for {{STRUCT_TY}}<'_> {"; + code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}}<'_> {"; code_ += - " fn fmt(&self, f: &mut core::fmt::Formatter<'_>" - ") -> core::fmt::Result {"; + " fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>" + ") -> ::core::fmt::Result {"; code_ += " let mut ds = f.debug_struct(\"{{STRUCT_TY}}\");"; ForAllTableFields(struct_def, [&](const FieldDef &field) { if (GetFullType(field.value.type) == ftUnionValue) { @@ -2245,10 +2247,10 @@ class RustGenerator : public BaseGenerator { // Generate pack function. code_ += "impl {{STRUCT_OTY}} {"; - code_ += " pub fn pack<'b, A: flatbuffers::Allocator + 'b>("; + code_ += " pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>("; code_ += " &self,"; - code_ += " _fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>"; - code_ += " ) -> flatbuffers::WIPOffset<{{STRUCT_TY}}<'b>> {"; + code_ += " _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>"; + code_ += " ) -> ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'b>> {"; // First we generate variables for each field and then later assemble them // using "StructArgs" to more easily manage ownership of the builder. ForAllObjectTableFields(table, [&](const FieldDef &field) { @@ -2304,10 +2306,10 @@ class RustGenerator : public BaseGenerator { return; } case ftVectorOfStruct: { - MapNativeTableField( - field, - "let w: Vec<_> = x.iter().map(|t| t.pack()).collect();" - "_fbb.create_vector(&w)"); + MapNativeTableField(field, + "let w: alloc::vec::Vec<_> = x.iter().map(|t| " + "t.pack()).collect();" + "_fbb.create_vector(&w)"); return; } case ftVectorOfString: { @@ -2315,16 +2317,16 @@ class RustGenerator : public BaseGenerator { // allocations. MapNativeTableField(field, - "let w: Vec<_> = x.iter().map(|s| " + "let w: alloc::vec::Vec<_> = x.iter().map(|s| " "_fbb.create_string(s)).collect();" "_fbb.create_vector(&w)"); return; } case ftVectorOfTable: { - MapNativeTableField( - field, - "let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();" - "_fbb.create_vector(&w)"); + MapNativeTableField(field, + "let w: alloc::vec::Vec<_> = x.iter().map(|t| " + "t.pack(_fbb)).collect();" + "_fbb.create_vector(&w)"); return; } case ftVectorOfUnionValue: { @@ -2418,8 +2420,8 @@ class RustGenerator : public BaseGenerator { code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`."; code_ += "pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) " - "-> Result<{{STRUCT_TY}}, flatbuffers::InvalidFlatbuffer> {"; - code_ += " flatbuffers::root::<{{STRUCT_TY}}>(buf)"; + "-> Result<{{STRUCT_TY}}, ::flatbuffers::InvalidFlatbuffer> {"; + code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)"; code_ += "}"; code_ += "#[inline]"; code_ += "/// Verifies that a buffer of bytes contains a size prefixed"; @@ -2431,8 +2433,8 @@ class RustGenerator : public BaseGenerator { code_ += "pub fn size_prefixed_root_as_{{STRUCT_FN}}" "(buf: &[u8]) -> Result<{{STRUCT_TY}}, " - "flatbuffers::InvalidFlatbuffer> {"; - code_ += " flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)"; + "::flatbuffers::InvalidFlatbuffer> {"; + code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)"; code_ += "}"; // Verifier with options root fns. code_ += "#[inline]"; @@ -2443,12 +2445,12 @@ class RustGenerator : public BaseGenerator { code_ += "/// previous, unchecked, behavior use"; code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`."; code_ += "pub fn root_as_{{STRUCT_FN}}_with_opts<'b, 'o>("; - code_ += " opts: &'o flatbuffers::VerifierOptions,"; + code_ += " opts: &'o ::flatbuffers::VerifierOptions,"; code_ += " buf: &'b [u8],"; code_ += - ") -> Result<{{STRUCT_TY}}<'b>, flatbuffers::InvalidFlatbuffer>" + ") -> Result<{{STRUCT_TY}}<'b>, ::flatbuffers::InvalidFlatbuffer>" " {"; - code_ += " flatbuffers::root_with_opts::<{{STRUCT_TY}}<'b>>(opts, buf)"; + code_ += " ::flatbuffers::root_with_opts::<{{STRUCT_TY}}<'b>>(opts, buf)"; code_ += "}"; code_ += "#[inline]"; code_ += "/// Verifies, with the given verifier options, that a buffer of"; @@ -2460,13 +2462,13 @@ class RustGenerator : public BaseGenerator { code_ += "pub fn size_prefixed_root_as_{{STRUCT_FN}}_with_opts" "<'b, 'o>("; - code_ += " opts: &'o flatbuffers::VerifierOptions,"; + code_ += " opts: &'o ::flatbuffers::VerifierOptions,"; code_ += " buf: &'b [u8],"; code_ += - ") -> Result<{{STRUCT_TY}}<'b>, flatbuffers::InvalidFlatbuffer>" + ") -> Result<{{STRUCT_TY}}<'b>, ::flatbuffers::InvalidFlatbuffer>" " {"; code_ += - " flatbuffers::size_prefixed_root_with_opts::<{{STRUCT_TY}}" + " ::flatbuffers::size_prefixed_root_with_opts::<{{STRUCT_TY}}" "<'b>>(opts, buf)"; code_ += "}"; // Unchecked root fns. @@ -2481,7 +2483,7 @@ class RustGenerator : public BaseGenerator { code_ += "pub unsafe fn root_as_{{STRUCT_FN}}_unchecked" "(buf: &[u8]) -> {{STRUCT_TY}} {"; - code_ += " flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf)"; + code_ += " ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf)"; code_ += "}"; code_ += "#[inline]"; code_ += @@ -2495,7 +2497,7 @@ class RustGenerator : public BaseGenerator { "pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}" "_unchecked(buf: &[u8]) -> {{STRUCT_TY}} {"; code_ += - " flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>" + " ::flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>" "(buf)"; code_ += "}"; @@ -2510,14 +2512,14 @@ class RustGenerator : public BaseGenerator { code_ += "#[inline]"; code_ += "pub fn {{STRUCT_FN}}_buffer_has_identifier\\"; code_ += "(buf: &[u8]) -> bool {"; - code_ += " flatbuffers::buffer_has_identifier(buf, \\"; + code_ += " ::flatbuffers::buffer_has_identifier(buf, \\"; code_ += "{{STRUCT_CONST}}_IDENTIFIER, false)"; code_ += "}"; code_ += ""; code_ += "#[inline]"; code_ += "pub fn {{STRUCT_FN}}_size_prefixed\\"; code_ += "_buffer_has_identifier(buf: &[u8]) -> bool {"; - code_ += " flatbuffers::buffer_has_identifier(buf, \\"; + code_ += " ::flatbuffers::buffer_has_identifier(buf, \\"; code_ += "{{STRUCT_CONST}}_IDENTIFIER, true)"; code_ += "}"; code_ += ""; @@ -2534,9 +2536,9 @@ class RustGenerator : public BaseGenerator { code_ += "#[inline]"; code_ += "pub fn finish_{{STRUCT_FN}}_buffer<'a, 'b, A: " - "flatbuffers::Allocator + 'a>("; - code_ += " fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>,"; - code_ += " root: flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {"; + "::flatbuffers::Allocator + 'a>("; + code_ += " fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,"; + code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {"; if (parser_.file_identifier_.length()) { code_ += " fbb.finish(root, Some({{STRUCT_CONST}}_IDENTIFIER));"; } else { @@ -2547,9 +2549,9 @@ class RustGenerator : public BaseGenerator { code_ += "#[inline]"; code_ += "pub fn finish_size_prefixed_{{STRUCT_FN}}_buffer" - "<'a, 'b, A: flatbuffers::Allocator + 'a>(" - "fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, " - "root: flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {"; + "<'a, 'b, A: ::flatbuffers::Allocator + 'a>(" + "fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, " + "root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>) {"; if (parser_.file_identifier_.length()) { code_ += " fbb.finish_size_prefixed(root, " @@ -2634,10 +2636,10 @@ class RustGenerator : public BaseGenerator { code_ += "}"; // Debug for structs. - code_ += "impl core::fmt::Debug for {{STRUCT_TY}} {"; + code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}} {"; code_ += - " fn fmt(&self, f: &mut core::fmt::Formatter" - ") -> core::fmt::Result {"; + " fn fmt(&self, f: &mut ::core::fmt::Formatter" + ") -> ::core::fmt::Result {"; code_ += " f.debug_struct(\"{{STRUCT_TY}}\")"; ForAllStructFields(struct_def, [&](const FieldDef &unused) { (void)unused; @@ -2651,45 +2653,45 @@ class RustGenerator : public BaseGenerator { // Generate impls for SafeSliceAccess (because all structs are endian-safe), // Follow for the value type, Follow for the reference type, Push for the // value type, and Push for the reference type. - code_ += "impl flatbuffers::SimpleToVerifyInSlice for {{STRUCT_TY}} {}"; - code_ += "impl<'a> flatbuffers::Follow<'a> for {{STRUCT_TY}} {"; + code_ += "impl ::flatbuffers::SimpleToVerifyInSlice for {{STRUCT_TY}} {}"; + code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}} {"; code_ += " type Inner = &'a {{STRUCT_TY}};"; code_ += " #[inline]"; code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {"; code_ += " <&'a {{STRUCT_TY}}>::follow(buf, loc)"; code_ += " }"; code_ += "}"; - code_ += "impl<'a> flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {"; + code_ += "impl<'a> ::flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {"; code_ += " type Inner = &'a {{STRUCT_TY}};"; code_ += " #[inline]"; code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {"; - code_ += " flatbuffers::follow_cast_ref::<{{STRUCT_TY}}>(buf, loc)"; + code_ += " ::flatbuffers::follow_cast_ref::<{{STRUCT_TY}}>(buf, loc)"; code_ += " }"; code_ += "}"; - code_ += "impl<'b> flatbuffers::Push for {{STRUCT_TY}} {"; + code_ += "impl<'b> ::flatbuffers::Push for {{STRUCT_TY}} {"; code_ += " type Output = {{STRUCT_TY}};"; code_ += " #[inline]"; code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {"; code_ += " let src = ::core::slice::from_raw_parts(self as *const " - "{{STRUCT_TY}} as *const u8, ::size());"; + "{{STRUCT_TY}} as *const u8, ::size());"; code_ += " dst.copy_from_slice(src);"; code_ += " }"; code_ += " #[inline]"; - code_ += " fn alignment() -> flatbuffers::PushAlignment {"; - code_ += " flatbuffers::PushAlignment::new({{ALIGN}})"; + code_ += " fn alignment() -> ::flatbuffers::PushAlignment {"; + code_ += " ::flatbuffers::PushAlignment::new({{ALIGN}})"; code_ += " }"; code_ += "}"; code_ += ""; // Generate verifier: Structs are simple so presence and alignment are // all that need to be checked. - code_ += "impl<'a> flatbuffers::Verifiable for {{STRUCT_TY}} {"; + code_ += "impl<'a> ::flatbuffers::Verifiable for {{STRUCT_TY}} {"; code_ += " #[inline]"; code_ += " fn run_verifier("; - code_ += " v: &mut flatbuffers::Verifier, pos: usize"; - code_ += " ) -> Result<(), flatbuffers::InvalidFlatbuffer> {"; - code_ += " use self::flatbuffers::Verifiable;"; + code_ += " v: &mut ::flatbuffers::Verifier, pos: usize"; + code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {"; + code_ += " use ::flatbuffers::Verifiable;"; code_ += " v.in_buffer::(pos)"; code_ += " }"; code_ += "}"; @@ -2766,28 +2768,31 @@ class RustGenerator : public BaseGenerator { code_.SetValue("ARRAY_ITEM", GetTypeGet(field.value.type.VectorType())); code_ += "pub fn {{FIELD}}(&'a self) -> " - "flatbuffers::Array<'a, {{ARRAY_ITEM}}, {{ARRAY_SIZE}}> {"; + "::flatbuffers::Array<'a, {{ARRAY_ITEM}}, {{ARRAY_SIZE}}> {"; code_ += " // Safety:"; code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid array in this slot"; + code_ += " use ::flatbuffers::Follow;"; code_ += - " unsafe { flatbuffers::Array::follow(&self.0, {{FIELD_OFFSET}}) " + " unsafe { ::flatbuffers::Array::follow(&self.0, " + "{{FIELD_OFFSET}}) " "}"; } else { code_ += "pub fn {{FIELD}}(&self) -> {{FIELD_TYPE}} {"; code_ += - " let mut mem = core::mem::MaybeUninit::" - "<<{{FIELD_TYPE}} as EndianScalar>::Scalar>::uninit();"; + " let mut mem = ::core::mem::MaybeUninit::" + "<<{{FIELD_TYPE}} as " + "::flatbuffers::EndianScalar>::Scalar>::uninit();"; code_ += " // Safety:"; code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid value in this slot"; - code_ += " EndianScalar::from_little_endian(unsafe {"; - code_ += " core::ptr::copy_nonoverlapping("; + code_ += " ::flatbuffers::EndianScalar::from_little_endian(unsafe {"; + code_ += " ::core::ptr::copy_nonoverlapping("; code_ += " self.0[{{FIELD_OFFSET}}..].as_ptr(),"; code_ += " mem.as_mut_ptr() as *mut u8,"; code_ += - " core::mem::size_of::<<{{FIELD_TYPE}} as " - "EndianScalar>::Scalar>(),"; + " ::core::mem::size_of::<<{{FIELD_TYPE}} as " + "::flatbuffers::EndianScalar>::Scalar>(),"; code_ += " );"; code_ += " mem.assume_init()"; code_ += " })"; @@ -2815,7 +2820,7 @@ class RustGenerator : public BaseGenerator { code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid array in this slot"; code_ += - " unsafe { flatbuffers::emplace_scalar_array(&mut self.0, " + " unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, " "{{FIELD_OFFSET}}, items) };"; } else { code_.SetValue("FIELD_SIZE", @@ -2825,7 +2830,7 @@ class RustGenerator : public BaseGenerator { code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid array in this slot"; code_ += " unsafe {"; - code_ += " core::ptr::copy("; + code_ += " ::core::ptr::copy("; code_ += " x.as_ptr() as *const u8,"; code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),"; code_ += " {{FIELD_SIZE}},"; @@ -2834,17 +2839,18 @@ class RustGenerator : public BaseGenerator { } } else { code_ += "pub fn set_{{FIELD}}(&mut self, x: {{FIELD_TYPE}}) {"; - code_ += " let x_le = x.to_little_endian();"; + code_ += + " let x_le = ::flatbuffers::EndianScalar::to_little_endian(x);"; code_ += " // Safety:"; code_ += " // Created from a valid Table for this object"; code_ += " // Which contains a valid value in this slot"; code_ += " unsafe {"; - code_ += " core::ptr::copy_nonoverlapping("; + code_ += " ::core::ptr::copy_nonoverlapping("; code_ += " &x_le as *const _ as *const u8,"; code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),"; code_ += - " core::mem::size_of::<<{{FIELD_TYPE}} as " - "EndianScalar>::Scalar>(),"; + " ::core::mem::size_of::<<{{FIELD_TYPE}} as " + "::flatbuffers::EndianScalar>::Scalar>(),"; code_ += " );"; code_ += " }"; } @@ -2864,7 +2870,7 @@ class RustGenerator : public BaseGenerator { if (GetFullType(field.value.type) == ftArrayOfStruct) { code_ += " {{FIELD}}: { let {{FIELD}} = " - "self.{{FIELD}}(); flatbuffers::array_init(|i| " + "self.{{FIELD}}(); ::flatbuffers::array_init(|i| " "{{FIELD}}.get(i).unpack()) },"; } else { code_ += " {{FIELD}}: self.{{FIELD}}().into(),"; @@ -2902,7 +2908,7 @@ class RustGenerator : public BaseGenerator { } else if (IsArray(field.value.type)) { if (GetFullType(field.value.type) == ftArrayOfStruct) { code_ += - " &flatbuffers::array_init(|i| " + " &::flatbuffers::array_init(|i| " "self.{{FIELD}}[i].pack()),"; } else { code_ += " &self.{{FIELD}},"; @@ -2943,9 +2949,6 @@ class RustGenerator : public BaseGenerator { } } } - code_ += indent + "use core::mem;"; - code_ += indent + "use core::cmp::Ordering;"; - code_ += ""; if (parser_.opts.rust_serialize) { code_ += indent + "extern crate serde;"; code_ += @@ -2953,8 +2956,6 @@ class RustGenerator : public BaseGenerator { "use self::serde::ser::{Serialize, Serializer, SerializeStruct};"; code_ += ""; } - code_ += indent + "extern crate flatbuffers;"; - code_ += indent + "use self::flatbuffers::{EndianScalar, Follow};"; } // Set up the correct namespace. This opens a namespace if the current diff --git a/tests/arrays_test/my_game/example/array_struct_generated.rs b/tests/arrays_test/my_game/example/array_struct_generated.rs index 65c7ca6cfcf..74f3b62ccf6 100644 --- a/tests/arrays_test/my_game/example/array_struct_generated.rs +++ b/tests/arrays_test/my_game/example/array_struct_generated.rs @@ -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 ArrayStruct, aligned to 8 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for ArrayStruct { Self([0; 160]) } } -impl core::fmt::Debug for ArrayStruct { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for ArrayStruct { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("ArrayStruct") .field("a", &self.a()) .field("b", &self.b()) @@ -31,40 +24,40 @@ impl core::fmt::Debug for ArrayStruct { } } -impl flatbuffers::SimpleToVerifyInSlice for ArrayStruct {} -impl<'a> flatbuffers::Follow<'a> for ArrayStruct { +impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {} +impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct { type Inner = &'a ArrayStruct; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a ArrayStruct>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a ArrayStruct { +impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct { type Inner = &'a ArrayStruct; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for ArrayStruct { +impl<'b> ::flatbuffers::Push for ArrayStruct { type Output = ArrayStruct; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(8) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(8) } } -impl<'a> flatbuffers::Verifiable for ArrayStruct { +impl<'a> ::flatbuffers::Verifiable for ArrayStruct { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -94,82 +87,84 @@ impl<'a> ArrayStruct { } pub fn a(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } - pub fn b(&'a self) -> flatbuffers::Array<'a, i32, 15> { + pub fn b(&'a self) -> ::flatbuffers::Array<'a, i32, 15> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 4) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 4) } } pub fn set_b(&mut self, items: &[i32; 15]) { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 4, items) }; + unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 4, items) }; } pub fn c(&self) -> i8 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[64..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_c(&mut self, x: i8) { - 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[64..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } - pub fn d(&'a self) -> flatbuffers::Array<'a, NestedStruct, 2> { + pub fn d(&'a self) -> ::flatbuffers::Array<'a, NestedStruct, 2> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 72) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 72) } } pub fn set_d(&mut self, x: &[NestedStruct; 2]) { @@ -177,7 +172,7 @@ impl<'a> ArrayStruct { // Created from a valid Table for this object // Which contains a valid array in this slot unsafe { - core::ptr::copy( + ::core::ptr::copy( x.as_ptr() as *const u8, self.0.as_mut_ptr().add(72), 64, @@ -186,46 +181,47 @@ impl<'a> ArrayStruct { } pub fn e(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[136..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_e(&mut self, x: i32) { - 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[136..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } - pub fn f(&'a self) -> flatbuffers::Array<'a, i64, 2> { + pub fn f(&'a self) -> ::flatbuffers::Array<'a, i64, 2> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 144) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 144) } } pub fn set_f(&mut self, items: &[i64; 2]) { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 144, items) }; + unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 144, items) }; } pub fn unpack(&self) -> ArrayStructT { @@ -233,7 +229,7 @@ impl<'a> ArrayStruct { a: self.a(), b: self.b().into(), c: self.c(), - d: { let d = self.d(); flatbuffers::array_init(|i| d.get(i).unpack()) }, + d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) }, e: self.e(), f: self.f().into(), } @@ -255,7 +251,7 @@ impl ArrayStructT { self.a, &self.b, self.c, - &flatbuffers::array_init(|i| self.d[i].pack()), + &::flatbuffers::array_init(|i| self.d[i].pack()), self.e, &self.f, ) diff --git a/tests/arrays_test/my_game/example/array_table_generated.rs b/tests/arrays_test/my_game/example/array_table_generated.rs index 3bb05d2f439..bc26593f943 100644 --- a/tests/arrays_test/my_game/example/array_table_generated.rs +++ b/tests/arrays_test/my_game/example/array_table_generated.rs @@ -1,45 +1,38 @@ // 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 ArrayTableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct ArrayTable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for ArrayTable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> { type Inner = ArrayTable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> ArrayTable<'a> { - pub const VT_A: flatbuffers::VOffsetT = 4; + pub const VT_A: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.ArrayTable" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { ArrayTable { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 ArrayTableArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = ArrayTableBuilder::new(_fbb); if let Some(x) = args.a { builder.add_a(x); } builder.finish() @@ -63,12 +56,11 @@ impl<'a> ArrayTable<'a> { } } -impl flatbuffers::Verifiable for ArrayTable<'_> { +impl ::flatbuffers::Verifiable for ArrayTable<'_> { #[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::("a", Self::VT_A, false)? .finish(); @@ -87,17 +79,17 @@ impl<'a> Default for ArrayTableArgs<'a> { } } -pub struct ArrayTableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct ArrayTableBuilder<'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> ArrayTableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A> { #[inline] pub fn add_a(&mut self, a: &ArrayStruct) { self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> { let start = _fbb.start_table(); ArrayTableBuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ArrayTableBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for ArrayTable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for ArrayTable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("ArrayTable"); ds.field("a", &self.a()); ds.finish() @@ -131,10 +123,10 @@ impl Default for ArrayTableT { } } impl ArrayTableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let a_tmp = self.a.as_ref().map(|x| x.pack()); let a = a_tmp.as_ref(); ArrayTable::create(_fbb, &ArrayTableArgs{ @@ -149,8 +141,8 @@ impl ArrayTableT { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_array_table_unchecked`. -pub fn root_as_array_table(buf: &[u8]) -> Result { - flatbuffers::root::(buf) +pub fn root_as_array_table(buf: &[u8]) -> Result { + ::flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -159,8 +151,8 @@ pub fn root_as_array_table(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result { + ::flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -170,10 +162,10 @@ pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -183,47 +175,47 @@ pub fn root_as_array_table_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_array_table_unchecked`. pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `ArrayTable`. pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable { - flatbuffers::root_unchecked::(buf) + ::flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`. pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable { - flatbuffers::size_prefixed_root_unchecked::(buf) + ::flatbuffers::size_prefixed_root_unchecked::(buf) } pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT"; #[inline] pub fn array_table_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, false) + ::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, false) } #[inline] pub fn array_table_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, true) + ::flatbuffers::buffer_has_identifier(buf, ARRAY_TABLE_IDENTIFIER, true) } pub const ARRAY_TABLE_EXTENSION: &str = "mon"; #[inline] -pub fn finish_array_table_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>) { +pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>) { fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER)); } diff --git a/tests/arrays_test/my_game/example/nested_struct_generated.rs b/tests/arrays_test/my_game/example/nested_struct_generated.rs index 0015f228260..a75d2a386d7 100644 --- a/tests/arrays_test/my_game/example/nested_struct_generated.rs +++ b/tests/arrays_test/my_game/example/nested_struct_generated.rs @@ -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 NestedStruct, aligned to 8 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for NestedStruct { Self([0; 32]) } } -impl core::fmt::Debug for NestedStruct { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for NestedStruct { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("NestedStruct") .field("a", &self.a()) .field("b", &self.b()) @@ -29,40 +22,40 @@ impl core::fmt::Debug for NestedStruct { } } -impl flatbuffers::SimpleToVerifyInSlice for NestedStruct {} -impl<'a> flatbuffers::Follow<'a> for NestedStruct { +impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {} +impl<'a> ::flatbuffers::Follow<'a> for NestedStruct { type Inner = &'a NestedStruct; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a NestedStruct>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a NestedStruct { +impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct { type Inner = &'a NestedStruct; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for NestedStruct { +impl<'b> ::flatbuffers::Push for NestedStruct { type Output = NestedStruct; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(8) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(8) } } -impl<'a> flatbuffers::Verifiable for NestedStruct { +impl<'a> ::flatbuffers::Verifiable for NestedStruct { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -87,54 +80,56 @@ impl<'a> NestedStruct { "MyGame.Example.NestedStruct" } - pub fn a(&'a self) -> flatbuffers::Array<'a, i32, 2> { + pub fn a(&'a self) -> ::flatbuffers::Array<'a, i32, 2> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 0) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 0) } } pub fn set_a(&mut self, items: &[i32; 2]) { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; + unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 0, items) }; } pub fn b(&self) -> TestEnum { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_b(&mut self, x: TestEnum) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } - pub fn c(&'a self) -> flatbuffers::Array<'a, TestEnum, 2> { + pub fn c(&'a self) -> ::flatbuffers::Array<'a, TestEnum, 2> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 9) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 9) } } pub fn set_c(&mut self, x: &[TestEnum; 2]) { @@ -142,7 +137,7 @@ impl<'a> NestedStruct { // Created from a valid Table for this object // Which contains a valid array in this slot unsafe { - core::ptr::copy( + ::core::ptr::copy( x.as_ptr() as *const u8, self.0.as_mut_ptr().add(9), 2, @@ -150,18 +145,19 @@ impl<'a> NestedStruct { } } - pub fn d(&'a self) -> flatbuffers::Array<'a, i64, 2> { + pub fn d(&'a self) -> ::flatbuffers::Array<'a, i64, 2> { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::Array::follow(&self.0, 16) } + use ::flatbuffers::Follow; + unsafe { ::flatbuffers::Array::follow(&self.0, 16) } } pub fn set_d(&mut self, items: &[i64; 2]) { // Safety: // Created from a valid Table for this object // Which contains a valid array in this slot - unsafe { flatbuffers::emplace_scalar_array(&mut self.0, 16, items) }; + unsafe { ::flatbuffers::emplace_scalar_array(&mut self.0, 16, items) }; } pub fn unpack(&self) -> NestedStructT { diff --git a/tests/arrays_test/my_game/example/test_enum_generated.rs b/tests/arrays_test/my_game/example/test_enum_generated.rs index 6721484ae26..71f592bf92b 100644 --- a/tests/arrays_test/my_game/example/test_enum_generated.rs +++ b/tests/arrays_test/my_game/example/test_enum_generated.rs @@ -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_TEST_ENUM: i8 = 0; @@ -47,8 +40,8 @@ impl TestEnum { } } } -impl core::fmt::Debug for TestEnum { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for TestEnum { + 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 TestEnum { } } } -impl<'a> flatbuffers::Follow<'a> for TestEnum { +impl<'a> ::flatbuffers::Follow<'a> for TestEnum { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for TestEnum { +impl ::flatbuffers::Push for TestEnum { type Output = TestEnum; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for TestEnum { +impl ::flatbuffers::EndianScalar for TestEnum { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for TestEnum { } } -impl<'a> flatbuffers::Verifiable for TestEnum { +impl<'a> ::flatbuffers::Verifiable for TestEnum { #[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 TestEnum {} +impl ::flatbuffers::SimpleToVerifyInSlice for TestEnum {} diff --git a/tests/include_test1/my_game/other_name_space/from_include_generated.rs b/tests/include_test1/my_game/other_name_space/from_include_generated.rs index 70cb407c1ea..5a7df08c76f 100644 --- a/tests/include_test1/my_game/other_name_space/from_include_generated.rs +++ b/tests/include_test1/my_game/other_name_space/from_include_generated.rs @@ -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_FROM_INCLUDE: i64 = 0; @@ -39,8 +32,8 @@ impl FromInclude { } } } -impl core::fmt::Debug for FromInclude { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for FromInclude { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -48,24 +41,24 @@ impl core::fmt::Debug for FromInclude { } } } -impl<'a> flatbuffers::Follow<'a> for FromInclude { +impl<'a> ::flatbuffers::Follow<'a> for FromInclude { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for FromInclude { +impl ::flatbuffers::Push for FromInclude { type Output = FromInclude; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for FromInclude { +impl ::flatbuffers::EndianScalar for FromInclude { type Scalar = i64; #[inline] fn to_little_endian(self) -> i64 { @@ -79,14 +72,13 @@ impl flatbuffers::EndianScalar for FromInclude { } } -impl<'a> flatbuffers::Verifiable for FromInclude { +impl<'a> ::flatbuffers::Verifiable for FromInclude { #[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> { i64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for FromInclude {} +impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {} diff --git a/tests/include_test1/my_game/other_name_space/table_b_generated.rs b/tests/include_test1/my_game/other_name_space/table_b_generated.rs index 84932cbc5ad..d318d36c236 100644 --- a/tests/include_test1/my_game/other_name_space/table_b_generated.rs +++ b/tests/include_test1/my_game/other_name_space/table_b_generated.rs @@ -1,45 +1,38 @@ // 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 TableBOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableB<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableB<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> { type Inner = TableB<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableB<'a> { - pub const VT_A: flatbuffers::VOffsetT = 4; + pub const VT_A: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.OtherNameSpace.TableB" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableB { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableBArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableBBuilder::new(_fbb); if let Some(x) = args.a { builder.add_a(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableB<'a> { pub fn unpack(&self) -> TableBT { let a = self.a().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableBT { a, @@ -59,24 +52,23 @@ impl<'a> TableB<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableB::VT_A, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableB::VT_A, None)} } } -impl flatbuffers::Verifiable for TableB<'_> { +impl ::flatbuffers::Verifiable for TableB<'_> { #[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::>("a", Self::VT_A, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("a", Self::VT_A, false)? .finish(); Ok(()) } } pub struct TableBArgs<'a> { - pub a: Option>>, + pub a: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableBArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableBArgs<'a> { } } -pub struct TableBBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableBBuilder<'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> TableBBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { #[inline] - pub fn add_a(&mut self, a: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableB::VT_A, a); + pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableB::VT_A, a); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableBBuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableB<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableB<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableB"); ds.field("a", &self.a()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableB<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableBT { - pub a: Option>, + pub a: Option>, } impl Default for TableBT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableBT { } } impl TableBT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let a = self.a.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/include_test1/my_game/other_name_space/unused_generated.rs b/tests/include_test1/my_game/other_name_space/unused_generated.rs index 11af62f073b..b16b39042b2 100644 --- a/tests/include_test1/my_game/other_name_space/unused_generated.rs +++ b/tests/include_test1/my_game/other_name_space/unused_generated.rs @@ -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 Unused, aligned to 4 #[repr(transparent)] @@ -18,48 +11,48 @@ impl Default for Unused { Self([0; 4]) } } -impl core::fmt::Debug for Unused { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Unused { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Unused") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for Unused {} -impl<'a> flatbuffers::Follow<'a> for Unused { +impl ::flatbuffers::SimpleToVerifyInSlice for Unused {} +impl<'a> ::flatbuffers::Follow<'a> for Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Unused>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Unused { +impl<'a> ::flatbuffers::Follow<'a> for &'a Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Unused { +impl<'b> ::flatbuffers::Push for Unused { type Output = Unused; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::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 Unused { +impl<'a> ::flatbuffers::Verifiable for Unused { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -79,30 +72,30 @@ impl<'a> Unused { } pub fn a(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/include_test1/table_a_generated.rs b/tests/include_test1/table_a_generated.rs index 781a6c469db..e2d9356f828 100644 --- a/tests/include_test1/table_a_generated.rs +++ b/tests/include_test1/table_a_generated.rs @@ -1,45 +1,38 @@ // 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 TableAOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableA<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableA<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> { type Inner = TableA<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableA<'a> { - pub const VT_B: flatbuffers::VOffsetT = 4; + pub const VT_B: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "TableA" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableA { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableAArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableABuilder::new(_fbb); if let Some(x) = args.b { builder.add_b(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableA<'a> { pub fn unpack(&self) -> TableAT { let b = self.b().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableAT { b, @@ -59,24 +52,23 @@ impl<'a> TableA<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableA::VT_B, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableA::VT_B, None)} } } -impl flatbuffers::Verifiable for TableA<'_> { +impl ::flatbuffers::Verifiable for TableA<'_> { #[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::>("b", Self::VT_B, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("b", Self::VT_B, false)? .finish(); Ok(()) } } pub struct TableAArgs<'a> { - pub b: Option>>, + pub b: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableAArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableAArgs<'a> { } } -pub struct TableABuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableABuilder<'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> TableABuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { #[inline] - pub fn add_b(&mut self, b: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableA::VT_B, b); + pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableA::VT_B, b); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { let start = _fbb.start_table(); TableABuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableA<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableA<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableA"); ds.field("b", &self.b()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableA<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableAT { - pub b: Option>, + pub b: Option>, } impl Default for TableAT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableAT { } } impl TableAT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let b = self.b.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/include_test2/my_game/other_name_space/from_include_generated.rs b/tests/include_test2/my_game/other_name_space/from_include_generated.rs index 70cb407c1ea..5a7df08c76f 100644 --- a/tests/include_test2/my_game/other_name_space/from_include_generated.rs +++ b/tests/include_test2/my_game/other_name_space/from_include_generated.rs @@ -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_FROM_INCLUDE: i64 = 0; @@ -39,8 +32,8 @@ impl FromInclude { } } } -impl core::fmt::Debug for FromInclude { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for FromInclude { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -48,24 +41,24 @@ impl core::fmt::Debug for FromInclude { } } } -impl<'a> flatbuffers::Follow<'a> for FromInclude { +impl<'a> ::flatbuffers::Follow<'a> for FromInclude { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for FromInclude { +impl ::flatbuffers::Push for FromInclude { type Output = FromInclude; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for FromInclude { +impl ::flatbuffers::EndianScalar for FromInclude { type Scalar = i64; #[inline] fn to_little_endian(self) -> i64 { @@ -79,14 +72,13 @@ impl flatbuffers::EndianScalar for FromInclude { } } -impl<'a> flatbuffers::Verifiable for FromInclude { +impl<'a> ::flatbuffers::Verifiable for FromInclude { #[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> { i64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for FromInclude {} +impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {} diff --git a/tests/include_test2/my_game/other_name_space/table_b_generated.rs b/tests/include_test2/my_game/other_name_space/table_b_generated.rs index 84932cbc5ad..d318d36c236 100644 --- a/tests/include_test2/my_game/other_name_space/table_b_generated.rs +++ b/tests/include_test2/my_game/other_name_space/table_b_generated.rs @@ -1,45 +1,38 @@ // 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 TableBOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableB<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableB<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> { type Inner = TableB<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableB<'a> { - pub const VT_A: flatbuffers::VOffsetT = 4; + pub const VT_A: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.OtherNameSpace.TableB" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableB { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableBArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableBBuilder::new(_fbb); if let Some(x) = args.a { builder.add_a(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableB<'a> { pub fn unpack(&self) -> TableBT { let a = self.a().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableBT { a, @@ -59,24 +52,23 @@ impl<'a> TableB<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableB::VT_A, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableB::VT_A, None)} } } -impl flatbuffers::Verifiable for TableB<'_> { +impl ::flatbuffers::Verifiable for TableB<'_> { #[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::>("a", Self::VT_A, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("a", Self::VT_A, false)? .finish(); Ok(()) } } pub struct TableBArgs<'a> { - pub a: Option>>, + pub a: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableBArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableBArgs<'a> { } } -pub struct TableBBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableBBuilder<'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> TableBBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { #[inline] - pub fn add_a(&mut self, a: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableB::VT_A, a); + pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableB::VT_A, a); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableBBuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableB<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableB<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableB"); ds.field("a", &self.a()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableB<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableBT { - pub a: Option>, + pub a: Option>, } impl Default for TableBT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableBT { } } impl TableBT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let a = self.a.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/include_test2/my_game/other_name_space/unused_generated.rs b/tests/include_test2/my_game/other_name_space/unused_generated.rs index 11af62f073b..b16b39042b2 100644 --- a/tests/include_test2/my_game/other_name_space/unused_generated.rs +++ b/tests/include_test2/my_game/other_name_space/unused_generated.rs @@ -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 Unused, aligned to 4 #[repr(transparent)] @@ -18,48 +11,48 @@ impl Default for Unused { Self([0; 4]) } } -impl core::fmt::Debug for Unused { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Unused { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Unused") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for Unused {} -impl<'a> flatbuffers::Follow<'a> for Unused { +impl ::flatbuffers::SimpleToVerifyInSlice for Unused {} +impl<'a> ::flatbuffers::Follow<'a> for Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Unused>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Unused { +impl<'a> ::flatbuffers::Follow<'a> for &'a Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Unused { +impl<'b> ::flatbuffers::Push for Unused { type Output = Unused; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::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 Unused { +impl<'a> ::flatbuffers::Verifiable for Unused { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -79,30 +72,30 @@ impl<'a> Unused { } pub fn a(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/include_test2/table_a_generated.rs b/tests/include_test2/table_a_generated.rs index 781a6c469db..e2d9356f828 100644 --- a/tests/include_test2/table_a_generated.rs +++ b/tests/include_test2/table_a_generated.rs @@ -1,45 +1,38 @@ // 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 TableAOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableA<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableA<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> { type Inner = TableA<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableA<'a> { - pub const VT_B: flatbuffers::VOffsetT = 4; + pub const VT_B: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "TableA" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableA { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableAArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableABuilder::new(_fbb); if let Some(x) = args.b { builder.add_b(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableA<'a> { pub fn unpack(&self) -> TableAT { let b = self.b().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableAT { b, @@ -59,24 +52,23 @@ impl<'a> TableA<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableA::VT_B, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableA::VT_B, None)} } } -impl flatbuffers::Verifiable for TableA<'_> { +impl ::flatbuffers::Verifiable for TableA<'_> { #[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::>("b", Self::VT_B, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("b", Self::VT_B, false)? .finish(); Ok(()) } } pub struct TableAArgs<'a> { - pub b: Option>>, + pub b: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableAArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableAArgs<'a> { } } -pub struct TableABuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableABuilder<'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> TableABuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { #[inline] - pub fn add_b(&mut self, b: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableA::VT_B, b); + pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableA::VT_B, b); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { let start = _fbb.start_table(); TableABuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableA<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableA<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableA"); ds.field("b", &self.b()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableA<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableAT { - pub b: Option>, + pub b: Option>, } impl Default for TableAT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableAT { } } impl TableAT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let b = self.b.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/keyword_test/keyword_test/abc_generated.rs b/tests/keyword_test/keyword_test/abc_generated.rs index 5169ab13da5..7947601861c 100644 --- a/tests/keyword_test/keyword_test/abc_generated.rs +++ b/tests/keyword_test/keyword_test/abc_generated.rs @@ -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_ABC: i32 = 0; @@ -47,8 +40,8 @@ impl ABC { } } } -impl core::fmt::Debug for ABC { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for ABC { + 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 ABC { } } } -impl<'a> flatbuffers::Follow<'a> for ABC { +impl<'a> ::flatbuffers::Follow<'a> for ABC { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for ABC { +impl ::flatbuffers::Push for ABC { type Output = ABC; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for ABC { +impl ::flatbuffers::EndianScalar for ABC { type Scalar = i32; #[inline] fn to_little_endian(self) -> i32 { @@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for ABC { } } -impl<'a> flatbuffers::Verifiable for ABC { +impl<'a> ::flatbuffers::Verifiable for ABC { #[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> { i32::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for ABC {} +impl ::flatbuffers::SimpleToVerifyInSlice for ABC {} diff --git a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs index 737e88aa0be..c1be74b177c 100644 --- a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs +++ b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs @@ -1,48 +1,41 @@ // 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 KeywordsInTableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct KeywordsInTable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for KeywordsInTable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for KeywordsInTable<'a> { type Inner = KeywordsInTable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> KeywordsInTable<'a> { - pub const VT_IS: flatbuffers::VOffsetT = 4; - pub const VT_PRIVATE: flatbuffers::VOffsetT = 6; - pub const VT_TYPE_: flatbuffers::VOffsetT = 8; - pub const VT_DEFAULT: flatbuffers::VOffsetT = 10; + pub const VT_IS: ::flatbuffers::VOffsetT = 4; + pub const VT_PRIVATE: ::flatbuffers::VOffsetT = 6; + pub const VT_TYPE_: ::flatbuffers::VOffsetT = 8; + pub const VT_DEFAULT: ::flatbuffers::VOffsetT = 10; pub const fn get_fully_qualified_name() -> &'static str { "KeywordTest.KeywordsInTable" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { KeywordsInTable { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 KeywordsInTableArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = KeywordsInTableBuilder::new(_fbb); builder.add_type_(args.type_); builder.add_private(args.private); @@ -94,12 +87,11 @@ impl<'a> KeywordsInTable<'a> { } } -impl flatbuffers::Verifiable for KeywordsInTable<'_> { +impl ::flatbuffers::Verifiable for KeywordsInTable<'_> { #[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::("is", Self::VT_IS, false)? .visit_field::("private", Self::VT_PRIVATE, false)? @@ -127,11 +119,11 @@ impl<'a> Default for KeywordsInTableArgs { } } -pub struct KeywordsInTableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct KeywordsInTableBuilder<'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> KeywordsInTableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b, A> { #[inline] pub fn add_is(&mut self, is: ABC) { self.fbb_.push_slot::(KeywordsInTable::VT_IS, is, ABC::void); @@ -149,7 +141,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b, self.fbb_.push_slot::(KeywordsInTable::VT_DEFAULT, default, false); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> { let start = _fbb.start_table(); KeywordsInTableBuilder { fbb_: _fbb, @@ -157,14 +149,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> KeywordsInTableBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for KeywordsInTable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for KeywordsInTable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("KeywordsInTable"); ds.field("is", &self.is()); ds.field("private", &self.private()); @@ -192,10 +184,10 @@ impl Default for KeywordsInTableT { } } impl KeywordsInTableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let is = self.is; let private = self.private; let type_ = self.type_; diff --git a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs index fa06597dddc..37339f4ef4c 100644 --- a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs +++ b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs @@ -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_KEYWORDS_IN_UNION: u8 = 0; @@ -47,8 +40,8 @@ impl KeywordsInUnion { } } } -impl core::fmt::Debug for KeywordsInUnion { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for KeywordsInUnion { + 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 KeywordsInUnion { } } } -impl<'a> flatbuffers::Follow<'a> for KeywordsInUnion { +impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for KeywordsInUnion { +impl ::flatbuffers::Push for KeywordsInUnion { type Output = KeywordsInUnion; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for KeywordsInUnion { +impl ::flatbuffers::EndianScalar for KeywordsInUnion { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -87,17 +80,16 @@ impl flatbuffers::EndianScalar for KeywordsInUnion { } } -impl<'a> flatbuffers::Verifiable for KeywordsInUnion { +impl<'a> ::flatbuffers::Verifiable for KeywordsInUnion { #[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 KeywordsInUnion {} +impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {} pub struct KeywordsInUnionUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -105,8 +97,8 @@ pub struct KeywordsInUnionUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum KeywordsInUnionT { NONE, - Static_(Box), - Internal(Box), + Static_(alloc::boxed::Box), + Internal(alloc::boxed::Box), } impl Default for KeywordsInUnionT { fn default() -> Self { @@ -121,7 +113,7 @@ impl KeywordsInUnionT { Self::Internal(_) => KeywordsInUnion::internal, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::Static_(v) => Some(v.pack(fbb).as_union_value()), @@ -129,9 +121,9 @@ impl KeywordsInUnionT { } } /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE. - pub fn take_static_(&mut self) -> Option> { + pub fn take_static_(&mut self) -> Option> { if let Self::Static_(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Static_(w) = v { Some(w) } else { @@ -150,9 +142,9 @@ impl KeywordsInUnionT { if let Self::Static_(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE. - pub fn take_internal(&mut self) -> Option> { + pub fn take_internal(&mut self) -> Option> { if let Self::Internal(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Internal(w) = v { Some(w) } else { diff --git a/tests/keyword_test/keyword_test/public_generated.rs b/tests/keyword_test/keyword_test/public_generated.rs index 12c3ff57935..8aed28eede8 100644 --- a/tests/keyword_test/keyword_test/public_generated.rs +++ b/tests/keyword_test/keyword_test/public_generated.rs @@ -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_PUBLIC: i32 = 0; @@ -39,8 +32,8 @@ impl public { } } } -impl core::fmt::Debug for public { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for public { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -48,24 +41,24 @@ impl core::fmt::Debug for public { } } } -impl<'a> flatbuffers::Follow<'a> for public { +impl<'a> ::flatbuffers::Follow<'a> for public { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for public { +impl ::flatbuffers::Push for public { type Output = public; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for public { +impl ::flatbuffers::EndianScalar for public { type Scalar = i32; #[inline] fn to_little_endian(self) -> i32 { @@ -79,14 +72,13 @@ impl flatbuffers::EndianScalar for public { } } -impl<'a> flatbuffers::Verifiable for public { +impl<'a> ::flatbuffers::Verifiable for public { #[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> { i32::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for public {} +impl ::flatbuffers::SimpleToVerifyInSlice for public {} diff --git a/tests/keyword_test/keyword_test/table_2_generated.rs b/tests/keyword_test/keyword_test/table_2_generated.rs index 2af417680e8..4701ee66b8b 100644 --- a/tests/keyword_test/keyword_test/table_2_generated.rs +++ b/tests/keyword_test/keyword_test/table_2_generated.rs @@ -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 Table2Offset {} #[derive(Copy, Clone, PartialEq)] pub struct Table2<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Table2<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Table2<'a> { type Inner = Table2<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Table2<'a> { - pub const VT_TYPE_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_TYPE_: flatbuffers::VOffsetT = 6; + pub const VT_TYPE_TYPE: ::flatbuffers::VOffsetT = 4; + pub const VT_TYPE_: ::flatbuffers::VOffsetT = 6; pub const fn get_fully_qualified_name() -> &'static str { "KeywordTest.Table2" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Table2 { _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 Table2Args - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = Table2Builder::new(_fbb); if let Some(x) = args.type_ { builder.add_type_(x); } builder.add_type_type(args.type_type); @@ -50,12 +43,12 @@ impl<'a> Table2<'a> { pub fn unpack(&self) -> Table2T { let type_ = match self.type_type() { KeywordsInUnion::NONE => KeywordsInUnionT::NONE, - KeywordsInUnion::static_ => KeywordsInUnionT::Static_(Box::new( + KeywordsInUnion::static_ => KeywordsInUnionT::Static_(alloc::boxed::Box::new( self.type__as_static_() .expect("Invalid union table, expected `KeywordsInUnion::static_`.") .unpack() )), - KeywordsInUnion::internal => KeywordsInUnionT::Internal(Box::new( + KeywordsInUnion::internal => KeywordsInUnionT::Internal(alloc::boxed::Box::new( self.type__as_internal() .expect("Invalid union table, expected `KeywordsInUnion::internal`.") .unpack() @@ -75,11 +68,11 @@ impl<'a> Table2<'a> { unsafe { self._tab.get::(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()} } #[inline] - pub fn type_(&self) -> Option> { + pub fn type_(&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::>>(Table2::VT_TYPE_, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)} } #[inline] #[allow(non_snake_case)] @@ -113,17 +106,16 @@ impl<'a> Table2<'a> { } -impl flatbuffers::Verifiable for Table2<'_> { +impl ::flatbuffers::Verifiable for Table2<'_> { #[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_union::("type_type", Self::VT_TYPE_TYPE, "type_", Self::VT_TYPE_, false, |key, v, pos| { match key { - KeywordsInUnion::static_ => v.verify_union_variant::>("KeywordsInUnion::static_", pos), - KeywordsInUnion::internal => v.verify_union_variant::>("KeywordsInUnion::internal", pos), + KeywordsInUnion::static_ => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("KeywordsInUnion::static_", pos), + KeywordsInUnion::internal => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("KeywordsInUnion::internal", pos), _ => Ok(()), } })? @@ -133,7 +125,7 @@ impl flatbuffers::Verifiable for Table2<'_> { } pub struct Table2Args { pub type_type: KeywordsInUnion, - pub type_: Option>, + pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, } impl<'a> Default for Table2Args { #[inline] @@ -145,21 +137,21 @@ impl<'a> Default for Table2Args { } } -pub struct Table2Builder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct Table2Builder<'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> Table2Builder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> { #[inline] pub fn add_type_type(&mut self, type_type: KeywordsInUnion) { self.fbb_.push_slot::(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE); } #[inline] - pub fn add_type_(&mut self, type_: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Table2::VT_TYPE_, type_); + pub fn add_type_(&mut self, type_: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Table2::VT_TYPE_, type_); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> Table2Builder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> Table2Builder<'a, 'b, A> { let start = _fbb.start_table(); Table2Builder { fbb_: _fbb, @@ -167,14 +159,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> Table2Builder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Table2<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Table2<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Table2"); ds.field("type_type", &self.type_type()); match self.type_type() { @@ -213,10 +205,10 @@ impl Default for Table2T { } } impl Table2T { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let type_type = self.type_.keywords_in_union_type(); let type_ = self.type_.pack(_fbb); Table2::create(_fbb, &Table2Args{ diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs index 0cef974d6ef..5d7b7a468b4 100644 --- a/tests/monster_test/my_game/example/ability_generated.rs +++ b/tests/monster_test/my_game/example/ability_generated.rs @@ -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 Ability, aligned to 4 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for Ability { Self([0; 8]) } } -impl core::fmt::Debug for Ability { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Ability { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Ability") .field("id", &self.id()) .field("distance", &self.distance()) @@ -27,40 +20,40 @@ impl core::fmt::Debug for Ability { } } -impl flatbuffers::SimpleToVerifyInSlice for Ability {} -impl<'a> flatbuffers::Follow<'a> for Ability { +impl ::flatbuffers::SimpleToVerifyInSlice for Ability {} +impl<'a> ::flatbuffers::Follow<'a> for Ability { type Inner = &'a Ability; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Ability>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Ability { +impl<'a> ::flatbuffers::Follow<'a> for &'a Ability { type Inner = &'a Ability; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Ability { +impl<'b> ::flatbuffers::Push for Ability { type Output = Ability; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, ::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 Ability { +impl<'a> ::flatbuffers::Verifiable for Ability { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -82,30 +75,30 @@ impl<'a> Ability { } pub fn id(&self) -> u32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_id(&mut self, x: u32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } @@ -121,30 +114,30 @@ impl<'a> Ability { key.cmp(&val) } pub fn distance(&self) -> u32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_distance(&mut self, x: u32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs index f4001fd7063..cef446e515e 100644 --- a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs +++ b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs @@ -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_ANY_AMBIGUOUS_ALIASES: u8 = 0; @@ -51,8 +44,8 @@ impl AnyAmbiguousAliases { } } } -impl core::fmt::Debug for AnyAmbiguousAliases { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for AnyAmbiguousAliases { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -60,24 +53,24 @@ impl core::fmt::Debug for AnyAmbiguousAliases { } } } -impl<'a> flatbuffers::Follow<'a> for AnyAmbiguousAliases { +impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for AnyAmbiguousAliases { +impl ::flatbuffers::Push for AnyAmbiguousAliases { type Output = AnyAmbiguousAliases; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for AnyAmbiguousAliases { +impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -91,17 +84,16 @@ impl flatbuffers::EndianScalar for AnyAmbiguousAliases { } } -impl<'a> flatbuffers::Verifiable for AnyAmbiguousAliases { +impl<'a> ::flatbuffers::Verifiable for AnyAmbiguousAliases { #[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 AnyAmbiguousAliases {} +impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {} pub struct AnyAmbiguousAliasesUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -109,9 +101,9 @@ pub struct AnyAmbiguousAliasesUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyAmbiguousAliasesT { NONE, - M1(Box), - M2(Box), - M3(Box), + M1(alloc::boxed::Box), + M2(alloc::boxed::Box), + M3(alloc::boxed::Box), } impl Default for AnyAmbiguousAliasesT { fn default() -> Self { @@ -127,7 +119,7 @@ impl AnyAmbiguousAliasesT { Self::M3(_) => AnyAmbiguousAliases::M3, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::M1(v) => Some(v.pack(fbb).as_union_value()), @@ -136,9 +128,9 @@ impl AnyAmbiguousAliasesT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m1(&mut self) -> Option> { + pub fn take_m1(&mut self) -> Option> { if let Self::M1(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M1(w) = v { Some(w) } else { @@ -157,9 +149,9 @@ impl AnyAmbiguousAliasesT { if let Self::M1(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m2(&mut self) -> Option> { + pub fn take_m2(&mut self) -> Option> { if let Self::M2(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M2(w) = v { Some(w) } else { @@ -178,9 +170,9 @@ impl AnyAmbiguousAliasesT { if let Self::M2(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m3(&mut self) -> Option> { + pub fn take_m3(&mut self) -> Option> { if let Self::M3(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M3(w) = v { Some(w) } else { diff --git a/tests/monster_test/my_game/example/any_generated.rs b/tests/monster_test/my_game/example/any_generated.rs index 4669671ea14..71a50a76811 100644 --- a/tests/monster_test/my_game/example/any_generated.rs +++ b/tests/monster_test/my_game/example/any_generated.rs @@ -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_ANY: u8 = 0; @@ -51,8 +44,8 @@ impl Any { } } } -impl core::fmt::Debug for Any { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Any { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -60,24 +53,24 @@ impl core::fmt::Debug for Any { } } } -impl<'a> flatbuffers::Follow<'a> for Any { +impl<'a> ::flatbuffers::Follow<'a> for Any { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for Any { +impl ::flatbuffers::Push for Any { type Output = Any; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for Any { +impl ::flatbuffers::EndianScalar for Any { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -91,17 +84,16 @@ impl flatbuffers::EndianScalar for Any { } } -impl<'a> flatbuffers::Verifiable for Any { +impl<'a> ::flatbuffers::Verifiable for Any { #[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 Any {} +impl ::flatbuffers::SimpleToVerifyInSlice for Any {} pub struct AnyUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -109,9 +101,9 @@ pub struct AnyUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyT { NONE, - Monster(Box), - TestSimpleTableWithEnum(Box), - MyGameExample2Monster(Box), + Monster(alloc::boxed::Box), + TestSimpleTableWithEnum(alloc::boxed::Box), + MyGameExample2Monster(alloc::boxed::Box), } impl Default for AnyT { fn default() -> Self { @@ -127,7 +119,7 @@ impl AnyT { Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::Monster(v) => Some(v.pack(fbb).as_union_value()), @@ -136,9 +128,9 @@ impl AnyT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_monster(&mut self) -> Option> { + pub fn take_monster(&mut self) -> Option> { if let Self::Monster(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Monster(w) = v { Some(w) } else { @@ -157,9 +149,9 @@ impl AnyT { if let Self::Monster(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. - pub fn take_test_simple_table_with_enum(&mut self) -> Option> { + pub fn take_test_simple_table_with_enum(&mut self) -> Option> { if let Self::TestSimpleTableWithEnum(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::TestSimpleTableWithEnum(w) = v { Some(w) } else { @@ -178,9 +170,9 @@ impl AnyT { if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. - pub fn take_my_game_example_2_monster(&mut self) -> Option> { + pub fn take_my_game_example_2_monster(&mut self) -> Option> { if let Self::MyGameExample2Monster(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::MyGameExample2Monster(w) = v { Some(w) } else { diff --git a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs index f2ee8462536..1a72b346a8e 100644 --- a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs +++ b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs @@ -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_ANY_UNIQUE_ALIASES: u8 = 0; @@ -51,8 +44,8 @@ impl AnyUniqueAliases { } } } -impl core::fmt::Debug for AnyUniqueAliases { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for AnyUniqueAliases { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -60,24 +53,24 @@ impl core::fmt::Debug for AnyUniqueAliases { } } } -impl<'a> flatbuffers::Follow<'a> for AnyUniqueAliases { +impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for AnyUniqueAliases { +impl ::flatbuffers::Push for AnyUniqueAliases { type Output = AnyUniqueAliases; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for AnyUniqueAliases { +impl ::flatbuffers::EndianScalar for AnyUniqueAliases { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -91,17 +84,16 @@ impl flatbuffers::EndianScalar for AnyUniqueAliases { } } -impl<'a> flatbuffers::Verifiable for AnyUniqueAliases { +impl<'a> ::flatbuffers::Verifiable for AnyUniqueAliases { #[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 AnyUniqueAliases {} +impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {} pub struct AnyUniqueAliasesUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -109,9 +101,9 @@ pub struct AnyUniqueAliasesUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyUniqueAliasesT { NONE, - M(Box), - TS(Box), - M2(Box), + M(alloc::boxed::Box), + TS(alloc::boxed::Box), + M2(alloc::boxed::Box), } impl Default for AnyUniqueAliasesT { fn default() -> Self { @@ -127,7 +119,7 @@ impl AnyUniqueAliasesT { Self::M2(_) => AnyUniqueAliases::M2, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::M(v) => Some(v.pack(fbb).as_union_value()), @@ -136,9 +128,9 @@ impl AnyUniqueAliasesT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m(&mut self) -> Option> { + pub fn take_m(&mut self) -> Option> { if let Self::M(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M(w) = v { Some(w) } else { @@ -157,9 +149,9 @@ impl AnyUniqueAliasesT { if let Self::M(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. - pub fn take_ts(&mut self) -> Option> { + pub fn take_ts(&mut self) -> Option> { if let Self::TS(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::TS(w) = v { Some(w) } else { @@ -178,9 +170,9 @@ impl AnyUniqueAliasesT { if let Self::TS(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. - pub fn take_m2(&mut self) -> Option> { + pub fn take_m2(&mut self) -> Option> { if let Self::M2(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M2(w) = v { Some(w) } else { diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs index 713e2b3da36..76da27f1a26 100644 --- a/tests/monster_test/my_game/example/color_generated.rs +++ b/tests/monster_test/my_game/example/color_generated.rs @@ -1,17 +1,10 @@ // 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::*; #[allow(non_upper_case_globals)] mod bitflags_color { - flatbuffers::bitflags::bitflags! { + ::flatbuffers::bitflags::bitflags! { /// Composite components of Monster color. #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct Color: u8 { @@ -26,24 +19,24 @@ mod bitflags_color { } pub use self::bitflags_color::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 = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self::from_bits_retain(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) { - flatbuffers::emplace_scalar::(dst, self.bits()); + ::flatbuffers::emplace_scalar::(dst, self.bits()); } } -impl flatbuffers::EndianScalar for Color { +impl ::flatbuffers::EndianScalar for Color { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -57,14 +50,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> { u8::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for Color {} +impl ::flatbuffers::SimpleToVerifyInSlice for Color {} diff --git a/tests/monster_test/my_game/example/long_enum_generated.rs b/tests/monster_test/my_game/example/long_enum_generated.rs index c912d25b091..4274cb2aa64 100644 --- a/tests/monster_test/my_game/example/long_enum_generated.rs +++ b/tests/monster_test/my_game/example/long_enum_generated.rs @@ -1,17 +1,10 @@ // 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::*; #[allow(non_upper_case_globals)] mod bitflags_long_enum { - flatbuffers::bitflags::bitflags! { + ::flatbuffers::bitflags::bitflags! { #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct LongEnum: u64 { const LongOne = 2; @@ -22,24 +15,24 @@ mod bitflags_long_enum { } pub use self::bitflags_long_enum::LongEnum; -impl<'a> flatbuffers::Follow<'a> for LongEnum { +impl<'a> ::flatbuffers::Follow<'a> for LongEnum { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self::from_bits_retain(b) } } -impl flatbuffers::Push for LongEnum { +impl ::flatbuffers::Push for LongEnum { type Output = LongEnum; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.bits()); + ::flatbuffers::emplace_scalar::(dst, self.bits()); } } -impl flatbuffers::EndianScalar for LongEnum { +impl ::flatbuffers::EndianScalar for LongEnum { type Scalar = u64; #[inline] fn to_little_endian(self) -> u64 { @@ -53,14 +46,13 @@ impl flatbuffers::EndianScalar for LongEnum { } } -impl<'a> flatbuffers::Verifiable for LongEnum { +impl<'a> ::flatbuffers::Verifiable for LongEnum { #[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> { u64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for LongEnum {} +impl ::flatbuffers::SimpleToVerifyInSlice for LongEnum {} diff --git a/tests/monster_test/my_game/example/monster_generated.rs b/tests/monster_test/my_game/example/monster_generated.rs index 9fd096ddf0c..39e717b4017 100644 --- a/tests/monster_test/my_game/example/monster_generated.rs +++ b/tests/monster_test/my_game/example/monster_generated.rs @@ -1,106 +1,99 @@ // 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)] /// an example documentation comment: "monster object" 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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::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_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; - pub const VT_NATIVE_INLINE: flatbuffers::VOffsetT = 106; - pub const VT_LONG_ENUM_NON_ENUM_DEFAULT: flatbuffers::VOffsetT = 108; - pub const VT_LONG_ENUM_NORMAL_DEFAULT: flatbuffers::VOffsetT = 110; - pub const VT_NAN_DEFAULT: flatbuffers::VOffsetT = 112; - pub const VT_INF_DEFAULT: flatbuffers::VOffsetT = 114; - pub const VT_POSITIVE_INF_DEFAULT: flatbuffers::VOffsetT = 116; - pub const VT_INFINITY_DEFAULT: flatbuffers::VOffsetT = 118; - pub const VT_POSITIVE_INFINITY_DEFAULT: flatbuffers::VOffsetT = 120; - pub const VT_NEGATIVE_INF_DEFAULT: flatbuffers::VOffsetT = 122; - pub const VT_NEGATIVE_INFINITY_DEFAULT: flatbuffers::VOffsetT = 124; - pub const VT_DOUBLE_INF_DEFAULT: flatbuffers::VOffsetT = 126; + 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; + pub const VT_NATIVE_INLINE: ::flatbuffers::VOffsetT = 106; + pub const VT_LONG_ENUM_NON_ENUM_DEFAULT: ::flatbuffers::VOffsetT = 108; + pub const VT_LONG_ENUM_NORMAL_DEFAULT: ::flatbuffers::VOffsetT = 110; + pub const VT_NAN_DEFAULT: ::flatbuffers::VOffsetT = 112; + pub const VT_INF_DEFAULT: ::flatbuffers::VOffsetT = 114; + pub const VT_POSITIVE_INF_DEFAULT: ::flatbuffers::VOffsetT = 116; + pub const VT_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 118; + pub const VT_POSITIVE_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 120; + pub const VT_NEGATIVE_INF_DEFAULT: ::flatbuffers::VOffsetT = 122; + pub const VT_NEGATIVE_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 124; + pub const VT_DOUBLE_INF_DEFAULT: ::flatbuffers::VOffsetT = 126; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.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> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = MonsterBuilder::new(_fbb); builder.add_double_inf_default(args.double_inf_default); builder.add_long_enum_normal_default(args.long_enum_normal_default); @@ -174,7 +167,7 @@ impl<'a> Monster<'a> { let hp = self.hp(); let name = { let x = self.name(); - x.to_string() + alloc::string::ToString::to_string(x) }; let inventory = self.inventory().map(|x| { x.into_iter().collect() @@ -182,17 +175,17 @@ impl<'a> Monster<'a> { let color = self.color(); let test = match self.test_type() { Any::NONE => AnyT::NONE, - Any::Monster => AnyT::Monster(Box::new( + Any::Monster => AnyT::Monster(alloc::boxed::Box::new( self.test_as_monster() .expect("Invalid union table, expected `Any::Monster`.") .unpack() )), - Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(Box::new( + Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(alloc::boxed::Box::new( self.test_as_test_simple_table_with_enum() .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.") .unpack() )), - Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(Box::new( + Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(alloc::boxed::Box::new( self.test_as_my_game_example_2_monster() .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.") .unpack() @@ -203,19 +196,19 @@ impl<'a> Monster<'a> { x.iter().map(|t| t.unpack()).collect() }); let testarrayofstring = self.testarrayofstring().map(|x| { - x.iter().map(|s| s.to_string()).collect() + x.iter().map(|s| alloc::string::ToString::to_string(s)).collect() }); let testarrayoftables = self.testarrayoftables().map(|x| { x.iter().map(|t| t.unpack()).collect() }); let enemy = self.enemy().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| { x.into_iter().collect() }); let testempty = self.testempty().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let testbool = self.testbool(); let testhashs32_fnv1 = self.testhashs32_fnv1(); @@ -233,7 +226,7 @@ impl<'a> Monster<'a> { let testf2 = self.testf2(); let testf3 = self.testf3(); let testarrayofstring2 = self.testarrayofstring2().map(|x| { - x.iter().map(|s| s.to_string()).collect() + x.iter().map(|s| alloc::string::ToString::to_string(s)).collect() }); let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| { x.iter().map(|t| t.unpack()).collect() @@ -251,7 +244,7 @@ impl<'a> Monster<'a> { x.into_iter().collect() }); let parent_namespace_test = self.parent_namespace_test().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let vector_of_referrables = self.vector_of_referrables().map(|x| { x.iter().map(|t| t.unpack()).collect() @@ -273,17 +266,17 @@ impl<'a> Monster<'a> { }); let any_unique = match self.any_unique_type() { AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE, - AnyUniqueAliases::M => AnyUniqueAliasesT::M(Box::new( + AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new( self.any_unique_as_m() .expect("Invalid union table, expected `AnyUniqueAliases::M`.") .unpack() )), - AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(Box::new( + AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(alloc::boxed::Box::new( self.any_unique_as_ts() .expect("Invalid union table, expected `AnyUniqueAliases::TS`.") .unpack() )), - AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(Box::new( + AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(alloc::boxed::Box::new( self.any_unique_as_m2() .expect("Invalid union table, expected `AnyUniqueAliases::M2`.") .unpack() @@ -292,17 +285,17 @@ impl<'a> Monster<'a> { }; let any_ambiguous = match self.any_ambiguous_type() { AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE, - AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(Box::new( + AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new( self.any_ambiguous_as_m1() .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.") .unpack() )), - AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(Box::new( + AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(alloc::boxed::Box::new( self.any_ambiguous_as_m2() .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.") .unpack() )), - AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(Box::new( + AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(alloc::boxed::Box::new( self.any_ambiguous_as_m3() .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.") .unpack() @@ -420,7 +413,7 @@ impl<'a> Monster<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_NAME, None).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()} } #[inline] pub fn key_compare_less_than(&self, o: &Monster) -> bool { @@ -433,11 +426,11 @@ impl<'a> Monster<'a> { key.cmp(val) } #[inline] - pub fn inventory(&self) -> Option> { + 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::>>(Monster::VT_INVENTORY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)} } #[inline] pub fn color(&self) -> Color { @@ -454,56 +447,56 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()} } #[inline] - pub fn test(&self) -> Option> { + pub fn test(&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::>>(Monster::VT_TEST, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)} } #[inline] - pub fn test4(&self) -> Option> { + pub fn test4(&self) -> Option<::flatbuffers::Vector<'a, Test>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TEST4, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)} } #[inline] - pub fn testarrayofstring(&self) -> Option>> { + pub fn testarrayofstring(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFSTRING, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING, None)} } /// an example documentation comment: this will end up in the generated code /// multiline too #[inline] - pub fn testarrayoftables(&self) -> Option>>> { + pub fn testarrayoftables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFTABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_TESTARRAYOFTABLES, None)} } #[inline] pub fn enemy(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_ENEMY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_ENEMY, None)} } #[inline] - pub fn testnestedflatbuffer(&self) -> Option> { + pub fn testnestedflatbuffer(&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::>>(Monster::VT_TESTNESTEDFLATBUFFER, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)} } pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option> { self.testnestedflatbuffer().map(|data| { - use flatbuffers::Follow; + use ::flatbuffers::Follow; // Safety: // Created from a valid Table for this object // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } + unsafe { <::flatbuffers::ForwardsUOffset>>::follow(data.bytes(), 0) } }) } #[inline] @@ -511,7 +504,7 @@ impl<'a> Monster<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_TESTEMPTY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_TESTEMPTY, None)} } #[inline] pub fn testbool(&self) -> bool { @@ -577,11 +570,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()} } #[inline] - pub fn testarrayofbools(&self) -> Option> { + pub fn testarrayofbools(&self) -> Option<::flatbuffers::Vector<'a, bool>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TESTARRAYOFBOOLS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)} } #[inline] pub fn testf(&self) -> f32 { @@ -605,60 +598,60 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TESTF3, Some(0.0)).unwrap()} } #[inline] - pub fn testarrayofstring2(&self) -> Option>> { + pub fn testarrayofstring2(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFSTRING2, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)} } #[inline] - pub fn testarrayofsortedstruct(&self) -> Option> { + pub fn testarrayofsortedstruct(&self) -> Option<::flatbuffers::Vector<'a, Ability>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)} } #[inline] - pub fn flex(&self) -> Option> { + pub fn flex(&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::>>(Monster::VT_FLEX, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)} } #[inline] - pub fn test5(&self) -> Option> { + pub fn test5(&self) -> Option<::flatbuffers::Vector<'a, Test>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TEST5, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)} } #[inline] - pub fn vector_of_longs(&self) -> Option> { + pub fn vector_of_longs(&self) -> Option<::flatbuffers::Vector<'a, i64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_LONGS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)} } #[inline] - pub fn vector_of_doubles(&self) -> Option> { + pub fn vector_of_doubles(&self) -> Option<::flatbuffers::Vector<'a, f64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_DOUBLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)} } #[inline] pub fn parent_namespace_test(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_PARENT_NAMESPACE_TEST, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_PARENT_NAMESPACE_TEST, None)} } #[inline] - pub fn vector_of_referrables(&self) -> Option>>> { + pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)} } #[inline] pub fn single_weak_reference(&self) -> u64 { @@ -668,18 +661,18 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_weak_references(&self) -> Option> { + pub fn vector_of_weak_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)} } #[inline] - pub fn vector_of_strong_referrables(&self) -> Option>>> { + pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)} } #[inline] pub fn co_owning_reference(&self) -> u64 { @@ -689,11 +682,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_co_owning_references(&self) -> Option> { + pub fn vector_of_co_owning_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)} } #[inline] pub fn non_owning_reference(&self) -> u64 { @@ -703,11 +696,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_non_owning_references(&self) -> Option> { + pub fn vector_of_non_owning_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)} } #[inline] pub fn any_unique_type(&self) -> AnyUniqueAliases { @@ -717,11 +710,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()} } #[inline] - pub fn any_unique(&self) -> Option> { + pub fn any_unique(&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::>>(Monster::VT_ANY_UNIQUE, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)} } #[inline] pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases { @@ -731,18 +724,18 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()} } #[inline] - pub fn any_ambiguous(&self) -> Option> { + pub fn any_ambiguous(&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::>>(Monster::VT_ANY_AMBIGUOUS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)} } #[inline] - pub fn vector_of_enums(&self) -> Option> { + pub fn vector_of_enums(&self) -> Option<::flatbuffers::Vector<'a, Color>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_ENUMS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)} } #[inline] pub fn signed_enum(&self) -> Race { @@ -752,27 +745,27 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()} } #[inline] - pub fn testrequirednestedflatbuffer(&self) -> Option> { + pub fn testrequirednestedflatbuffer(&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::>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)} } pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option> { self.testrequirednestedflatbuffer().map(|data| { - use flatbuffers::Follow; + use ::flatbuffers::Follow; // Safety: // Created from a valid Table for this object // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } + unsafe { <::flatbuffers::ForwardsUOffset>>::follow(data.bytes(), 0) } }) } #[inline] - pub fn scalar_key_sorted_tables(&self) -> Option>>> { + pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)} } #[inline] pub fn native_inline(&self) -> Option<&'a Test> { @@ -988,33 +981,32 @@ 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::("pos", Self::VT_POS, false)? .visit_field::("mana", Self::VT_MANA, false)? .visit_field::("hp", Self::VT_HP, false)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>>("inventory", Self::VT_INVENTORY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)? .visit_field::("color", Self::VT_COLOR, false)? .visit_union::("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| { match key { - Any::Monster => v.verify_union_variant::>("Any::Monster", pos), - Any::TestSimpleTableWithEnum => v.verify_union_variant::>("Any::TestSimpleTableWithEnum", pos), - Any::MyGame_Example2_Monster => v.verify_union_variant::>("Any::MyGame_Example2_Monster", pos), + Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::Monster", pos), + Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::TestSimpleTableWithEnum", pos), + Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::MyGame_Example2_Monster", pos), _ => Ok(()), } })? - .visit_field::>>("test4", Self::VT_TEST4, false)? - .visit_field::>>>("testarrayofstring", Self::VT_TESTARRAYOFSTRING, false)? - .visit_field::>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)? - .visit_field::>("enemy", Self::VT_ENEMY, false)? - .visit_field::>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)? - .visit_field::>("testempty", Self::VT_TESTEMPTY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Test>>>("test4", Self::VT_TEST4, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring", Self::VT_TESTARRAYOFSTRING, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("enemy", Self::VT_ENEMY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("testempty", Self::VT_TESTEMPTY, false)? .visit_field::("testbool", Self::VT_TESTBOOL, false)? .visit_field::("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)? .visit_field::("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)? @@ -1024,45 +1016,45 @@ impl flatbuffers::Verifiable for Monster<'_> { .visit_field::("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)? .visit_field::("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)? .visit_field::("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)? - .visit_field::>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)? .visit_field::("testf", Self::VT_TESTF, false)? .visit_field::("testf2", Self::VT_TESTF2, false)? .visit_field::("testf3", Self::VT_TESTF3, false)? - .visit_field::>>>("testarrayofstring2", Self::VT_TESTARRAYOFSTRING2, false)? - .visit_field::>>("testarrayofsortedstruct", Self::VT_TESTARRAYOFSORTEDSTRUCT, false)? - .visit_field::>>("flex", Self::VT_FLEX, false)? - .visit_field::>>("test5", Self::VT_TEST5, false)? - .visit_field::>>("vector_of_longs", Self::VT_VECTOR_OF_LONGS, false)? - .visit_field::>>("vector_of_doubles", Self::VT_VECTOR_OF_DOUBLES, false)? - .visit_field::>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)? - .visit_field::>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring2", Self::VT_TESTARRAYOFSTRING2, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Ability>>>("testarrayofsortedstruct", Self::VT_TESTARRAYOFSORTEDSTRUCT, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("flex", Self::VT_FLEX, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Test>>>("test5", Self::VT_TEST5, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i64>>>("vector_of_longs", Self::VT_VECTOR_OF_LONGS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, f64>>>("vector_of_doubles", Self::VT_VECTOR_OF_DOUBLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)? .visit_field::("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, false)? - .visit_field::>>("vector_of_weak_references", Self::VT_VECTOR_OF_WEAK_REFERENCES, false)? - .visit_field::>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_weak_references", Self::VT_VECTOR_OF_WEAK_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)? .visit_field::("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)? - .visit_field::>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)? .visit_field::("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)? - .visit_field::>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)? .visit_union::("any_unique_type", Self::VT_ANY_UNIQUE_TYPE, "any_unique", Self::VT_ANY_UNIQUE, false, |key, v, pos| { match key { - AnyUniqueAliases::M => v.verify_union_variant::>("AnyUniqueAliases::M", pos), - AnyUniqueAliases::TS => v.verify_union_variant::>("AnyUniqueAliases::TS", pos), - AnyUniqueAliases::M2 => v.verify_union_variant::>("AnyUniqueAliases::M2", pos), + AnyUniqueAliases::M => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::M", pos), + AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::TS", pos), + AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::M2", pos), _ => Ok(()), } })? .visit_union::("any_ambiguous_type", Self::VT_ANY_AMBIGUOUS_TYPE, "any_ambiguous", Self::VT_ANY_AMBIGUOUS, false, |key, v, pos| { match key { - AnyAmbiguousAliases::M1 => v.verify_union_variant::>("AnyAmbiguousAliases::M1", pos), - AnyAmbiguousAliases::M2 => v.verify_union_variant::>("AnyAmbiguousAliases::M2", pos), - AnyAmbiguousAliases::M3 => v.verify_union_variant::>("AnyAmbiguousAliases::M3", pos), + AnyAmbiguousAliases::M1 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M1", pos), + AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M2", pos), + AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M3", pos), _ => Ok(()), } })? - .visit_field::>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)? .visit_field::("signed_enum", Self::VT_SIGNED_ENUM, false)? - .visit_field::>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)? - .visit_field::>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)? .visit_field::("native_inline", Self::VT_NATIVE_INLINE, false)? .visit_field::("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)? .visit_field::("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)? @@ -1082,17 +1074,17 @@ pub struct MonsterArgs<'a> { pub pos: Option<&'a Vec3>, pub mana: i16, pub hp: i16, - pub name: Option>, - pub inventory: Option>>, + pub name: Option<::flatbuffers::WIPOffset<&'a str>>, + pub inventory: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, pub color: Color, pub test_type: Any, - pub test: Option>, - pub test4: Option>>, - pub testarrayofstring: Option>>>, - pub testarrayoftables: Option>>>>, - pub enemy: Option>>, - pub testnestedflatbuffer: Option>>, - pub testempty: Option>>, + pub test: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub test4: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Test>>>, + pub testarrayofstring: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, + pub testarrayoftables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, + pub enemy: Option<::flatbuffers::WIPOffset>>, + pub testnestedflatbuffer: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub testempty: Option<::flatbuffers::WIPOffset>>, pub testbool: bool, pub testhashs32_fnv1: i32, pub testhashu32_fnv1: u32, @@ -1102,33 +1094,33 @@ pub struct MonsterArgs<'a> { pub testhashu32_fnv1a: u32, pub testhashs64_fnv1a: i64, pub testhashu64_fnv1a: u64, - pub testarrayofbools: Option>>, + pub testarrayofbools: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, bool>>>, pub testf: f32, pub testf2: f32, pub testf3: f32, - pub testarrayofstring2: Option>>>, - pub testarrayofsortedstruct: Option>>, - pub flex: Option>>, - pub test5: Option>>, - pub vector_of_longs: Option>>, - pub vector_of_doubles: Option>>, - pub parent_namespace_test: Option>>, - pub vector_of_referrables: Option>>>>, + pub testarrayofstring2: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, + pub testarrayofsortedstruct: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Ability>>>, + pub flex: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub test5: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Test>>>, + pub vector_of_longs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i64>>>, + pub vector_of_doubles: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>, + pub parent_namespace_test: Option<::flatbuffers::WIPOffset>>, + pub vector_of_referrables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub single_weak_reference: u64, - pub vector_of_weak_references: Option>>, - pub vector_of_strong_referrables: Option>>>>, + pub vector_of_weak_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, + pub vector_of_strong_referrables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub co_owning_reference: u64, - pub vector_of_co_owning_references: Option>>, + pub vector_of_co_owning_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, pub non_owning_reference: u64, - pub vector_of_non_owning_references: Option>>, + pub vector_of_non_owning_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, pub any_unique_type: AnyUniqueAliases, - pub any_unique: Option>, + pub any_unique: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, pub any_ambiguous_type: AnyAmbiguousAliases, - pub any_ambiguous: Option>, - pub vector_of_enums: Option>>, + pub any_ambiguous: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub vector_of_enums: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Color>>>, pub signed_enum: Race, - pub testrequirednestedflatbuffer: Option>>, - pub scalar_key_sorted_tables: Option>>>>, + pub testrequirednestedflatbuffer: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub scalar_key_sorted_tables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub native_inline: Option<&'a Test>, pub long_enum_non_enum_default: LongEnum, pub long_enum_normal_default: LongEnum, @@ -1210,11 +1202,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, +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); @@ -1228,12 +1220,12 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_HP, hp, 100); } #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(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>) { - self.fbb_.push_slot_always::>(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) { @@ -1244,32 +1236,32 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TEST_TYPE, test_type, Any::NONE); } #[inline] - pub fn add_test(&mut self, test: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_TEST, test); + pub fn add_test(&mut self, test: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST, test); } #[inline] - pub fn add_test4(&mut self, test4: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TEST4, test4); + pub fn add_test4(&mut self, test4: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Test>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST4, test4); } #[inline] - pub fn add_testarrayofstring(&mut self, testarrayofstring: flatbuffers::WIPOffset>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSTRING, testarrayofstring); + pub fn add_testarrayofstring(&mut self, testarrayofstring: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSTRING, testarrayofstring); } #[inline] - pub fn add_testarrayoftables(&mut self, testarrayoftables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables); + pub fn add_testarrayoftables(&mut self, testarrayoftables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables); } #[inline] - pub fn add_enemy(&mut self, enemy: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_ENEMY, enemy); + pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_ENEMY, enemy); } #[inline] - pub fn add_testnestedflatbuffer(&mut self, testnestedflatbuffer: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer); + pub fn add_testnestedflatbuffer(&mut self, testnestedflatbuffer: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer); } #[inline] - pub fn add_testempty(&mut self, testempty: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTEMPTY, testempty); + pub fn add_testempty(&mut self, testempty: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_TESTEMPTY, testempty); } #[inline] pub fn add_testbool(&mut self, testbool: bool) { @@ -1308,8 +1300,8 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0); } #[inline] - pub fn add_testarrayofbools(&mut self, testarrayofbools: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools); + pub fn add_testarrayofbools(&mut self, testarrayofbools: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , bool>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools); } #[inline] pub fn add_testf(&mut self, testf: f32) { @@ -1324,96 +1316,96 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TESTF3, testf3, 0.0); } #[inline] - pub fn add_testarrayofstring2(&mut self, testarrayofstring2: flatbuffers::WIPOffset>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2); + pub fn add_testarrayofstring2(&mut self, testarrayofstring2: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2); } #[inline] - pub fn add_testarrayofsortedstruct(&mut self, testarrayofsortedstruct: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct); + pub fn add_testarrayofsortedstruct(&mut self, testarrayofsortedstruct: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Ability>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct); } #[inline] - pub fn add_flex(&mut self, flex: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_FLEX, flex); + pub fn add_flex(&mut self, flex: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_FLEX, flex); } #[inline] - pub fn add_test5(&mut self, test5: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TEST5, test5); + pub fn add_test5(&mut self, test5: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Test>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST5, test5); } #[inline] - pub fn add_vector_of_longs(&mut self, vector_of_longs: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_LONGS, vector_of_longs); + pub fn add_vector_of_longs(&mut self, vector_of_longs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_LONGS, vector_of_longs); } #[inline] - pub fn add_vector_of_doubles(&mut self, vector_of_doubles: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles); + pub fn add_vector_of_doubles(&mut self, vector_of_doubles: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , f64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles); } #[inline] - pub fn add_parent_namespace_test(&mut self, parent_namespace_test: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test); + pub fn add_parent_namespace_test(&mut self, parent_namespace_test: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test); } #[inline] - pub fn add_vector_of_referrables(&mut self, vector_of_referrables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables); + pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables); } #[inline] pub fn add_single_weak_reference(&mut self, single_weak_reference: u64) { self.fbb_.push_slot::(Monster::VT_SINGLE_WEAK_REFERENCE, single_weak_reference, 0); } #[inline] - pub fn add_vector_of_weak_references(&mut self, vector_of_weak_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references); + pub fn add_vector_of_weak_references(&mut self, vector_of_weak_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references); } #[inline] - pub fn add_vector_of_strong_referrables(&mut self, vector_of_strong_referrables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables); + pub fn add_vector_of_strong_referrables(&mut self, vector_of_strong_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables); } #[inline] pub fn add_co_owning_reference(&mut self, co_owning_reference: u64) { self.fbb_.push_slot::(Monster::VT_CO_OWNING_REFERENCE, co_owning_reference, 0); } #[inline] - pub fn add_vector_of_co_owning_references(&mut self, vector_of_co_owning_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references); + pub fn add_vector_of_co_owning_references(&mut self, vector_of_co_owning_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references); } #[inline] pub fn add_non_owning_reference(&mut self, non_owning_reference: u64) { self.fbb_.push_slot::(Monster::VT_NON_OWNING_REFERENCE, non_owning_reference, 0); } #[inline] - pub fn add_vector_of_non_owning_references(&mut self, vector_of_non_owning_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references); + pub fn add_vector_of_non_owning_references(&mut self, vector_of_non_owning_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references); } #[inline] pub fn add_any_unique_type(&mut self, any_unique_type: AnyUniqueAliases) { self.fbb_.push_slot::(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE); } #[inline] - pub fn add_any_unique(&mut self, any_unique: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_ANY_UNIQUE, any_unique); + pub fn add_any_unique(&mut self, any_unique: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_ANY_UNIQUE, any_unique); } #[inline] pub fn add_any_ambiguous_type(&mut self, any_ambiguous_type: AnyAmbiguousAliases) { self.fbb_.push_slot::(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE); } #[inline] - pub fn add_any_ambiguous(&mut self, any_ambiguous: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_ANY_AMBIGUOUS, any_ambiguous); + pub fn add_any_ambiguous(&mut self, any_ambiguous: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_ANY_AMBIGUOUS, any_ambiguous); } #[inline] - pub fn add_vector_of_enums(&mut self, vector_of_enums: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums); + pub fn add_vector_of_enums(&mut self, vector_of_enums: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Color>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums); } #[inline] pub fn add_signed_enum(&mut self, signed_enum: Race) { self.fbb_.push_slot::(Monster::VT_SIGNED_ENUM, signed_enum, Race::None); } #[inline] - pub fn add_testrequirednestedflatbuffer(&mut self, testrequirednestedflatbuffer: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer); + pub fn add_testrequirednestedflatbuffer(&mut self, testrequirednestedflatbuffer: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer); } #[inline] - pub fn add_scalar_key_sorted_tables(&mut self, scalar_key_sorted_tables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables); + pub fn add_scalar_key_sorted_tables(&mut self, scalar_key_sorted_tables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables); } #[inline] pub fn add_native_inline(&mut self, native_inline: &Test) { @@ -1460,7 +1452,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_DOUBLE_INF_DEFAULT, double_inf_default, f64::INFINITY); } #[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, @@ -1468,15 +1460,15 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); self.fbb_.required(o, Monster::VT_NAME,"name"); - 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()); @@ -1626,16 +1618,16 @@ pub struct MonsterT { pub pos: Option, pub mana: i16, pub hp: i16, - pub name: String, - pub inventory: Option>, + pub name: alloc::string::String, + pub inventory: Option>, pub color: Color, pub test: AnyT, - pub test4: Option>, - pub testarrayofstring: Option>, - pub testarrayoftables: Option>, - pub enemy: Option>, - pub testnestedflatbuffer: Option>, - pub testempty: Option>, + pub test4: Option>, + pub testarrayofstring: Option>, + pub testarrayoftables: Option>, + pub enemy: Option>, + pub testnestedflatbuffer: Option>, + pub testempty: Option>, pub testbool: bool, pub testhashs32_fnv1: i32, pub testhashu32_fnv1: u32, @@ -1645,31 +1637,31 @@ pub struct MonsterT { pub testhashu32_fnv1a: u32, pub testhashs64_fnv1a: i64, pub testhashu64_fnv1a: u64, - pub testarrayofbools: Option>, + pub testarrayofbools: Option>, pub testf: f32, pub testf2: f32, pub testf3: f32, - pub testarrayofstring2: Option>, - pub testarrayofsortedstruct: Option>, - pub flex: Option>, - pub test5: Option>, - pub vector_of_longs: Option>, - pub vector_of_doubles: Option>, - pub parent_namespace_test: Option>, - pub vector_of_referrables: Option>, + pub testarrayofstring2: Option>, + pub testarrayofsortedstruct: Option>, + pub flex: Option>, + pub test5: Option>, + pub vector_of_longs: Option>, + pub vector_of_doubles: Option>, + pub parent_namespace_test: Option>, + pub vector_of_referrables: Option>, pub single_weak_reference: u64, - pub vector_of_weak_references: Option>, - pub vector_of_strong_referrables: Option>, + pub vector_of_weak_references: Option>, + pub vector_of_strong_referrables: Option>, pub co_owning_reference: u64, - pub vector_of_co_owning_references: Option>, + pub vector_of_co_owning_references: Option>, pub non_owning_reference: u64, - pub vector_of_non_owning_references: Option>, + pub vector_of_non_owning_references: Option>, pub any_unique: AnyUniqueAliasesT, pub any_ambiguous: AnyAmbiguousAliasesT, - pub vector_of_enums: Option>, + pub vector_of_enums: Option>, pub signed_enum: Race, - pub testrequirednestedflatbuffer: Option>, - pub scalar_key_sorted_tables: Option>, + pub testrequirednestedflatbuffer: Option>, + pub scalar_key_sorted_tables: Option>, pub native_inline: Option, pub long_enum_non_enum_default: LongEnum, pub long_enum_normal_default: LongEnum, @@ -1688,7 +1680,7 @@ impl Default for MonsterT { pos: None, mana: 150, hp: 100, - name: "".to_string(), + name: alloc::string::ToString::to_string(""), inventory: None, color: Color::Blue, test: AnyT::NONE, @@ -1747,10 +1739,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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let pos_tmp = self.pos.as_ref().map(|x| x.pack()); let pos = pos_tmp.as_ref(); let mana = self.mana; @@ -1766,13 +1758,13 @@ impl MonsterT { let test_type = self.test.any_type(); let test = self.test.pack(_fbb); let test4 = self.test4.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) }); let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) }); let testarrayoftables = self.testarrayoftables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let enemy = self.enemy.as_ref().map(|x|{ x.pack(_fbb) @@ -1799,16 +1791,16 @@ impl MonsterT { let testf2 = self.testf2; let testf3 = self.testf3; let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) }); let testarrayofsortedstruct = self.testarrayofsortedstruct.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) }); let flex = self.flex.as_ref().map(|x|{ _fbb.create_vector(x) }); let test5 = self.test5.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) }); let vector_of_longs = self.vector_of_longs.as_ref().map(|x|{ _fbb.create_vector(x) @@ -1820,14 +1812,14 @@ impl MonsterT { x.pack(_fbb) }); let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let single_weak_reference = self.single_weak_reference; let vector_of_weak_references = self.vector_of_weak_references.as_ref().map(|x|{ _fbb.create_vector(x) }); let vector_of_strong_referrables = self.vector_of_strong_referrables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let co_owning_reference = self.co_owning_reference; let vector_of_co_owning_references = self.vector_of_co_owning_references.as_ref().map(|x|{ @@ -1849,7 +1841,7 @@ impl MonsterT { _fbb.create_vector(x) }); let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let native_inline_tmp = self.native_inline.as_ref().map(|x| x.pack()); let native_inline = native_inline_tmp.as_ref(); @@ -1935,8 +1927,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 { - flatbuffers::root::(buf) +pub fn root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -1945,8 +1937,8 @@ pub fn root_as_monster(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -1956,10 +1948,10 @@ pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -1969,47 +1961,47 @@ 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, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(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 { - flatbuffers::root_unchecked::(buf) + ::flatbuffers::root_unchecked::(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 { - flatbuffers::size_prefixed_root_unchecked::(buf) + ::flatbuffers::size_prefixed_root_unchecked::(buf) } pub const MONSTER_IDENTIFIER: &str = "MONS"; #[inline] pub fn monster_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, false) + ::flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, false) } #[inline] pub fn monster_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, true) + ::flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, true) } pub const MONSTER_EXTENSION: &str = "mon"; #[inline] -pub fn finish_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>) { +pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>) { fbb.finish(root, Some(MONSTER_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, Some(MONSTER_IDENTIFIER)); } diff --git a/tests/monster_test/my_game/example/race_generated.rs b/tests/monster_test/my_game/example/race_generated.rs index dd48b4e1eeb..1d7c4f6531d 100644 --- a/tests/monster_test/my_game/example/race_generated.rs +++ b/tests/monster_test/my_game/example/race_generated.rs @@ -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_RACE: i8 = -1; @@ -51,8 +44,8 @@ impl Race { } } } -impl core::fmt::Debug for Race { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Race { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -60,24 +53,24 @@ impl core::fmt::Debug for Race { } } } -impl<'a> flatbuffers::Follow<'a> for Race { +impl<'a> ::flatbuffers::Follow<'a> for Race { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for Race { +impl ::flatbuffers::Push for Race { type Output = Race; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for Race { +impl ::flatbuffers::EndianScalar for Race { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -91,14 +84,13 @@ impl flatbuffers::EndianScalar for Race { } } -impl<'a> flatbuffers::Verifiable for Race { +impl<'a> ::flatbuffers::Verifiable for Race { #[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 Race {} +impl ::flatbuffers::SimpleToVerifyInSlice for Race {} diff --git a/tests/monster_test/my_game/example/referrable_generated.rs b/tests/monster_test/my_game/example/referrable_generated.rs index 4932b35fe4d..364d3f5da43 100644 --- a/tests/monster_test/my_game/example/referrable_generated.rs +++ b/tests/monster_test/my_game/example/referrable_generated.rs @@ -1,45 +1,38 @@ // 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 ReferrableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Referrable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Referrable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Referrable<'a> { type Inner = Referrable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Referrable<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_ID: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.Referrable" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Referrable { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 ReferrableArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = ReferrableBuilder::new(_fbb); builder.add_id(args.id); builder.finish() @@ -71,12 +64,11 @@ impl<'a> Referrable<'a> { } } -impl flatbuffers::Verifiable for Referrable<'_> { +impl ::flatbuffers::Verifiable for Referrable<'_> { #[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::("id", Self::VT_ID, false)? .finish(); @@ -95,17 +87,17 @@ impl<'a> Default for ReferrableArgs { } } -pub struct ReferrableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct ReferrableBuilder<'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> ReferrableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ReferrableBuilder<'a, 'b, A> { #[inline] pub fn add_id(&mut self, id: u64) { self.fbb_.push_slot::(Referrable::VT_ID, id, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> { let start = _fbb.start_table(); ReferrableBuilder { fbb_: _fbb, @@ -113,14 +105,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ReferrableBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Referrable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Referrable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Referrable"); ds.field("id", &self.id()); ds.finish() @@ -139,10 +131,10 @@ impl Default for ReferrableT { } } impl ReferrableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let id = self.id; Referrable::create(_fbb, &ReferrableArgs{ id, diff --git a/tests/monster_test/my_game/example/stat_generated.rs b/tests/monster_test/my_game/example/stat_generated.rs index d94ff273549..0771a8da234 100644 --- a/tests/monster_test/my_game/example/stat_generated.rs +++ b/tests/monster_test/my_game/example/stat_generated.rs @@ -1,47 +1,40 @@ // 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 StatOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Stat<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Stat<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Stat<'a> { type Inner = Stat<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Stat<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_VAL: flatbuffers::VOffsetT = 6; - pub const VT_COUNT: flatbuffers::VOffsetT = 8; + pub const VT_ID: ::flatbuffers::VOffsetT = 4; + pub const VT_VAL: ::flatbuffers::VOffsetT = 6; + pub const VT_COUNT: ::flatbuffers::VOffsetT = 8; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.Stat" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Stat { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 StatArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = StatBuilder::new(_fbb); builder.add_val(args.val); if let Some(x) = args.id { builder.add_id(x); } @@ -51,7 +44,7 @@ impl<'a> Stat<'a> { pub fn unpack(&self) -> StatT { let id = self.id().map(|x| { - x.to_string() + alloc::string::ToString::to_string(x) }); let val = self.val(); let count = self.count(); @@ -67,7 +60,7 @@ impl<'a> Stat<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Stat::VT_ID, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)} } #[inline] pub fn val(&self) -> i64 { @@ -95,14 +88,13 @@ impl<'a> Stat<'a> { } } -impl flatbuffers::Verifiable for Stat<'_> { +impl ::flatbuffers::Verifiable for Stat<'_> { #[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::>("id", Self::VT_ID, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)? .visit_field::("val", Self::VT_VAL, false)? .visit_field::("count", Self::VT_COUNT, false)? .finish(); @@ -110,7 +102,7 @@ impl flatbuffers::Verifiable for Stat<'_> { } } pub struct StatArgs<'a> { - pub id: Option>, + pub id: Option<::flatbuffers::WIPOffset<&'a str>>, pub val: i64, pub count: u16, } @@ -125,14 +117,14 @@ impl<'a> Default for StatArgs<'a> { } } -pub struct StatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct StatBuilder<'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> StatBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { #[inline] - pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Stat::VT_ID, id); + pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Stat::VT_ID, id); } #[inline] pub fn add_val(&mut self, val: i64) { @@ -143,7 +135,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { self.fbb_.push_slot::(Stat::VT_COUNT, count, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> { let start = _fbb.start_table(); StatBuilder { fbb_: _fbb, @@ -151,14 +143,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Stat<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Stat<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Stat"); ds.field("id", &self.id()); ds.field("val", &self.val()); @@ -169,7 +161,7 @@ impl core::fmt::Debug for Stat<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct StatT { - pub id: Option, + pub id: Option, pub val: i64, pub count: u16, } @@ -183,10 +175,10 @@ impl Default for StatT { } } impl StatT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let id = self.id.as_ref().map(|x|{ _fbb.create_string(x) }); diff --git a/tests/monster_test/my_game/example/struct_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_generated.rs index 675a846cd70..d4037bb0d3c 100644 --- a/tests/monster_test/my_game/example/struct_of_structs_generated.rs +++ b/tests/monster_test/my_game/example/struct_of_structs_generated.rs @@ -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 StructOfStructs, aligned to 4 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for StructOfStructs { Self([0; 20]) } } -impl core::fmt::Debug for StructOfStructs { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for StructOfStructs { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("StructOfStructs") .field("a", &self.a()) .field("b", &self.b()) @@ -28,40 +21,40 @@ impl core::fmt::Debug for StructOfStructs { } } -impl flatbuffers::SimpleToVerifyInSlice for StructOfStructs {} -impl<'a> flatbuffers::Follow<'a> for StructOfStructs { +impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {} +impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs { type Inner = &'a StructOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a StructOfStructs>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructs { +impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructs { type Inner = &'a StructOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for StructOfStructs { +impl<'b> ::flatbuffers::Push for StructOfStructs { type Output = StructOfStructs; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, ::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 StructOfStructs { +impl<'a> ::flatbuffers::Verifiable for StructOfStructs { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } diff --git a/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs index 3eaa7055638..e906906ffc9 100644 --- a/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs +++ b/tests/monster_test/my_game/example/struct_of_structs_of_structs_generated.rs @@ -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 StructOfStructsOfStructs, aligned to 4 #[repr(transparent)] @@ -18,48 +11,48 @@ impl Default for StructOfStructsOfStructs { Self([0; 20]) } } -impl core::fmt::Debug for StructOfStructsOfStructs { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for StructOfStructsOfStructs { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("StructOfStructsOfStructs") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {} -impl<'a> flatbuffers::Follow<'a> for StructOfStructsOfStructs { +impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {} +impl<'a> ::flatbuffers::Follow<'a> for StructOfStructsOfStructs { type Inner = &'a StructOfStructsOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a StructOfStructsOfStructs>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs { +impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs { type Inner = &'a StructOfStructsOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for StructOfStructsOfStructs { +impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs { type Output = StructOfStructsOfStructs; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, ::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 StructOfStructsOfStructs { +impl<'a> ::flatbuffers::Verifiable for StructOfStructsOfStructs { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs index 65ef25031d3..434fd6009b3 100644 --- a/tests/monster_test/my_game/example/test_generated.rs +++ b/tests/monster_test/my_game/example/test_generated.rs @@ -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 Test, aligned to 2 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for Test { Self([0; 4]) } } -impl core::fmt::Debug for Test { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Test { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Test") .field("a", &self.a()) .field("b", &self.b()) @@ -27,40 +20,40 @@ impl core::fmt::Debug for Test { } } -impl flatbuffers::SimpleToVerifyInSlice for Test {} -impl<'a> flatbuffers::Follow<'a> for Test { +impl ::flatbuffers::SimpleToVerifyInSlice for Test {} +impl<'a> ::flatbuffers::Follow<'a> for Test { type Inner = &'a Test; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Test>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Test { +impl<'a> ::flatbuffers::Follow<'a> for &'a Test { type Inner = &'a Test; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Test { +impl<'b> ::flatbuffers::Push for Test { type Output = Test; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(2) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(2) } } -impl<'a> flatbuffers::Verifiable for Test { +impl<'a> ::flatbuffers::Verifiable for Test { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -82,59 +75,59 @@ impl<'a> Test { } pub fn a(&self) -> i16 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i16) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn b(&self) -> i8 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[2..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_b(&mut self, x: i8) { - 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[2..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs index daa5174408c..c3b23a47119 100644 --- a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs +++ b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs @@ -1,45 +1,38 @@ // 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 TestSimpleTableWithEnumOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TestSimpleTableWithEnum<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> { type Inner = TestSimpleTableWithEnum<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TestSimpleTableWithEnum<'a> { - pub const VT_COLOR: flatbuffers::VOffsetT = 4; + pub const VT_COLOR: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.TestSimpleTableWithEnum" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TestSimpleTableWithEnum { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TestSimpleTableWithEnumArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb); builder.add_color(args.color); builder.finish() @@ -61,12 +54,11 @@ impl<'a> TestSimpleTableWithEnum<'a> { } } -impl flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> { +impl ::flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> { #[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::("color", Self::VT_COLOR, false)? .finish(); @@ -85,17 +77,17 @@ impl<'a> Default for TestSimpleTableWithEnumArgs { } } -pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TestSimpleTableWithEnumBuilder<'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> TestSimpleTableWithEnumBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TestSimpleTableWithEnumBuilder<'a, 'b, A> { #[inline] pub fn add_color(&mut self, color: Color) { self.fbb_.push_slot::(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> { let start = _fbb.start_table(); TestSimpleTableWithEnumBuilder { fbb_: _fbb, @@ -103,14 +95,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TestSimpleTableWithEnumBuilder< } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TestSimpleTableWithEnum<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TestSimpleTableWithEnum<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TestSimpleTableWithEnum"); ds.field("color", &self.color()); ds.finish() @@ -129,10 +121,10 @@ impl Default for TestSimpleTableWithEnumT { } } impl TestSimpleTableWithEnumT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let color = self.color; TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{ color, diff --git a/tests/monster_test/my_game/example/type_aliases_generated.rs b/tests/monster_test/my_game/example/type_aliases_generated.rs index f813c25907e..57631e3e917 100644 --- a/tests/monster_test/my_game/example/type_aliases_generated.rs +++ b/tests/monster_test/my_game/example/type_aliases_generated.rs @@ -1,56 +1,49 @@ // 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 TypeAliasesOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TypeAliases<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TypeAliases<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TypeAliases<'a> { type Inner = TypeAliases<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TypeAliases<'a> { - 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; + 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; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.TypeAliases" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TypeAliases { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TypeAliasesArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TypeAliasesBuilder::new(_fbb); builder.add_f64_(args.f64_); builder.add_u64_(args.u64_); @@ -171,27 +164,26 @@ impl<'a> TypeAliases<'a> { unsafe { self._tab.get::(TypeAliases::VT_F64_, Some(0.0)).unwrap()} } #[inline] - pub fn v8(&self) -> Option> { + pub fn v8(&self) -> Option<::flatbuffers::Vector<'a, i8>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(TypeAliases::VT_V8, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)} } #[inline] - pub fn vf64(&self) -> Option> { + pub fn vf64(&self) -> Option<::flatbuffers::Vector<'a, f64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(TypeAliases::VT_VF64, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)} } } -impl flatbuffers::Verifiable for TypeAliases<'_> { +impl ::flatbuffers::Verifiable for TypeAliases<'_> { #[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::("i8_", Self::VT_I8_, false)? .visit_field::("u8_", Self::VT_U8_, false)? @@ -203,8 +195,8 @@ impl flatbuffers::Verifiable for TypeAliases<'_> { .visit_field::("u64_", Self::VT_U64_, false)? .visit_field::("f32_", Self::VT_F32_, false)? .visit_field::("f64_", Self::VT_F64_, false)? - .visit_field::>>("v8", Self::VT_V8, false)? - .visit_field::>>("vf64", Self::VT_VF64, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i8>>>("v8", Self::VT_V8, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, f64>>>("vf64", Self::VT_VF64, false)? .finish(); Ok(()) } @@ -220,8 +212,8 @@ pub struct TypeAliasesArgs<'a> { pub u64_: u64, pub f32_: f32, pub f64_: f64, - pub v8: Option>>, - pub vf64: Option>>, + pub v8: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>, + pub vf64: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>, } impl<'a> Default for TypeAliasesArgs<'a> { #[inline] @@ -243,11 +235,11 @@ impl<'a> Default for TypeAliasesArgs<'a> { } } -pub struct TypeAliasesBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TypeAliasesBuilder<'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> TypeAliasesBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { #[inline] pub fn add_i8_(&mut self, i8_: i8) { self.fbb_.push_slot::(TypeAliases::VT_I8_, i8_, 0); @@ -289,15 +281,15 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { self.fbb_.push_slot::(TypeAliases::VT_F64_, f64_, 0.0); } #[inline] - pub fn add_v8(&mut self, v8: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TypeAliases::VT_V8, v8); + pub fn add_v8(&mut self, v8: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(TypeAliases::VT_V8, v8); } #[inline] - pub fn add_vf64(&mut self, vf64: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TypeAliases::VT_VF64, vf64); + pub fn add_vf64(&mut self, vf64: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , f64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(TypeAliases::VT_VF64, vf64); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TypeAliasesBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TypeAliasesBuilder<'a, 'b, A> { let start = _fbb.start_table(); TypeAliasesBuilder { fbb_: _fbb, @@ -305,14 +297,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TypeAliases<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TypeAliases<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TypeAliases"); ds.field("i8_", &self.i8_()); ds.field("u8_", &self.u8_()); @@ -342,8 +334,8 @@ pub struct TypeAliasesT { pub u64_: u64, pub f32_: f32, pub f64_: f64, - pub v8: Option>, - pub vf64: Option>, + pub v8: Option>, + pub vf64: Option>, } impl Default for TypeAliasesT { fn default() -> Self { @@ -364,10 +356,10 @@ impl Default for TypeAliasesT { } } impl TypeAliasesT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let i8_ = self.i8_; let u8_ = self.u8_; let i16_ = self.i16_; diff --git a/tests/monster_test/my_game/example/vec_3_generated.rs b/tests/monster_test/my_game/example/vec_3_generated.rs index 8aebab50a2c..c9df4ad8666 100644 --- a/tests/monster_test/my_game/example/vec_3_generated.rs +++ b/tests/monster_test/my_game/example/vec_3_generated.rs @@ -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 8 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for Vec3 { Self([0; 32]) } } -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()) @@ -31,40 +24,40 @@ 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 { <&'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 { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(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 = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(8) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(8) } } -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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -94,146 +87,146 @@ impl<'a> Vec3 { } pub fn x(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn y(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn z(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn test1(&self) -> f64 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[16..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_test1(&mut self, x: f64) { - 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[16..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn test2(&self) -> Color { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[24..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_test2(&mut self, x: Color) { - 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[24..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test/my_game/example_2/monster_generated.rs b/tests/monster_test/my_game/example_2/monster_generated.rs index a0a138dc7a6..7107658bcde 100644 --- a/tests/monster_test/my_game/example_2/monster_generated.rs +++ b/tests/monster_test/my_game/example_2/monster_generated.rs @@ -1,26 +1,19 @@ // 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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> Monster<'a> { } #[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 - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = MonsterBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ 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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for MonsterArgs { } } -pub struct MonsterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +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 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, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { 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.finish() } @@ -107,10 +99,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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { Monster::create(_fbb, &MonsterArgs{ }) } diff --git a/tests/monster_test/my_game/in_parent_namespace_generated.rs b/tests/monster_test/my_game/in_parent_namespace_generated.rs index 5885714720b..40a2dd89a2c 100644 --- a/tests/monster_test/my_game/in_parent_namespace_generated.rs +++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs @@ -1,26 +1,19 @@ // 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 InParentNamespaceOffset {} #[derive(Copy, Clone, PartialEq)] pub struct InParentNamespace<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for InParentNamespace<'a> { +impl<'a> ::flatbuffers::Follow<'a> for InParentNamespace<'a> { type Inner = InParentNamespace<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> InParentNamespace<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe 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, 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 InParentNamespaceArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = InParentNamespaceBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ impl<'a> InParentNamespace<'a> { } } -impl flatbuffers::Verifiable for InParentNamespace<'_> { +impl ::flatbuffers::Verifiable for InParentNamespace<'_> { #[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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for InParentNamespaceArgs { } } -pub struct InParentNamespaceBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct InParentNamespaceBuilder<'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> InParentNamespaceBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> InParentNamespaceBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> { let start = _fbb.start_table(); InParentNamespaceBuilder { fbb_: _fbb, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> InParentNamespaceBuilder<'a, 'b } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for InParentNamespace<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for InParentNamespace<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("InParentNamespace"); ds.finish() } @@ -107,10 +99,10 @@ impl Default for InParentNamespaceT { } } impl InParentNamespaceT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { InParentNamespace::create(_fbb, &InParentNamespaceArgs{ }) } diff --git a/tests/monster_test/my_game/other_name_space/from_include_generated.rs b/tests/monster_test/my_game/other_name_space/from_include_generated.rs index 70cb407c1ea..5a7df08c76f 100644 --- a/tests/monster_test/my_game/other_name_space/from_include_generated.rs +++ b/tests/monster_test/my_game/other_name_space/from_include_generated.rs @@ -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_FROM_INCLUDE: i64 = 0; @@ -39,8 +32,8 @@ impl FromInclude { } } } -impl core::fmt::Debug for FromInclude { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for FromInclude { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -48,24 +41,24 @@ impl core::fmt::Debug for FromInclude { } } } -impl<'a> flatbuffers::Follow<'a> for FromInclude { +impl<'a> ::flatbuffers::Follow<'a> for FromInclude { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for FromInclude { +impl ::flatbuffers::Push for FromInclude { type Output = FromInclude; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for FromInclude { +impl ::flatbuffers::EndianScalar for FromInclude { type Scalar = i64; #[inline] fn to_little_endian(self) -> i64 { @@ -79,14 +72,13 @@ impl flatbuffers::EndianScalar for FromInclude { } } -impl<'a> flatbuffers::Verifiable for FromInclude { +impl<'a> ::flatbuffers::Verifiable for FromInclude { #[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> { i64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for FromInclude {} +impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {} diff --git a/tests/monster_test/my_game/other_name_space/table_b_generated.rs b/tests/monster_test/my_game/other_name_space/table_b_generated.rs index 84932cbc5ad..d318d36c236 100644 --- a/tests/monster_test/my_game/other_name_space/table_b_generated.rs +++ b/tests/monster_test/my_game/other_name_space/table_b_generated.rs @@ -1,45 +1,38 @@ // 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 TableBOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableB<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableB<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> { type Inner = TableB<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableB<'a> { - pub const VT_A: flatbuffers::VOffsetT = 4; + pub const VT_A: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.OtherNameSpace.TableB" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableB { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableBArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableBBuilder::new(_fbb); if let Some(x) = args.a { builder.add_a(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableB<'a> { pub fn unpack(&self) -> TableBT { let a = self.a().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableBT { a, @@ -59,24 +52,23 @@ impl<'a> TableB<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableB::VT_A, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableB::VT_A, None)} } } -impl flatbuffers::Verifiable for TableB<'_> { +impl ::flatbuffers::Verifiable for TableB<'_> { #[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::>("a", Self::VT_A, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("a", Self::VT_A, false)? .finish(); Ok(()) } } pub struct TableBArgs<'a> { - pub a: Option>>, + pub a: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableBArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableBArgs<'a> { } } -pub struct TableBBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableBBuilder<'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> TableBBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { #[inline] - pub fn add_a(&mut self, a: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableB::VT_A, a); + pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableB::VT_A, a); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableBBuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableB<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableB<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableB"); ds.field("a", &self.a()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableB<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableBT { - pub a: Option>, + pub a: Option>, } impl Default for TableBT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableBT { } } impl TableBT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let a = self.a.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/monster_test/my_game/other_name_space/unused_generated.rs b/tests/monster_test/my_game/other_name_space/unused_generated.rs index 11af62f073b..b16b39042b2 100644 --- a/tests/monster_test/my_game/other_name_space/unused_generated.rs +++ b/tests/monster_test/my_game/other_name_space/unused_generated.rs @@ -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 Unused, aligned to 4 #[repr(transparent)] @@ -18,48 +11,48 @@ impl Default for Unused { Self([0; 4]) } } -impl core::fmt::Debug for Unused { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Unused { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Unused") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for Unused {} -impl<'a> flatbuffers::Follow<'a> for Unused { +impl ::flatbuffers::SimpleToVerifyInSlice for Unused {} +impl<'a> ::flatbuffers::Follow<'a> for Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Unused>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Unused { +impl<'a> ::flatbuffers::Follow<'a> for &'a Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Unused { +impl<'b> ::flatbuffers::Push for Unused { type Output = Unused; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::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 Unused { +impl<'a> ::flatbuffers::Verifiable for Unused { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -79,30 +72,30 @@ impl<'a> Unused { } pub fn a(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs index 781a6c469db..e2d9356f828 100644 --- a/tests/monster_test/table_a_generated.rs +++ b/tests/monster_test/table_a_generated.rs @@ -1,45 +1,38 @@ // 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 TableAOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableA<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableA<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> { type Inner = TableA<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableA<'a> { - pub const VT_B: flatbuffers::VOffsetT = 4; + pub const VT_B: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "TableA" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableA { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableAArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableABuilder::new(_fbb); if let Some(x) = args.b { builder.add_b(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> TableA<'a> { pub fn unpack(&self) -> TableAT { let b = self.b().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableAT { b, @@ -59,24 +52,23 @@ impl<'a> TableA<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableA::VT_B, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableA::VT_B, None)} } } -impl flatbuffers::Verifiable for TableA<'_> { +impl ::flatbuffers::Verifiable for TableA<'_> { #[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::>("b", Self::VT_B, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("b", Self::VT_B, false)? .finish(); Ok(()) } } pub struct TableAArgs<'a> { - pub b: Option>>, + pub b: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableAArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for TableAArgs<'a> { } } -pub struct TableABuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableABuilder<'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> TableABuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { #[inline] - pub fn add_b(&mut self, b: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableA::VT_B, b); + pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableA::VT_B, b); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { let start = _fbb.start_table(); TableABuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableA<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableA<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableA"); ds.field("b", &self.b()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for TableA<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableAT { - pub b: Option>, + pub b: Option>, } impl Default for TableAT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for TableAT { } } impl TableAT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let b = self.b.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/monster_test_serialize/my_game/example/ability_generated.rs b/tests/monster_test_serialize/my_game/example/ability_generated.rs index 88f380206c1..d7e45dc75a9 100644 --- a/tests/monster_test_serialize/my_game/example/ability_generated.rs +++ b/tests/monster_test_serialize/my_game/example/ability_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct Ability, aligned to 4 #[repr(transparent)] @@ -20,8 +13,8 @@ impl Default for Ability { Self([0; 8]) } } -impl core::fmt::Debug for Ability { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Ability { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Ability") .field("id", &self.id()) .field("distance", &self.distance()) @@ -29,40 +22,40 @@ impl core::fmt::Debug for Ability { } } -impl flatbuffers::SimpleToVerifyInSlice for Ability {} -impl<'a> flatbuffers::Follow<'a> for Ability { +impl ::flatbuffers::SimpleToVerifyInSlice for Ability {} +impl<'a> ::flatbuffers::Follow<'a> for Ability { type Inner = &'a Ability; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Ability>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Ability { +impl<'a> ::flatbuffers::Follow<'a> for &'a Ability { type Inner = &'a Ability; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Ability { +impl<'b> ::flatbuffers::Push for Ability { type Output = Ability; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Ability as *const u8, ::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 Ability { +impl<'a> ::flatbuffers::Verifiable for Ability { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -96,30 +89,30 @@ impl<'a> Ability { } pub fn id(&self) -> u32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_id(&mut self, x: u32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } @@ -135,30 +128,30 @@ impl<'a> Ability { key.cmp(&val) } pub fn distance(&self) -> u32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_distance(&mut self, x: u32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs index a8e25b6b54d..590309f1fea 100644 --- a/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs +++ b/tests/monster_test_serialize/my_game/example/any_ambiguous_aliases_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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_ANY_AMBIGUOUS_ALIASES: u8 = 0; @@ -53,8 +46,8 @@ impl AnyAmbiguousAliases { } } } -impl core::fmt::Debug for AnyAmbiguousAliases { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for AnyAmbiguousAliases { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -71,24 +64,24 @@ impl Serialize for AnyAmbiguousAliases { } } -impl<'a> flatbuffers::Follow<'a> for AnyAmbiguousAliases { +impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for AnyAmbiguousAliases { +impl ::flatbuffers::Push for AnyAmbiguousAliases { type Output = AnyAmbiguousAliases; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for AnyAmbiguousAliases { +impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -102,17 +95,16 @@ impl flatbuffers::EndianScalar for AnyAmbiguousAliases { } } -impl<'a> flatbuffers::Verifiable for AnyAmbiguousAliases { +impl<'a> ::flatbuffers::Verifiable for AnyAmbiguousAliases { #[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 AnyAmbiguousAliases {} +impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {} pub struct AnyAmbiguousAliasesUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -120,9 +112,9 @@ pub struct AnyAmbiguousAliasesUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyAmbiguousAliasesT { NONE, - M1(Box), - M2(Box), - M3(Box), + M1(alloc::boxed::Box), + M2(alloc::boxed::Box), + M3(alloc::boxed::Box), } impl Default for AnyAmbiguousAliasesT { fn default() -> Self { @@ -138,7 +130,7 @@ impl AnyAmbiguousAliasesT { Self::M3(_) => AnyAmbiguousAliases::M3, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::M1(v) => Some(v.pack(fbb).as_union_value()), @@ -147,9 +139,9 @@ impl AnyAmbiguousAliasesT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m1(&mut self) -> Option> { + pub fn take_m1(&mut self) -> Option> { if let Self::M1(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M1(w) = v { Some(w) } else { @@ -168,9 +160,9 @@ impl AnyAmbiguousAliasesT { if let Self::M1(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m2(&mut self) -> Option> { + pub fn take_m2(&mut self) -> Option> { if let Self::M2(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M2(w) = v { Some(w) } else { @@ -189,9 +181,9 @@ impl AnyAmbiguousAliasesT { if let Self::M2(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m3(&mut self) -> Option> { + pub fn take_m3(&mut self) -> Option> { if let Self::M3(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M3(w) = v { Some(w) } else { diff --git a/tests/monster_test_serialize/my_game/example/any_generated.rs b/tests/monster_test_serialize/my_game/example/any_generated.rs index b4c49a3ce93..18318c11318 100644 --- a/tests/monster_test_serialize/my_game/example/any_generated.rs +++ b/tests/monster_test_serialize/my_game/example/any_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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_ANY: u8 = 0; @@ -53,8 +46,8 @@ impl Any { } } } -impl core::fmt::Debug for Any { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Any { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -71,24 +64,24 @@ impl Serialize for Any { } } -impl<'a> flatbuffers::Follow<'a> for Any { +impl<'a> ::flatbuffers::Follow<'a> for Any { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for Any { +impl ::flatbuffers::Push for Any { type Output = Any; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for Any { +impl ::flatbuffers::EndianScalar for Any { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -102,17 +95,16 @@ impl flatbuffers::EndianScalar for Any { } } -impl<'a> flatbuffers::Verifiable for Any { +impl<'a> ::flatbuffers::Verifiable for Any { #[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 Any {} +impl ::flatbuffers::SimpleToVerifyInSlice for Any {} pub struct AnyUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -120,9 +112,9 @@ pub struct AnyUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyT { NONE, - Monster(Box), - TestSimpleTableWithEnum(Box), - MyGameExample2Monster(Box), + Monster(alloc::boxed::Box), + TestSimpleTableWithEnum(alloc::boxed::Box), + MyGameExample2Monster(alloc::boxed::Box), } impl Default for AnyT { fn default() -> Self { @@ -138,7 +130,7 @@ impl AnyT { Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::Monster(v) => Some(v.pack(fbb).as_union_value()), @@ -147,9 +139,9 @@ impl AnyT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_monster(&mut self) -> Option> { + pub fn take_monster(&mut self) -> Option> { if let Self::Monster(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Monster(w) = v { Some(w) } else { @@ -168,9 +160,9 @@ impl AnyT { if let Self::Monster(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. - pub fn take_test_simple_table_with_enum(&mut self) -> Option> { + pub fn take_test_simple_table_with_enum(&mut self) -> Option> { if let Self::TestSimpleTableWithEnum(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::TestSimpleTableWithEnum(w) = v { Some(w) } else { @@ -189,9 +181,9 @@ impl AnyT { if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. - pub fn take_my_game_example_2_monster(&mut self) -> Option> { + pub fn take_my_game_example_2_monster(&mut self) -> Option> { if let Self::MyGameExample2Monster(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::MyGameExample2Monster(w) = v { Some(w) } else { diff --git a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs index 389cee9b433..7d652e7f9d1 100644 --- a/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs +++ b/tests/monster_test_serialize/my_game/example/any_unique_aliases_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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_ANY_UNIQUE_ALIASES: u8 = 0; @@ -53,8 +46,8 @@ impl AnyUniqueAliases { } } } -impl core::fmt::Debug for AnyUniqueAliases { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for AnyUniqueAliases { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -71,24 +64,24 @@ impl Serialize for AnyUniqueAliases { } } -impl<'a> flatbuffers::Follow<'a> for AnyUniqueAliases { +impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for AnyUniqueAliases { +impl ::flatbuffers::Push for AnyUniqueAliases { type Output = AnyUniqueAliases; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for AnyUniqueAliases { +impl ::flatbuffers::EndianScalar for AnyUniqueAliases { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -102,17 +95,16 @@ impl flatbuffers::EndianScalar for AnyUniqueAliases { } } -impl<'a> flatbuffers::Verifiable for AnyUniqueAliases { +impl<'a> ::flatbuffers::Verifiable for AnyUniqueAliases { #[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 AnyUniqueAliases {} +impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {} pub struct AnyUniqueAliasesUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -120,9 +112,9 @@ pub struct AnyUniqueAliasesUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum AnyUniqueAliasesT { NONE, - M(Box), - TS(Box), - M2(Box), + M(alloc::boxed::Box), + TS(alloc::boxed::Box), + M2(alloc::boxed::Box), } impl Default for AnyUniqueAliasesT { fn default() -> Self { @@ -138,7 +130,7 @@ impl AnyUniqueAliasesT { Self::M2(_) => AnyUniqueAliases::M2, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::M(v) => Some(v.pack(fbb).as_union_value()), @@ -147,9 +139,9 @@ impl AnyUniqueAliasesT { } } /// If the union variant matches, return the owned MonsterT, setting the union to NONE. - pub fn take_m(&mut self) -> Option> { + pub fn take_m(&mut self) -> Option> { if let Self::M(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M(w) = v { Some(w) } else { @@ -168,9 +160,9 @@ impl AnyUniqueAliasesT { if let Self::M(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE. - pub fn take_ts(&mut self) -> Option> { + pub fn take_ts(&mut self) -> Option> { if let Self::TS(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::TS(w) = v { Some(w) } else { @@ -189,9 +181,9 @@ impl AnyUniqueAliasesT { if let Self::TS(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE. - pub fn take_m2(&mut self) -> Option> { + pub fn take_m2(&mut self) -> Option> { if let Self::M2(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::M2(w) = v { Some(w) } else { diff --git a/tests/monster_test_serialize/my_game/example/color_generated.rs b/tests/monster_test_serialize/my_game/example/color_generated.rs index d6879de592c..d3abd738a85 100644 --- a/tests/monster_test_serialize/my_game/example/color_generated.rs +++ b/tests/monster_test_serialize/my_game/example/color_generated.rs @@ -1,19 +1,12 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[allow(non_upper_case_globals)] mod bitflags_color { - flatbuffers::bitflags::bitflags! { + ::flatbuffers::bitflags::bitflags! { /// Composite components of Monster color. #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct Color: u8 { @@ -37,24 +30,24 @@ impl Serialize 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 = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self::from_bits_retain(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) { - flatbuffers::emplace_scalar::(dst, self.bits()); + ::flatbuffers::emplace_scalar::(dst, self.bits()); } } -impl flatbuffers::EndianScalar for Color { +impl ::flatbuffers::EndianScalar for Color { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -68,14 +61,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> { u8::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for Color {} +impl ::flatbuffers::SimpleToVerifyInSlice for Color {} diff --git a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs index e588ae0e4af..e79f3665b20 100644 --- a/tests/monster_test_serialize/my_game/example/long_enum_generated.rs +++ b/tests/monster_test_serialize/my_game/example/long_enum_generated.rs @@ -1,19 +1,12 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; #[allow(non_upper_case_globals)] mod bitflags_long_enum { - flatbuffers::bitflags::bitflags! { + ::flatbuffers::bitflags::bitflags! { #[derive(Default, Debug, Clone, Copy, PartialEq)] pub struct LongEnum: u64 { const LongOne = 2; @@ -33,24 +26,24 @@ impl Serialize for LongEnum { } } -impl<'a> flatbuffers::Follow<'a> for LongEnum { +impl<'a> ::flatbuffers::Follow<'a> for LongEnum { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self::from_bits_retain(b) } } -impl flatbuffers::Push for LongEnum { +impl ::flatbuffers::Push for LongEnum { type Output = LongEnum; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.bits()); + ::flatbuffers::emplace_scalar::(dst, self.bits()); } } -impl flatbuffers::EndianScalar for LongEnum { +impl ::flatbuffers::EndianScalar for LongEnum { type Scalar = u64; #[inline] fn to_little_endian(self) -> u64 { @@ -64,14 +57,13 @@ impl flatbuffers::EndianScalar for LongEnum { } } -impl<'a> flatbuffers::Verifiable for LongEnum { +impl<'a> ::flatbuffers::Verifiable for LongEnum { #[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> { u64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for LongEnum {} +impl ::flatbuffers::SimpleToVerifyInSlice for LongEnum {} diff --git a/tests/monster_test_serialize/my_game/example/monster_generated.rs b/tests/monster_test_serialize/my_game/example/monster_generated.rs index 5457507dd6b..70ab5e8487d 100644 --- a/tests/monster_test_serialize/my_game/example/monster_generated.rs +++ b/tests/monster_test_serialize/my_game/example/monster_generated.rs @@ -1,108 +1,101 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum MonsterOffset {} #[derive(Copy, Clone, PartialEq)] /// an example documentation comment: "monster object" 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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::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_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; - pub const VT_NATIVE_INLINE: flatbuffers::VOffsetT = 106; - pub const VT_LONG_ENUM_NON_ENUM_DEFAULT: flatbuffers::VOffsetT = 108; - pub const VT_LONG_ENUM_NORMAL_DEFAULT: flatbuffers::VOffsetT = 110; - pub const VT_NAN_DEFAULT: flatbuffers::VOffsetT = 112; - pub const VT_INF_DEFAULT: flatbuffers::VOffsetT = 114; - pub const VT_POSITIVE_INF_DEFAULT: flatbuffers::VOffsetT = 116; - pub const VT_INFINITY_DEFAULT: flatbuffers::VOffsetT = 118; - pub const VT_POSITIVE_INFINITY_DEFAULT: flatbuffers::VOffsetT = 120; - pub const VT_NEGATIVE_INF_DEFAULT: flatbuffers::VOffsetT = 122; - pub const VT_NEGATIVE_INFINITY_DEFAULT: flatbuffers::VOffsetT = 124; - pub const VT_DOUBLE_INF_DEFAULT: flatbuffers::VOffsetT = 126; + 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; + pub const VT_NATIVE_INLINE: ::flatbuffers::VOffsetT = 106; + pub const VT_LONG_ENUM_NON_ENUM_DEFAULT: ::flatbuffers::VOffsetT = 108; + pub const VT_LONG_ENUM_NORMAL_DEFAULT: ::flatbuffers::VOffsetT = 110; + pub const VT_NAN_DEFAULT: ::flatbuffers::VOffsetT = 112; + pub const VT_INF_DEFAULT: ::flatbuffers::VOffsetT = 114; + pub const VT_POSITIVE_INF_DEFAULT: ::flatbuffers::VOffsetT = 116; + pub const VT_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 118; + pub const VT_POSITIVE_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 120; + pub const VT_NEGATIVE_INF_DEFAULT: ::flatbuffers::VOffsetT = 122; + pub const VT_NEGATIVE_INFINITY_DEFAULT: ::flatbuffers::VOffsetT = 124; + pub const VT_DOUBLE_INF_DEFAULT: ::flatbuffers::VOffsetT = 126; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.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> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = MonsterBuilder::new(_fbb); builder.add_double_inf_default(args.double_inf_default); builder.add_long_enum_normal_default(args.long_enum_normal_default); @@ -176,7 +169,7 @@ impl<'a> Monster<'a> { let hp = self.hp(); let name = { let x = self.name(); - x.to_string() + alloc::string::ToString::to_string(x) }; let inventory = self.inventory().map(|x| { x.into_iter().collect() @@ -184,17 +177,17 @@ impl<'a> Monster<'a> { let color = self.color(); let test = match self.test_type() { Any::NONE => AnyT::NONE, - Any::Monster => AnyT::Monster(Box::new( + Any::Monster => AnyT::Monster(alloc::boxed::Box::new( self.test_as_monster() .expect("Invalid union table, expected `Any::Monster`.") .unpack() )), - Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(Box::new( + Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(alloc::boxed::Box::new( self.test_as_test_simple_table_with_enum() .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.") .unpack() )), - Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(Box::new( + Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(alloc::boxed::Box::new( self.test_as_my_game_example_2_monster() .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.") .unpack() @@ -205,19 +198,19 @@ impl<'a> Monster<'a> { x.iter().map(|t| t.unpack()).collect() }); let testarrayofstring = self.testarrayofstring().map(|x| { - x.iter().map(|s| s.to_string()).collect() + x.iter().map(|s| alloc::string::ToString::to_string(s)).collect() }); let testarrayoftables = self.testarrayoftables().map(|x| { x.iter().map(|t| t.unpack()).collect() }); let enemy = self.enemy().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| { x.into_iter().collect() }); let testempty = self.testempty().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let testbool = self.testbool(); let testhashs32_fnv1 = self.testhashs32_fnv1(); @@ -235,7 +228,7 @@ impl<'a> Monster<'a> { let testf2 = self.testf2(); let testf3 = self.testf3(); let testarrayofstring2 = self.testarrayofstring2().map(|x| { - x.iter().map(|s| s.to_string()).collect() + x.iter().map(|s| alloc::string::ToString::to_string(s)).collect() }); let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| { x.iter().map(|t| t.unpack()).collect() @@ -253,7 +246,7 @@ impl<'a> Monster<'a> { x.into_iter().collect() }); let parent_namespace_test = self.parent_namespace_test().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let vector_of_referrables = self.vector_of_referrables().map(|x| { x.iter().map(|t| t.unpack()).collect() @@ -275,17 +268,17 @@ impl<'a> Monster<'a> { }); let any_unique = match self.any_unique_type() { AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE, - AnyUniqueAliases::M => AnyUniqueAliasesT::M(Box::new( + AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new( self.any_unique_as_m() .expect("Invalid union table, expected `AnyUniqueAliases::M`.") .unpack() )), - AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(Box::new( + AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(alloc::boxed::Box::new( self.any_unique_as_ts() .expect("Invalid union table, expected `AnyUniqueAliases::TS`.") .unpack() )), - AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(Box::new( + AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(alloc::boxed::Box::new( self.any_unique_as_m2() .expect("Invalid union table, expected `AnyUniqueAliases::M2`.") .unpack() @@ -294,17 +287,17 @@ impl<'a> Monster<'a> { }; let any_ambiguous = match self.any_ambiguous_type() { AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE, - AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(Box::new( + AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new( self.any_ambiguous_as_m1() .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.") .unpack() )), - AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(Box::new( + AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(alloc::boxed::Box::new( self.any_ambiguous_as_m2() .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.") .unpack() )), - AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(Box::new( + AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(alloc::boxed::Box::new( self.any_ambiguous_as_m3() .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.") .unpack() @@ -422,7 +415,7 @@ impl<'a> Monster<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_NAME, None).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()} } #[inline] pub fn key_compare_less_than(&self, o: &Monster) -> bool { @@ -435,11 +428,11 @@ impl<'a> Monster<'a> { key.cmp(val) } #[inline] - pub fn inventory(&self) -> Option> { + 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::>>(Monster::VT_INVENTORY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)} } #[inline] pub fn color(&self) -> Color { @@ -456,56 +449,56 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()} } #[inline] - pub fn test(&self) -> Option> { + pub fn test(&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::>>(Monster::VT_TEST, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)} } #[inline] - pub fn test4(&self) -> Option> { + pub fn test4(&self) -> Option<::flatbuffers::Vector<'a, Test>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TEST4, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)} } #[inline] - pub fn testarrayofstring(&self) -> Option>> { + pub fn testarrayofstring(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFSTRING, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING, None)} } /// an example documentation comment: this will end up in the generated code /// multiline too #[inline] - pub fn testarrayoftables(&self) -> Option>>> { + pub fn testarrayoftables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFTABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_TESTARRAYOFTABLES, None)} } #[inline] pub fn enemy(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_ENEMY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_ENEMY, None)} } #[inline] - pub fn testnestedflatbuffer(&self) -> Option> { + pub fn testnestedflatbuffer(&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::>>(Monster::VT_TESTNESTEDFLATBUFFER, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)} } pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option> { self.testnestedflatbuffer().map(|data| { - use flatbuffers::Follow; + use ::flatbuffers::Follow; // Safety: // Created from a valid Table for this object // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } + unsafe { <::flatbuffers::ForwardsUOffset>>::follow(data.bytes(), 0) } }) } #[inline] @@ -513,7 +506,7 @@ impl<'a> Monster<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_TESTEMPTY, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_TESTEMPTY, None)} } #[inline] pub fn testbool(&self) -> bool { @@ -579,11 +572,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()} } #[inline] - pub fn testarrayofbools(&self) -> Option> { + pub fn testarrayofbools(&self) -> Option<::flatbuffers::Vector<'a, bool>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TESTARRAYOFBOOLS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)} } #[inline] pub fn testf(&self) -> f32 { @@ -607,60 +600,60 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_TESTF3, Some(0.0)).unwrap()} } #[inline] - pub fn testarrayofstring2(&self) -> Option>> { + pub fn testarrayofstring2(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_TESTARRAYOFSTRING2, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)} } #[inline] - pub fn testarrayofsortedstruct(&self) -> Option> { + pub fn testarrayofsortedstruct(&self) -> Option<::flatbuffers::Vector<'a, Ability>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)} } #[inline] - pub fn flex(&self) -> Option> { + pub fn flex(&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::>>(Monster::VT_FLEX, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)} } #[inline] - pub fn test5(&self) -> Option> { + pub fn test5(&self) -> Option<::flatbuffers::Vector<'a, Test>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_TEST5, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)} } #[inline] - pub fn vector_of_longs(&self) -> Option> { + pub fn vector_of_longs(&self) -> Option<::flatbuffers::Vector<'a, i64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_LONGS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)} } #[inline] - pub fn vector_of_doubles(&self) -> Option> { + pub fn vector_of_doubles(&self) -> Option<::flatbuffers::Vector<'a, f64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_DOUBLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)} } #[inline] pub fn parent_namespace_test(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Monster::VT_PARENT_NAMESPACE_TEST, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(Monster::VT_PARENT_NAMESPACE_TEST, None)} } #[inline] - pub fn vector_of_referrables(&self) -> Option>>> { + pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)} } #[inline] pub fn single_weak_reference(&self) -> u64 { @@ -670,18 +663,18 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_weak_references(&self) -> Option> { + pub fn vector_of_weak_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)} } #[inline] - pub fn vector_of_strong_referrables(&self) -> Option>>> { + pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)} } #[inline] pub fn co_owning_reference(&self) -> u64 { @@ -691,11 +684,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_co_owning_references(&self) -> Option> { + pub fn vector_of_co_owning_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)} } #[inline] pub fn non_owning_reference(&self) -> u64 { @@ -705,11 +698,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()} } #[inline] - pub fn vector_of_non_owning_references(&self) -> Option> { + pub fn vector_of_non_owning_references(&self) -> Option<::flatbuffers::Vector<'a, u64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)} } #[inline] pub fn any_unique_type(&self) -> AnyUniqueAliases { @@ -719,11 +712,11 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()} } #[inline] - pub fn any_unique(&self) -> Option> { + pub fn any_unique(&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::>>(Monster::VT_ANY_UNIQUE, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)} } #[inline] pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases { @@ -733,18 +726,18 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()} } #[inline] - pub fn any_ambiguous(&self) -> Option> { + pub fn any_ambiguous(&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::>>(Monster::VT_ANY_AMBIGUOUS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)} } #[inline] - pub fn vector_of_enums(&self) -> Option> { + pub fn vector_of_enums(&self) -> Option<::flatbuffers::Vector<'a, Color>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(Monster::VT_VECTOR_OF_ENUMS, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)} } #[inline] pub fn signed_enum(&self) -> Race { @@ -754,27 +747,27 @@ impl<'a> Monster<'a> { unsafe { self._tab.get::(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()} } #[inline] - pub fn testrequirednestedflatbuffer(&self) -> Option> { + pub fn testrequirednestedflatbuffer(&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::>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)} } pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option> { self.testrequirednestedflatbuffer().map(|data| { - use flatbuffers::Follow; + use ::flatbuffers::Follow; // Safety: // Created from a valid Table for this object // Which contains a valid flatbuffer in this slot - unsafe { >>::follow(data.bytes(), 0) } + unsafe { <::flatbuffers::ForwardsUOffset>>::follow(data.bytes(), 0) } }) } #[inline] - pub fn scalar_key_sorted_tables(&self) -> Option>>> { + pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)} } #[inline] pub fn native_inline(&self) -> Option<&'a Test> { @@ -990,33 +983,32 @@ 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::("pos", Self::VT_POS, false)? .visit_field::("mana", Self::VT_MANA, false)? .visit_field::("hp", Self::VT_HP, false)? - .visit_field::>("name", Self::VT_NAME, true)? - .visit_field::>>("inventory", Self::VT_INVENTORY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)? .visit_field::("color", Self::VT_COLOR, false)? .visit_union::("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| { match key { - Any::Monster => v.verify_union_variant::>("Any::Monster", pos), - Any::TestSimpleTableWithEnum => v.verify_union_variant::>("Any::TestSimpleTableWithEnum", pos), - Any::MyGame_Example2_Monster => v.verify_union_variant::>("Any::MyGame_Example2_Monster", pos), + Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::Monster", pos), + Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::TestSimpleTableWithEnum", pos), + Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("Any::MyGame_Example2_Monster", pos), _ => Ok(()), } })? - .visit_field::>>("test4", Self::VT_TEST4, false)? - .visit_field::>>>("testarrayofstring", Self::VT_TESTARRAYOFSTRING, false)? - .visit_field::>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)? - .visit_field::>("enemy", Self::VT_ENEMY, false)? - .visit_field::>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)? - .visit_field::>("testempty", Self::VT_TESTEMPTY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Test>>>("test4", Self::VT_TEST4, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring", Self::VT_TESTARRAYOFSTRING, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("enemy", Self::VT_ENEMY, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("testempty", Self::VT_TESTEMPTY, false)? .visit_field::("testbool", Self::VT_TESTBOOL, false)? .visit_field::("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)? .visit_field::("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)? @@ -1026,45 +1018,45 @@ impl flatbuffers::Verifiable for Monster<'_> { .visit_field::("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)? .visit_field::("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)? .visit_field::("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)? - .visit_field::>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)? .visit_field::("testf", Self::VT_TESTF, false)? .visit_field::("testf2", Self::VT_TESTF2, false)? .visit_field::("testf3", Self::VT_TESTF3, false)? - .visit_field::>>>("testarrayofstring2", Self::VT_TESTARRAYOFSTRING2, false)? - .visit_field::>>("testarrayofsortedstruct", Self::VT_TESTARRAYOFSORTEDSTRUCT, false)? - .visit_field::>>("flex", Self::VT_FLEX, false)? - .visit_field::>>("test5", Self::VT_TEST5, false)? - .visit_field::>>("vector_of_longs", Self::VT_VECTOR_OF_LONGS, false)? - .visit_field::>>("vector_of_doubles", Self::VT_VECTOR_OF_DOUBLES, false)? - .visit_field::>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)? - .visit_field::>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring2", Self::VT_TESTARRAYOFSTRING2, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Ability>>>("testarrayofsortedstruct", Self::VT_TESTARRAYOFSORTEDSTRUCT, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("flex", Self::VT_FLEX, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Test>>>("test5", Self::VT_TEST5, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i64>>>("vector_of_longs", Self::VT_VECTOR_OF_LONGS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, f64>>>("vector_of_doubles", Self::VT_VECTOR_OF_DOUBLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)? .visit_field::("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, false)? - .visit_field::>>("vector_of_weak_references", Self::VT_VECTOR_OF_WEAK_REFERENCES, false)? - .visit_field::>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_weak_references", Self::VT_VECTOR_OF_WEAK_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)? .visit_field::("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)? - .visit_field::>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)? .visit_field::("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)? - .visit_field::>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)? .visit_union::("any_unique_type", Self::VT_ANY_UNIQUE_TYPE, "any_unique", Self::VT_ANY_UNIQUE, false, |key, v, pos| { match key { - AnyUniqueAliases::M => v.verify_union_variant::>("AnyUniqueAliases::M", pos), - AnyUniqueAliases::TS => v.verify_union_variant::>("AnyUniqueAliases::TS", pos), - AnyUniqueAliases::M2 => v.verify_union_variant::>("AnyUniqueAliases::M2", pos), + AnyUniqueAliases::M => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::M", pos), + AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::TS", pos), + AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyUniqueAliases::M2", pos), _ => Ok(()), } })? .visit_union::("any_ambiguous_type", Self::VT_ANY_AMBIGUOUS_TYPE, "any_ambiguous", Self::VT_ANY_AMBIGUOUS, false, |key, v, pos| { match key { - AnyAmbiguousAliases::M1 => v.verify_union_variant::>("AnyAmbiguousAliases::M1", pos), - AnyAmbiguousAliases::M2 => v.verify_union_variant::>("AnyAmbiguousAliases::M2", pos), - AnyAmbiguousAliases::M3 => v.verify_union_variant::>("AnyAmbiguousAliases::M3", pos), + AnyAmbiguousAliases::M1 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M1", pos), + AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M2", pos), + AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("AnyAmbiguousAliases::M3", pos), _ => Ok(()), } })? - .visit_field::>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)? .visit_field::("signed_enum", Self::VT_SIGNED_ENUM, false)? - .visit_field::>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)? - .visit_field::>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)? .visit_field::("native_inline", Self::VT_NATIVE_INLINE, false)? .visit_field::("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)? .visit_field::("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)? @@ -1084,17 +1076,17 @@ pub struct MonsterArgs<'a> { pub pos: Option<&'a Vec3>, pub mana: i16, pub hp: i16, - pub name: Option>, - pub inventory: Option>>, + pub name: Option<::flatbuffers::WIPOffset<&'a str>>, + pub inventory: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, pub color: Color, pub test_type: Any, - pub test: Option>, - pub test4: Option>>, - pub testarrayofstring: Option>>>, - pub testarrayoftables: Option>>>>, - pub enemy: Option>>, - pub testnestedflatbuffer: Option>>, - pub testempty: Option>>, + pub test: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub test4: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Test>>>, + pub testarrayofstring: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, + pub testarrayoftables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, + pub enemy: Option<::flatbuffers::WIPOffset>>, + pub testnestedflatbuffer: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub testempty: Option<::flatbuffers::WIPOffset>>, pub testbool: bool, pub testhashs32_fnv1: i32, pub testhashu32_fnv1: u32, @@ -1104,33 +1096,33 @@ pub struct MonsterArgs<'a> { pub testhashu32_fnv1a: u32, pub testhashs64_fnv1a: i64, pub testhashu64_fnv1a: u64, - pub testarrayofbools: Option>>, + pub testarrayofbools: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, bool>>>, pub testf: f32, pub testf2: f32, pub testf3: f32, - pub testarrayofstring2: Option>>>, - pub testarrayofsortedstruct: Option>>, - pub flex: Option>>, - pub test5: Option>>, - pub vector_of_longs: Option>>, - pub vector_of_doubles: Option>>, - pub parent_namespace_test: Option>>, - pub vector_of_referrables: Option>>>>, + pub testarrayofstring2: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>, + pub testarrayofsortedstruct: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Ability>>>, + pub flex: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub test5: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Test>>>, + pub vector_of_longs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i64>>>, + pub vector_of_doubles: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>, + pub parent_namespace_test: Option<::flatbuffers::WIPOffset>>, + pub vector_of_referrables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub single_weak_reference: u64, - pub vector_of_weak_references: Option>>, - pub vector_of_strong_referrables: Option>>>>, + pub vector_of_weak_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, + pub vector_of_strong_referrables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub co_owning_reference: u64, - pub vector_of_co_owning_references: Option>>, + pub vector_of_co_owning_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, pub non_owning_reference: u64, - pub vector_of_non_owning_references: Option>>, + pub vector_of_non_owning_references: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u64>>>, pub any_unique_type: AnyUniqueAliases, - pub any_unique: Option>, + pub any_unique: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, pub any_ambiguous_type: AnyAmbiguousAliases, - pub any_ambiguous: Option>, - pub vector_of_enums: Option>>, + pub any_ambiguous: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, + pub vector_of_enums: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Color>>>, pub signed_enum: Race, - pub testrequirednestedflatbuffer: Option>>, - pub scalar_key_sorted_tables: Option>>>>, + pub testrequirednestedflatbuffer: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, u8>>>, + pub scalar_key_sorted_tables: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset>>>>, pub native_inline: Option<&'a Test>, pub long_enum_non_enum_default: LongEnum, pub long_enum_normal_default: LongEnum, @@ -1437,11 +1429,11 @@ impl Serialize for Monster<'_> { } } -pub struct MonsterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +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); @@ -1455,12 +1447,12 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_HP, hp, 100); } #[inline] - pub fn add_name(&mut self, name: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(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>) { - self.fbb_.push_slot_always::>(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) { @@ -1471,32 +1463,32 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TEST_TYPE, test_type, Any::NONE); } #[inline] - pub fn add_test(&mut self, test: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_TEST, test); + pub fn add_test(&mut self, test: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST, test); } #[inline] - pub fn add_test4(&mut self, test4: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TEST4, test4); + pub fn add_test4(&mut self, test4: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Test>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST4, test4); } #[inline] - pub fn add_testarrayofstring(&mut self, testarrayofstring: flatbuffers::WIPOffset>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSTRING, testarrayofstring); + pub fn add_testarrayofstring(&mut self, testarrayofstring: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSTRING, testarrayofstring); } #[inline] - pub fn add_testarrayoftables(&mut self, testarrayoftables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables); + pub fn add_testarrayoftables(&mut self, testarrayoftables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables); } #[inline] - pub fn add_enemy(&mut self, enemy: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_ENEMY, enemy); + pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_ENEMY, enemy); } #[inline] - pub fn add_testnestedflatbuffer(&mut self, testnestedflatbuffer: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer); + pub fn add_testnestedflatbuffer(&mut self, testnestedflatbuffer: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTNESTEDFLATBUFFER, testnestedflatbuffer); } #[inline] - pub fn add_testempty(&mut self, testempty: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTEMPTY, testempty); + pub fn add_testempty(&mut self, testempty: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_TESTEMPTY, testempty); } #[inline] pub fn add_testbool(&mut self, testbool: bool) { @@ -1535,8 +1527,8 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0); } #[inline] - pub fn add_testarrayofbools(&mut self, testarrayofbools: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools); + pub fn add_testarrayofbools(&mut self, testarrayofbools: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , bool>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFBOOLS, testarrayofbools); } #[inline] pub fn add_testf(&mut self, testf: f32) { @@ -1551,96 +1543,96 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_TESTF3, testf3, 0.0); } #[inline] - pub fn add_testarrayofstring2(&mut self, testarrayofstring2: flatbuffers::WIPOffset>>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2); + pub fn add_testarrayofstring2(&mut self, testarrayofstring2: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<&'b str>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSTRING2, testarrayofstring2); } #[inline] - pub fn add_testarrayofsortedstruct(&mut self, testarrayofsortedstruct: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct); + pub fn add_testarrayofsortedstruct(&mut self, testarrayofsortedstruct: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Ability>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, testarrayofsortedstruct); } #[inline] - pub fn add_flex(&mut self, flex: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_FLEX, flex); + pub fn add_flex(&mut self, flex: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_FLEX, flex); } #[inline] - pub fn add_test5(&mut self, test5: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TEST5, test5); + pub fn add_test5(&mut self, test5: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Test>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TEST5, test5); } #[inline] - pub fn add_vector_of_longs(&mut self, vector_of_longs: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_LONGS, vector_of_longs); + pub fn add_vector_of_longs(&mut self, vector_of_longs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_LONGS, vector_of_longs); } #[inline] - pub fn add_vector_of_doubles(&mut self, vector_of_doubles: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles); + pub fn add_vector_of_doubles(&mut self, vector_of_doubles: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , f64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_DOUBLES, vector_of_doubles); } #[inline] - pub fn add_parent_namespace_test(&mut self, parent_namespace_test: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test); + pub fn add_parent_namespace_test(&mut self, parent_namespace_test: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test); } #[inline] - pub fn add_vector_of_referrables(&mut self, vector_of_referrables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables); + pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_REFERRABLES, vector_of_referrables); } #[inline] pub fn add_single_weak_reference(&mut self, single_weak_reference: u64) { self.fbb_.push_slot::(Monster::VT_SINGLE_WEAK_REFERENCE, single_weak_reference, 0); } #[inline] - pub fn add_vector_of_weak_references(&mut self, vector_of_weak_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references); + pub fn add_vector_of_weak_references(&mut self, vector_of_weak_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, vector_of_weak_references); } #[inline] - pub fn add_vector_of_strong_referrables(&mut self, vector_of_strong_referrables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables); + pub fn add_vector_of_strong_referrables(&mut self, vector_of_strong_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, vector_of_strong_referrables); } #[inline] pub fn add_co_owning_reference(&mut self, co_owning_reference: u64) { self.fbb_.push_slot::(Monster::VT_CO_OWNING_REFERENCE, co_owning_reference, 0); } #[inline] - pub fn add_vector_of_co_owning_references(&mut self, vector_of_co_owning_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references); + pub fn add_vector_of_co_owning_references(&mut self, vector_of_co_owning_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, vector_of_co_owning_references); } #[inline] pub fn add_non_owning_reference(&mut self, non_owning_reference: u64) { self.fbb_.push_slot::(Monster::VT_NON_OWNING_REFERENCE, non_owning_reference, 0); } #[inline] - pub fn add_vector_of_non_owning_references(&mut self, vector_of_non_owning_references: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references); + pub fn add_vector_of_non_owning_references(&mut self, vector_of_non_owning_references: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, vector_of_non_owning_references); } #[inline] pub fn add_any_unique_type(&mut self, any_unique_type: AnyUniqueAliases) { self.fbb_.push_slot::(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE); } #[inline] - pub fn add_any_unique(&mut self, any_unique: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_ANY_UNIQUE, any_unique); + pub fn add_any_unique(&mut self, any_unique: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_ANY_UNIQUE, any_unique); } #[inline] pub fn add_any_ambiguous_type(&mut self, any_ambiguous_type: AnyAmbiguousAliases) { self.fbb_.push_slot::(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE); } #[inline] - pub fn add_any_ambiguous(&mut self, any_ambiguous: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(Monster::VT_ANY_AMBIGUOUS, any_ambiguous); + pub fn add_any_ambiguous(&mut self, any_ambiguous: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_ANY_AMBIGUOUS, any_ambiguous); } #[inline] - pub fn add_vector_of_enums(&mut self, vector_of_enums: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums); + pub fn add_vector_of_enums(&mut self, vector_of_enums: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Color>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_VECTOR_OF_ENUMS, vector_of_enums); } #[inline] pub fn add_signed_enum(&mut self, signed_enum: Race) { self.fbb_.push_slot::(Monster::VT_SIGNED_ENUM, signed_enum, Race::None); } #[inline] - pub fn add_testrequirednestedflatbuffer(&mut self, testrequirednestedflatbuffer: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer); + pub fn add_testrequirednestedflatbuffer(&mut self, testrequirednestedflatbuffer: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, testrequirednestedflatbuffer); } #[inline] - pub fn add_scalar_key_sorted_tables(&mut self, scalar_key_sorted_tables: flatbuffers::WIPOffset>>>) { - self.fbb_.push_slot_always::>(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables); + pub fn add_scalar_key_sorted_tables(&mut self, scalar_key_sorted_tables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset>>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, scalar_key_sorted_tables); } #[inline] pub fn add_native_inline(&mut self, native_inline: &Test) { @@ -1687,7 +1679,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { self.fbb_.push_slot::(Monster::VT_DOUBLE_INF_DEFAULT, double_inf_default, f64::INFINITY); } #[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, @@ -1695,15 +1687,15 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); self.fbb_.required(o, Monster::VT_NAME,"name"); - 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()); @@ -1853,16 +1845,16 @@ pub struct MonsterT { pub pos: Option, pub mana: i16, pub hp: i16, - pub name: String, - pub inventory: Option>, + pub name: alloc::string::String, + pub inventory: Option>, pub color: Color, pub test: AnyT, - pub test4: Option>, - pub testarrayofstring: Option>, - pub testarrayoftables: Option>, - pub enemy: Option>, - pub testnestedflatbuffer: Option>, - pub testempty: Option>, + pub test4: Option>, + pub testarrayofstring: Option>, + pub testarrayoftables: Option>, + pub enemy: Option>, + pub testnestedflatbuffer: Option>, + pub testempty: Option>, pub testbool: bool, pub testhashs32_fnv1: i32, pub testhashu32_fnv1: u32, @@ -1872,31 +1864,31 @@ pub struct MonsterT { pub testhashu32_fnv1a: u32, pub testhashs64_fnv1a: i64, pub testhashu64_fnv1a: u64, - pub testarrayofbools: Option>, + pub testarrayofbools: Option>, pub testf: f32, pub testf2: f32, pub testf3: f32, - pub testarrayofstring2: Option>, - pub testarrayofsortedstruct: Option>, - pub flex: Option>, - pub test5: Option>, - pub vector_of_longs: Option>, - pub vector_of_doubles: Option>, - pub parent_namespace_test: Option>, - pub vector_of_referrables: Option>, + pub testarrayofstring2: Option>, + pub testarrayofsortedstruct: Option>, + pub flex: Option>, + pub test5: Option>, + pub vector_of_longs: Option>, + pub vector_of_doubles: Option>, + pub parent_namespace_test: Option>, + pub vector_of_referrables: Option>, pub single_weak_reference: u64, - pub vector_of_weak_references: Option>, - pub vector_of_strong_referrables: Option>, + pub vector_of_weak_references: Option>, + pub vector_of_strong_referrables: Option>, pub co_owning_reference: u64, - pub vector_of_co_owning_references: Option>, + pub vector_of_co_owning_references: Option>, pub non_owning_reference: u64, - pub vector_of_non_owning_references: Option>, + pub vector_of_non_owning_references: Option>, pub any_unique: AnyUniqueAliasesT, pub any_ambiguous: AnyAmbiguousAliasesT, - pub vector_of_enums: Option>, + pub vector_of_enums: Option>, pub signed_enum: Race, - pub testrequirednestedflatbuffer: Option>, - pub scalar_key_sorted_tables: Option>, + pub testrequirednestedflatbuffer: Option>, + pub scalar_key_sorted_tables: Option>, pub native_inline: Option, pub long_enum_non_enum_default: LongEnum, pub long_enum_normal_default: LongEnum, @@ -1915,7 +1907,7 @@ impl Default for MonsterT { pos: None, mana: 150, hp: 100, - name: "".to_string(), + name: alloc::string::ToString::to_string(""), inventory: None, color: Color::Blue, test: AnyT::NONE, @@ -1974,10 +1966,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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let pos_tmp = self.pos.as_ref().map(|x| x.pack()); let pos = pos_tmp.as_ref(); let mana = self.mana; @@ -1993,13 +1985,13 @@ impl MonsterT { let test_type = self.test.any_type(); let test = self.test.pack(_fbb); let test4 = self.test4.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) }); let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) }); let testarrayoftables = self.testarrayoftables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let enemy = self.enemy.as_ref().map(|x|{ x.pack(_fbb) @@ -2026,16 +2018,16 @@ impl MonsterT { let testf2 = self.testf2; let testf3 = self.testf3; let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|s| _fbb.create_string(s)).collect();_fbb.create_vector(&w) }); let testarrayofsortedstruct = self.testarrayofsortedstruct.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) }); let flex = self.flex.as_ref().map(|x|{ _fbb.create_vector(x) }); let test5 = self.test5.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w) }); let vector_of_longs = self.vector_of_longs.as_ref().map(|x|{ _fbb.create_vector(x) @@ -2047,14 +2039,14 @@ impl MonsterT { x.pack(_fbb) }); let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let single_weak_reference = self.single_weak_reference; let vector_of_weak_references = self.vector_of_weak_references.as_ref().map(|x|{ _fbb.create_vector(x) }); let vector_of_strong_referrables = self.vector_of_strong_referrables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let co_owning_reference = self.co_owning_reference; let vector_of_co_owning_references = self.vector_of_co_owning_references.as_ref().map(|x|{ @@ -2076,7 +2068,7 @@ impl MonsterT { _fbb.create_vector(x) }); let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{ - let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) + let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w) }); let native_inline_tmp = self.native_inline.as_ref().map(|x| x.pack()); let native_inline = native_inline_tmp.as_ref(); @@ -2162,8 +2154,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 { - flatbuffers::root::(buf) +pub fn root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -2172,8 +2164,8 @@ pub fn root_as_monster(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result { + ::flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -2183,10 +2175,10 @@ pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -2196,47 +2188,47 @@ 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, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(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 { - flatbuffers::root_unchecked::(buf) + ::flatbuffers::root_unchecked::(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 { - flatbuffers::size_prefixed_root_unchecked::(buf) + ::flatbuffers::size_prefixed_root_unchecked::(buf) } pub const MONSTER_IDENTIFIER: &str = "MONS"; #[inline] pub fn monster_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, false) + ::flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, false) } #[inline] pub fn monster_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, true) + ::flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, true) } pub const MONSTER_EXTENSION: &str = "mon"; #[inline] -pub fn finish_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>) { +pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>) { fbb.finish(root, Some(MONSTER_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, Some(MONSTER_IDENTIFIER)); } diff --git a/tests/monster_test_serialize/my_game/example/race_generated.rs b/tests/monster_test_serialize/my_game/example/race_generated.rs index fe57ce0a048..d72b6a9900e 100644 --- a/tests/monster_test_serialize/my_game/example/race_generated.rs +++ b/tests/monster_test_serialize/my_game/example/race_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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_RACE: i8 = -1; @@ -53,8 +46,8 @@ impl Race { } } } -impl core::fmt::Debug for Race { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Race { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -71,24 +64,24 @@ impl Serialize for Race { } } -impl<'a> flatbuffers::Follow<'a> for Race { +impl<'a> ::flatbuffers::Follow<'a> for Race { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for Race { +impl ::flatbuffers::Push for Race { type Output = Race; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for Race { +impl ::flatbuffers::EndianScalar for Race { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -102,14 +95,13 @@ impl flatbuffers::EndianScalar for Race { } } -impl<'a> flatbuffers::Verifiable for Race { +impl<'a> ::flatbuffers::Verifiable for Race { #[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 Race {} +impl ::flatbuffers::SimpleToVerifyInSlice for Race {} diff --git a/tests/monster_test_serialize/my_game/example/referrable_generated.rs b/tests/monster_test_serialize/my_game/example/referrable_generated.rs index 681cc13232f..41ebc9f1015 100644 --- a/tests/monster_test_serialize/my_game/example/referrable_generated.rs +++ b/tests/monster_test_serialize/my_game/example/referrable_generated.rs @@ -1,47 +1,40 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum ReferrableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Referrable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Referrable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Referrable<'a> { type Inner = Referrable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Referrable<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; + pub const VT_ID: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.Referrable" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Referrable { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 ReferrableArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = ReferrableBuilder::new(_fbb); builder.add_id(args.id); builder.finish() @@ -73,12 +66,11 @@ impl<'a> Referrable<'a> { } } -impl flatbuffers::Verifiable for Referrable<'_> { +impl ::flatbuffers::Verifiable for Referrable<'_> { #[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::("id", Self::VT_ID, false)? .finish(); @@ -108,17 +100,17 @@ impl Serialize for Referrable<'_> { } } -pub struct ReferrableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct ReferrableBuilder<'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> ReferrableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ReferrableBuilder<'a, 'b, A> { #[inline] pub fn add_id(&mut self, id: u64) { self.fbb_.push_slot::(Referrable::VT_ID, id, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> { let start = _fbb.start_table(); ReferrableBuilder { fbb_: _fbb, @@ -126,14 +118,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ReferrableBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Referrable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Referrable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Referrable"); ds.field("id", &self.id()); ds.finish() @@ -152,10 +144,10 @@ impl Default for ReferrableT { } } impl ReferrableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let id = self.id; Referrable::create(_fbb, &ReferrableArgs{ id, diff --git a/tests/monster_test_serialize/my_game/example/stat_generated.rs b/tests/monster_test_serialize/my_game/example/stat_generated.rs index f864c6f828b..2c3b816f359 100644 --- a/tests/monster_test_serialize/my_game/example/stat_generated.rs +++ b/tests/monster_test_serialize/my_game/example/stat_generated.rs @@ -1,49 +1,42 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum StatOffset {} #[derive(Copy, Clone, PartialEq)] pub struct Stat<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Stat<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Stat<'a> { type Inner = Stat<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Stat<'a> { - pub const VT_ID: flatbuffers::VOffsetT = 4; - pub const VT_VAL: flatbuffers::VOffsetT = 6; - pub const VT_COUNT: flatbuffers::VOffsetT = 8; + pub const VT_ID: ::flatbuffers::VOffsetT = 4; + pub const VT_VAL: ::flatbuffers::VOffsetT = 6; + pub const VT_COUNT: ::flatbuffers::VOffsetT = 8; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.Stat" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Stat { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 StatArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = StatBuilder::new(_fbb); builder.add_val(args.val); if let Some(x) = args.id { builder.add_id(x); } @@ -53,7 +46,7 @@ impl<'a> Stat<'a> { pub fn unpack(&self) -> StatT { let id = self.id().map(|x| { - x.to_string() + alloc::string::ToString::to_string(x) }); let val = self.val(); let count = self.count(); @@ -69,7 +62,7 @@ impl<'a> Stat<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(Stat::VT_ID, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)} } #[inline] pub fn val(&self) -> i64 { @@ -97,14 +90,13 @@ impl<'a> Stat<'a> { } } -impl flatbuffers::Verifiable for Stat<'_> { +impl ::flatbuffers::Verifiable for Stat<'_> { #[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::>("id", Self::VT_ID, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)? .visit_field::("val", Self::VT_VAL, false)? .visit_field::("count", Self::VT_COUNT, false)? .finish(); @@ -112,7 +104,7 @@ impl flatbuffers::Verifiable for Stat<'_> { } } pub struct StatArgs<'a> { - pub id: Option>, + pub id: Option<::flatbuffers::WIPOffset<&'a str>>, pub val: i64, pub count: u16, } @@ -144,14 +136,14 @@ impl Serialize for Stat<'_> { } } -pub struct StatBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct StatBuilder<'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> StatBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { #[inline] - pub fn add_id(&mut self, id: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(Stat::VT_ID, id); + pub fn add_id(&mut self, id: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Stat::VT_ID, id); } #[inline] pub fn add_val(&mut self, val: i64) { @@ -162,7 +154,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { self.fbb_.push_slot::(Stat::VT_COUNT, count, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> { let start = _fbb.start_table(); StatBuilder { fbb_: _fbb, @@ -170,14 +162,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> StatBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Stat<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Stat<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Stat"); ds.field("id", &self.id()); ds.field("val", &self.val()); @@ -188,7 +180,7 @@ impl core::fmt::Debug for Stat<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct StatT { - pub id: Option, + pub id: Option, pub val: i64, pub count: u16, } @@ -202,10 +194,10 @@ impl Default for StatT { } } impl StatT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let id = self.id.as_ref().map(|x|{ _fbb.create_string(x) }); diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs index e524059f807..ffc816de780 100644 --- a/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs +++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct StructOfStructs, aligned to 4 #[repr(transparent)] @@ -20,8 +13,8 @@ impl Default for StructOfStructs { Self([0; 20]) } } -impl core::fmt::Debug for StructOfStructs { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for StructOfStructs { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("StructOfStructs") .field("a", &self.a()) .field("b", &self.b()) @@ -30,40 +23,40 @@ impl core::fmt::Debug for StructOfStructs { } } -impl flatbuffers::SimpleToVerifyInSlice for StructOfStructs {} -impl<'a> flatbuffers::Follow<'a> for StructOfStructs { +impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {} +impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs { type Inner = &'a StructOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a StructOfStructs>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructs { +impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructs { type Inner = &'a StructOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for StructOfStructs { +impl<'b> ::flatbuffers::Push for StructOfStructs { type Output = StructOfStructs; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, ::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 StructOfStructs { +impl<'a> ::flatbuffers::Verifiable for StructOfStructs { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } diff --git a/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs index b7fd8cd7cf9..59436c3e284 100644 --- a/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs +++ b/tests/monster_test_serialize/my_game/example/struct_of_structs_of_structs_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct StructOfStructsOfStructs, aligned to 4 #[repr(transparent)] @@ -20,48 +13,48 @@ impl Default for StructOfStructsOfStructs { Self([0; 20]) } } -impl core::fmt::Debug for StructOfStructsOfStructs { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for StructOfStructsOfStructs { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("StructOfStructsOfStructs") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {} -impl<'a> flatbuffers::Follow<'a> for StructOfStructsOfStructs { +impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {} +impl<'a> ::flatbuffers::Follow<'a> for StructOfStructsOfStructs { type Inner = &'a StructOfStructsOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a StructOfStructsOfStructs>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs { +impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs { type Inner = &'a StructOfStructsOfStructs; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for StructOfStructsOfStructs { +impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs { type Output = StructOfStructsOfStructs; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, ::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 StructOfStructsOfStructs { +impl<'a> ::flatbuffers::Verifiable for StructOfStructsOfStructs { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } diff --git a/tests/monster_test_serialize/my_game/example/test_generated.rs b/tests/monster_test_serialize/my_game/example/test_generated.rs index 0a0a48c7dbe..f27fde7a1f7 100644 --- a/tests/monster_test_serialize/my_game/example/test_generated.rs +++ b/tests/monster_test_serialize/my_game/example/test_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct Test, aligned to 2 #[repr(transparent)] @@ -20,8 +13,8 @@ impl Default for Test { Self([0; 4]) } } -impl core::fmt::Debug for Test { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Test { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Test") .field("a", &self.a()) .field("b", &self.b()) @@ -29,40 +22,40 @@ impl core::fmt::Debug for Test { } } -impl flatbuffers::SimpleToVerifyInSlice for Test {} -impl<'a> flatbuffers::Follow<'a> for Test { +impl ::flatbuffers::SimpleToVerifyInSlice for Test {} +impl<'a> ::flatbuffers::Follow<'a> for Test { type Inner = &'a Test; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Test>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Test { +impl<'a> ::flatbuffers::Follow<'a> for &'a Test { type Inner = &'a Test; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Test { +impl<'b> ::flatbuffers::Push for Test { type Output = Test; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Test as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(2) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(2) } } -impl<'a> flatbuffers::Verifiable for Test { +impl<'a> ::flatbuffers::Verifiable for Test { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -96,59 +89,59 @@ impl<'a> Test { } pub fn a(&self) -> i16 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i16) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn b(&self) -> i8 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[2..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_b(&mut self, x: i8) { - 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[2..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs index 2db2b0bccdc..7cd919d0b97 100644 --- a/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs +++ b/tests/monster_test_serialize/my_game/example/test_simple_table_with_enum_generated.rs @@ -1,47 +1,40 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum TestSimpleTableWithEnumOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TestSimpleTableWithEnum<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> { type Inner = TestSimpleTableWithEnum<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TestSimpleTableWithEnum<'a> { - pub const VT_COLOR: flatbuffers::VOffsetT = 4; + pub const VT_COLOR: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.TestSimpleTableWithEnum" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TestSimpleTableWithEnum { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TestSimpleTableWithEnumArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb); builder.add_color(args.color); builder.finish() @@ -63,12 +56,11 @@ impl<'a> TestSimpleTableWithEnum<'a> { } } -impl flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> { +impl ::flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> { #[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::("color", Self::VT_COLOR, false)? .finish(); @@ -98,17 +90,17 @@ impl Serialize for TestSimpleTableWithEnum<'_> { } } -pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TestSimpleTableWithEnumBuilder<'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> TestSimpleTableWithEnumBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TestSimpleTableWithEnumBuilder<'a, 'b, A> { #[inline] pub fn add_color(&mut self, color: Color) { self.fbb_.push_slot::(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> { let start = _fbb.start_table(); TestSimpleTableWithEnumBuilder { fbb_: _fbb, @@ -116,14 +108,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TestSimpleTableWithEnumBuilder< } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TestSimpleTableWithEnum<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TestSimpleTableWithEnum<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TestSimpleTableWithEnum"); ds.field("color", &self.color()); ds.finish() @@ -142,10 +134,10 @@ impl Default for TestSimpleTableWithEnumT { } } impl TestSimpleTableWithEnumT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let color = self.color; TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{ color, diff --git a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs index fb9d1a1c431..00415a15e0b 100644 --- a/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs +++ b/tests/monster_test_serialize/my_game/example/type_aliases_generated.rs @@ -1,58 +1,51 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum TypeAliasesOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TypeAliases<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TypeAliases<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TypeAliases<'a> { type Inner = TypeAliases<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TypeAliases<'a> { - 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; + 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; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.Example.TypeAliases" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TypeAliases { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TypeAliasesArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TypeAliasesBuilder::new(_fbb); builder.add_f64_(args.f64_); builder.add_u64_(args.u64_); @@ -173,27 +166,26 @@ impl<'a> TypeAliases<'a> { unsafe { self._tab.get::(TypeAliases::VT_F64_, Some(0.0)).unwrap()} } #[inline] - pub fn v8(&self) -> Option> { + pub fn v8(&self) -> Option<::flatbuffers::Vector<'a, i8>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(TypeAliases::VT_V8, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)} } #[inline] - pub fn vf64(&self) -> Option> { + pub fn vf64(&self) -> Option<::flatbuffers::Vector<'a, f64>> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(TypeAliases::VT_VF64, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)} } } -impl flatbuffers::Verifiable for TypeAliases<'_> { +impl ::flatbuffers::Verifiable for TypeAliases<'_> { #[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::("i8_", Self::VT_I8_, false)? .visit_field::("u8_", Self::VT_U8_, false)? @@ -205,8 +197,8 @@ impl flatbuffers::Verifiable for TypeAliases<'_> { .visit_field::("u64_", Self::VT_U64_, false)? .visit_field::("f32_", Self::VT_F32_, false)? .visit_field::("f64_", Self::VT_F64_, false)? - .visit_field::>>("v8", Self::VT_V8, false)? - .visit_field::>>("vf64", Self::VT_VF64, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i8>>>("v8", Self::VT_V8, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, f64>>>("vf64", Self::VT_VF64, false)? .finish(); Ok(()) } @@ -222,8 +214,8 @@ pub struct TypeAliasesArgs<'a> { pub u64_: u64, pub f32_: f32, pub f64_: f64, - pub v8: Option>>, - pub vf64: Option>>, + pub v8: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>, + pub vf64: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>, } impl<'a> Default for TypeAliasesArgs<'a> { #[inline] @@ -275,11 +267,11 @@ impl Serialize for TypeAliases<'_> { } } -pub struct TypeAliasesBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TypeAliasesBuilder<'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> TypeAliasesBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { #[inline] pub fn add_i8_(&mut self, i8_: i8) { self.fbb_.push_slot::(TypeAliases::VT_I8_, i8_, 0); @@ -321,15 +313,15 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { self.fbb_.push_slot::(TypeAliases::VT_F64_, f64_, 0.0); } #[inline] - pub fn add_v8(&mut self, v8: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TypeAliases::VT_V8, v8); + pub fn add_v8(&mut self, v8: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i8>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(TypeAliases::VT_V8, v8); } #[inline] - pub fn add_vf64(&mut self, vf64: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TypeAliases::VT_VF64, vf64); + pub fn add_vf64(&mut self, vf64: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , f64>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(TypeAliases::VT_VF64, vf64); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TypeAliasesBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TypeAliasesBuilder<'a, 'b, A> { let start = _fbb.start_table(); TypeAliasesBuilder { fbb_: _fbb, @@ -337,14 +329,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TypeAliasesBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TypeAliases<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TypeAliases<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TypeAliases"); ds.field("i8_", &self.i8_()); ds.field("u8_", &self.u8_()); @@ -374,8 +366,8 @@ pub struct TypeAliasesT { pub u64_: u64, pub f32_: f32, pub f64_: f64, - pub v8: Option>, - pub vf64: Option>, + pub v8: Option>, + pub vf64: Option>, } impl Default for TypeAliasesT { fn default() -> Self { @@ -396,10 +388,10 @@ impl Default for TypeAliasesT { } } impl TypeAliasesT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let i8_ = self.i8_; let u8_ = self.u8_; let i16_ = self.i16_; diff --git a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs index e4ff8f2a2a7..7b3dbc7abc6 100644 --- a/tests/monster_test_serialize/my_game/example/vec_3_generated.rs +++ b/tests/monster_test_serialize/my_game/example/vec_3_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct Vec3, aligned to 8 #[repr(transparent)] @@ -20,8 +13,8 @@ impl Default for Vec3 { Self([0; 32]) } } -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()) @@ -33,40 +26,40 @@ 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 { <&'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 { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(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 = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, ::size()); dst.copy_from_slice(src); } #[inline] - fn alignment() -> flatbuffers::PushAlignment { - flatbuffers::PushAlignment::new(8) + fn alignment() -> ::flatbuffers::PushAlignment { + ::flatbuffers::PushAlignment::new(8) } } -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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -112,146 +105,146 @@ impl<'a> Vec3 { } pub fn x(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn y(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn z(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn test1(&self) -> f64 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[16..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_test1(&mut self, x: f64) { - 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[16..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn test2(&self) -> Color { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[24..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_test2(&mut self, x: Color) { - 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[24..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs index 96f2d17a17b..de65c7d96f3 100644 --- a/tests/monster_test_serialize/my_game/example_2/monster_generated.rs +++ b/tests/monster_test_serialize/my_game/example_2/monster_generated.rs @@ -1,28 +1,21 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -33,14 +26,14 @@ impl<'a> Monster<'a> { } #[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 - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = MonsterBuilder::new(_fbb); builder.finish() } @@ -51,12 +44,11 @@ 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)? .finish(); Ok(()) @@ -82,13 +74,13 @@ impl Serialize for Monster<'_> { } } -pub struct MonsterBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +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 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, @@ -96,14 +88,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MonsterBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { 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.finish() } @@ -119,10 +111,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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { Monster::create(_fbb, &MonsterArgs{ }) } diff --git a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs index 7f9324342c6..cacc72c8c51 100644 --- a/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs +++ b/tests/monster_test_serialize/my_game/in_parent_namespace_generated.rs @@ -1,28 +1,21 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum InParentNamespaceOffset {} #[derive(Copy, Clone, PartialEq)] pub struct InParentNamespace<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for InParentNamespace<'a> { +impl<'a> ::flatbuffers::Follow<'a> for InParentNamespace<'a> { type Inner = InParentNamespace<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -33,14 +26,14 @@ impl<'a> InParentNamespace<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe 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, 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 InParentNamespaceArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = InParentNamespaceBuilder::new(_fbb); builder.finish() } @@ -51,12 +44,11 @@ impl<'a> InParentNamespace<'a> { } } -impl flatbuffers::Verifiable for InParentNamespace<'_> { +impl ::flatbuffers::Verifiable for InParentNamespace<'_> { #[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)? .finish(); Ok(()) @@ -82,13 +74,13 @@ impl Serialize for InParentNamespace<'_> { } } -pub struct InParentNamespaceBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct InParentNamespaceBuilder<'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> InParentNamespaceBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> InParentNamespaceBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> { let start = _fbb.start_table(); InParentNamespaceBuilder { fbb_: _fbb, @@ -96,14 +88,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> InParentNamespaceBuilder<'a, 'b } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for InParentNamespace<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for InParentNamespace<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("InParentNamespace"); ds.finish() } @@ -119,10 +111,10 @@ impl Default for InParentNamespaceT { } } impl InParentNamespaceT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { InParentNamespace::create(_fbb, &InParentNamespaceArgs{ }) } diff --git a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs index 15366440143..8dd4e832b52 100644 --- a/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs +++ b/tests/monster_test_serialize/my_game/other_name_space/from_include_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -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_FROM_INCLUDE: i64 = 0; @@ -41,8 +34,8 @@ impl FromInclude { } } } -impl core::fmt::Debug for FromInclude { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for FromInclude { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -59,24 +52,24 @@ impl Serialize for FromInclude { } } -impl<'a> flatbuffers::Follow<'a> for FromInclude { +impl<'a> ::flatbuffers::Follow<'a> for FromInclude { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for FromInclude { +impl ::flatbuffers::Push for FromInclude { type Output = FromInclude; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for FromInclude { +impl ::flatbuffers::EndianScalar for FromInclude { type Scalar = i64; #[inline] fn to_little_endian(self) -> i64 { @@ -90,14 +83,13 @@ impl flatbuffers::EndianScalar for FromInclude { } } -impl<'a> flatbuffers::Verifiable for FromInclude { +impl<'a> ::flatbuffers::Verifiable for FromInclude { #[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> { i64::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for FromInclude {} +impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {} diff --git a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs index 83ed1a9fbe6..890d23b6fff 100644 --- a/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs +++ b/tests/monster_test_serialize/my_game/other_name_space/table_b_generated.rs @@ -1,47 +1,40 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum TableBOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableB<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableB<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableB<'a> { type Inner = TableB<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableB<'a> { - pub const VT_A: flatbuffers::VOffsetT = 4; + pub const VT_A: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "MyGame.OtherNameSpace.TableB" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableB { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableBArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableBBuilder::new(_fbb); if let Some(x) = args.a { builder.add_a(x); } builder.finish() @@ -49,7 +42,7 @@ impl<'a> TableB<'a> { pub fn unpack(&self) -> TableBT { let a = self.a().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableBT { a, @@ -61,24 +54,23 @@ impl<'a> TableB<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableB::VT_A, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableB::VT_A, None)} } } -impl flatbuffers::Verifiable for TableB<'_> { +impl ::flatbuffers::Verifiable for TableB<'_> { #[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::>("a", Self::VT_A, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("a", Self::VT_A, false)? .finish(); Ok(()) } } pub struct TableBArgs<'a> { - pub a: Option>>, + pub a: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableBArgs<'a> { #[inline] @@ -104,17 +96,17 @@ impl Serialize for TableB<'_> { } } -pub struct TableBBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableBBuilder<'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> TableBBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { #[inline] - pub fn add_a(&mut self, a: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableB::VT_A, a); + pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableB::VT_A, a); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableBBuilder { fbb_: _fbb, @@ -122,14 +114,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableB<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableB<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableB"); ds.field("a", &self.a()); ds.finish() @@ -138,7 +130,7 @@ impl core::fmt::Debug for TableB<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableBT { - pub a: Option>, + pub a: Option>, } impl Default for TableBT { fn default() -> Self { @@ -148,10 +140,10 @@ impl Default for TableBT { } } impl TableBT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let a = self.a.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs index c89fab4ef78..72dfec1c5b9 100644 --- a/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs +++ b/tests/monster_test_serialize/my_game/other_name_space/unused_generated.rs @@ -1,15 +1,8 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; // struct Unused, aligned to 4 #[repr(transparent)] @@ -20,48 +13,48 @@ impl Default for Unused { Self([0; 4]) } } -impl core::fmt::Debug for Unused { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Unused { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Unused") .field("a", &self.a()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for Unused {} -impl<'a> flatbuffers::Follow<'a> for Unused { +impl ::flatbuffers::SimpleToVerifyInSlice for Unused {} +impl<'a> ::flatbuffers::Follow<'a> for Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Unused>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Unused { +impl<'a> ::flatbuffers::Follow<'a> for &'a Unused { type Inner = &'a Unused; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Unused { +impl<'b> ::flatbuffers::Push for Unused { type Output = Unused; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Unused as *const u8, ::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 Unused { +impl<'a> ::flatbuffers::Verifiable for Unused { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -92,30 +85,30 @@ impl<'a> Unused { } pub fn a(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/monster_test_serialize/table_a_generated.rs b/tests/monster_test_serialize/table_a_generated.rs index c0d8f65b154..5ce3c60933e 100644 --- a/tests/monster_test_serialize/table_a_generated.rs +++ b/tests/monster_test_serialize/table_a_generated.rs @@ -1,47 +1,40 @@ // 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; extern crate serde; use self::serde::ser::{Serialize, Serializer, SerializeStruct}; -use self::flatbuffers::{EndianScalar, Follow}; use super::*; pub enum TableAOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableA<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableA<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> { type Inner = TableA<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableA<'a> { - pub const VT_B: flatbuffers::VOffsetT = 4; + pub const VT_B: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "TableA" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableA { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableAArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableABuilder::new(_fbb); if let Some(x) = args.b { builder.add_b(x); } builder.finish() @@ -49,7 +42,7 @@ impl<'a> TableA<'a> { pub fn unpack(&self) -> TableAT { let b = self.b().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableAT { b, @@ -61,24 +54,23 @@ impl<'a> TableA<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableA::VT_B, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableA::VT_B, None)} } } -impl flatbuffers::Verifiable for TableA<'_> { +impl ::flatbuffers::Verifiable for TableA<'_> { #[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::>("b", Self::VT_B, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("b", Self::VT_B, false)? .finish(); Ok(()) } } pub struct TableAArgs<'a> { - pub b: Option>>, + pub b: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableAArgs<'a> { #[inline] @@ -104,17 +96,17 @@ impl Serialize for TableA<'_> { } } -pub struct TableABuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableABuilder<'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> TableABuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { #[inline] - pub fn add_b(&mut self, b: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableA::VT_B, b); + pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableA::VT_B, b); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> { let start = _fbb.start_table(); TableABuilder { fbb_: _fbb, @@ -122,14 +114,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableA<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableA<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableA"); ds.field("b", &self.b()); ds.finish() @@ -138,7 +130,7 @@ impl core::fmt::Debug for TableA<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableAT { - pub b: Option>, + pub b: Option>, } impl Default for TableAT { fn default() -> Self { @@ -148,10 +140,10 @@ impl Default for TableAT { } } impl TableAT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let b = self.b.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/more_defaults/abc_generated.rs b/tests/more_defaults/abc_generated.rs index cff89ca72c6..8a4678f8100 100644 --- a/tests/more_defaults/abc_generated.rs +++ b/tests/more_defaults/abc_generated.rs @@ -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_ABC: i32 = 0; @@ -47,8 +40,8 @@ impl ABC { } } } -impl core::fmt::Debug for ABC { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for ABC { + 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 ABC { } } } -impl<'a> flatbuffers::Follow<'a> for ABC { +impl<'a> ::flatbuffers::Follow<'a> for ABC { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for ABC { +impl ::flatbuffers::Push for ABC { type Output = ABC; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for ABC { +impl ::flatbuffers::EndianScalar for ABC { type Scalar = i32; #[inline] fn to_little_endian(self) -> i32 { @@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for ABC { } } -impl<'a> flatbuffers::Verifiable for ABC { +impl<'a> ::flatbuffers::Verifiable for ABC { #[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> { i32::run_verifier(v, pos) } } -impl flatbuffers::SimpleToVerifyInSlice for ABC {} +impl ::flatbuffers::SimpleToVerifyInSlice for ABC {} diff --git a/tests/more_defaults/more_defaults_generated.rs b/tests/more_defaults/more_defaults_generated.rs index bf6d3e799f7..93dc63386ff 100644 --- a/tests/more_defaults/more_defaults_generated.rs +++ b/tests/more_defaults/more_defaults_generated.rs @@ -1,50 +1,43 @@ // 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 MoreDefaultsOffset {} #[derive(Copy, Clone, PartialEq)] pub struct MoreDefaults<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for MoreDefaults<'a> { +impl<'a> ::flatbuffers::Follow<'a> for MoreDefaults<'a> { type Inner = MoreDefaults<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> MoreDefaults<'a> { - 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; + 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; pub const fn get_fully_qualified_name() -> &'static str { "MoreDefaults" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { MoreDefaults { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 MoreDefaultsArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { 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); } @@ -66,11 +59,11 @@ impl<'a> MoreDefaults<'a> { }; let empty_string = { let x = self.empty_string(); - x.to_string() + alloc::string::ToString::to_string(x) }; let some_string = { let x = self.some_string(); - x.to_string() + alloc::string::ToString::to_string(x) }; let abcs = { let x = self.abcs(); @@ -91,73 +84,72 @@ impl<'a> MoreDefaults<'a> { } #[inline] - pub fn ints(&self) -> flatbuffers::Vector<'a, i32> { + pub fn ints(&self) -> ::flatbuffers::Vector<'a, i32> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(MoreDefaults::VT_INTS, Some(Default::default())).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i32>>>(MoreDefaults::VT_INTS, Some(Default::default())).unwrap()} } #[inline] - pub fn floats(&self) -> flatbuffers::Vector<'a, f32> { + pub fn floats(&self) -> ::flatbuffers::Vector<'a, f32> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(MoreDefaults::VT_FLOATS, Some(Default::default())).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f32>>>(MoreDefaults::VT_FLOATS, Some(Default::default())).unwrap()} } #[inline] pub fn empty_string(&self) -> &'a str { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(MoreDefaults::VT_EMPTY_STRING, Some(&"")).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_EMPTY_STRING, Some(&"")).unwrap()} } #[inline] pub fn some_string(&self) -> &'a str { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(MoreDefaults::VT_SOME_STRING, Some(&"some")).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_SOME_STRING, Some(&"some")).unwrap()} } #[inline] - pub fn abcs(&self) -> flatbuffers::Vector<'a, ABC> { + pub fn abcs(&self) -> ::flatbuffers::Vector<'a, ABC> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(MoreDefaults::VT_ABCS, Some(Default::default())).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ABC>>>(MoreDefaults::VT_ABCS, Some(Default::default())).unwrap()} } #[inline] - pub fn bools(&self) -> flatbuffers::Vector<'a, bool> { + pub fn bools(&self) -> ::flatbuffers::Vector<'a, bool> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>>(MoreDefaults::VT_BOOLS, Some(Default::default())).unwrap()} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(MoreDefaults::VT_BOOLS, Some(Default::default())).unwrap()} } } -impl flatbuffers::Verifiable for MoreDefaults<'_> { +impl ::flatbuffers::Verifiable for MoreDefaults<'_> { #[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::>>("ints", Self::VT_INTS, false)? - .visit_field::>>("floats", Self::VT_FLOATS, false)? - .visit_field::>("empty_string", Self::VT_EMPTY_STRING, false)? - .visit_field::>("some_string", Self::VT_SOME_STRING, false)? - .visit_field::>>("abcs", Self::VT_ABCS, false)? - .visit_field::>>("bools", Self::VT_BOOLS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, i32>>>("ints", Self::VT_INTS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, f32>>>("floats", Self::VT_FLOATS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("empty_string", Self::VT_EMPTY_STRING, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("some_string", Self::VT_SOME_STRING, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ABC>>>("abcs", Self::VT_ABCS, false)? + .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("bools", Self::VT_BOOLS, false)? .finish(); Ok(()) } } pub struct MoreDefaultsArgs<'a> { - pub ints: Option>>, - pub floats: Option>>, - pub empty_string: Option>, - pub some_string: Option>, - pub abcs: Option>>, - pub bools: Option>>, + pub ints: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i32>>>, + pub floats: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f32>>>, + pub empty_string: Option<::flatbuffers::WIPOffset<&'a str>>, + pub some_string: Option<::flatbuffers::WIPOffset<&'a str>>, + pub abcs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ABC>>>, + pub bools: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, bool>>>, } impl<'a> Default for MoreDefaultsArgs<'a> { #[inline] @@ -173,37 +165,37 @@ impl<'a> Default for MoreDefaultsArgs<'a> { } } -pub struct MoreDefaultsBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct MoreDefaultsBuilder<'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> MoreDefaultsBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MoreDefaultsBuilder<'a, 'b, A> { #[inline] - pub fn add_ints(&mut self, ints: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_INTS, ints); + pub fn add_ints(&mut self, ints: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , i32>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_INTS, ints); } #[inline] - pub fn add_floats(&mut self, floats: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_FLOATS, floats); + pub fn add_floats(&mut self, floats: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , f32>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_FLOATS, floats); } #[inline] - pub fn add_empty_string(&mut self, empty_string: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_EMPTY_STRING, empty_string); + pub fn add_empty_string(&mut self, empty_string: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_EMPTY_STRING, empty_string); } #[inline] - pub fn add_some_string(&mut self, some_string: flatbuffers::WIPOffset<&'b str>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_SOME_STRING, some_string); + pub fn add_some_string(&mut self, some_string: ::flatbuffers::WIPOffset<&'b str>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_SOME_STRING, some_string); } #[inline] - pub fn add_abcs(&mut self, abcs: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_ABCS, abcs); + pub fn add_abcs(&mut self, abcs: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ABC>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_ABCS, abcs); } #[inline] - pub fn add_bools(&mut self, bools: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(MoreDefaults::VT_BOOLS, bools); + pub fn add_bools(&mut self, bools: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , bool>>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_BOOLS, bools); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> MoreDefaultsBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MoreDefaultsBuilder<'a, 'b, A> { let start = _fbb.start_table(); MoreDefaultsBuilder { fbb_: _fbb, @@ -211,14 +203,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> MoreDefaultsBuilder<'a, 'b, A> } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for MoreDefaults<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for MoreDefaults<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("MoreDefaults"); ds.field("ints", &self.ints()); ds.field("floats", &self.floats()); @@ -232,30 +224,30 @@ impl core::fmt::Debug for MoreDefaults<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct MoreDefaultsT { - pub ints: Vec, - pub floats: Vec, - pub empty_string: String, - pub some_string: String, - pub abcs: Vec, - pub bools: Vec, + pub ints: alloc::vec::Vec, + pub floats: alloc::vec::Vec, + pub empty_string: alloc::string::String, + pub some_string: alloc::string::String, + pub abcs: alloc::vec::Vec, + pub bools: alloc::vec::Vec, } impl Default for MoreDefaultsT { fn default() -> Self { Self { ints: Default::default(), floats: Default::default(), - empty_string: "".to_string(), - some_string: "some".to_string(), + empty_string: alloc::string::ToString::to_string(""), + some_string: alloc::string::ToString::to_string("some"), abcs: Default::default(), bools: Default::default(), } } } impl MoreDefaultsT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let ints = Some({ let x = &self.ints; _fbb.create_vector(x) diff --git a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs index 59277bd4081..450a6561a26 100644 --- a/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs +++ b/tests/namespace_test/namespace_a/namespace_b/enum_in_nested_ns_generated.rs @@ -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_ENUM_IN_NESTED_NS: i8 = 0; @@ -47,8 +40,8 @@ impl EnumInNestedNS { } } } -impl core::fmt::Debug for EnumInNestedNS { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for EnumInNestedNS { + 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 EnumInNestedNS { } } } -impl<'a> flatbuffers::Follow<'a> for EnumInNestedNS { +impl<'a> ::flatbuffers::Follow<'a> for EnumInNestedNS { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for EnumInNestedNS { +impl ::flatbuffers::Push for EnumInNestedNS { type Output = EnumInNestedNS; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for EnumInNestedNS { +impl ::flatbuffers::EndianScalar for EnumInNestedNS { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for EnumInNestedNS { } } -impl<'a> flatbuffers::Verifiable for EnumInNestedNS { +impl<'a> ::flatbuffers::Verifiable for EnumInNestedNS { #[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 EnumInNestedNS {} +impl ::flatbuffers::SimpleToVerifyInSlice for EnumInNestedNS {} diff --git a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs index db22105b8e7..375cd6fee9b 100644 --- a/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs +++ b/tests/namespace_test/namespace_a/namespace_b/struct_in_nested_ns_generated.rs @@ -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 StructInNestedNS, aligned to 4 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for StructInNestedNS { Self([0; 8]) } } -impl core::fmt::Debug for StructInNestedNS { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for StructInNestedNS { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("StructInNestedNS") .field("a", &self.a()) .field("b", &self.b()) @@ -27,40 +20,40 @@ impl core::fmt::Debug for StructInNestedNS { } } -impl flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {} -impl<'a> flatbuffers::Follow<'a> for StructInNestedNS { +impl ::flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {} +impl<'a> ::flatbuffers::Follow<'a> for StructInNestedNS { type Inner = &'a StructInNestedNS; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a StructInNestedNS>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a StructInNestedNS { +impl<'a> ::flatbuffers::Follow<'a> for &'a StructInNestedNS { type Inner = &'a StructInNestedNS; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for StructInNestedNS { +impl<'b> ::flatbuffers::Push for StructInNestedNS { type Output = StructInNestedNS; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, ::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 StructInNestedNS { +impl<'a> ::flatbuffers::Verifiable for StructInNestedNS { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -82,59 +75,59 @@ impl<'a> StructInNestedNS { } pub fn a(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_a(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn b(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_b(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs index 34c3794a594..e28dd2cb7cb 100644 --- a/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs +++ b/tests/namespace_test/namespace_a/namespace_b/table_in_nested_ns_generated.rs @@ -1,45 +1,38 @@ // 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 TableInNestedNSOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableInNestedNS<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableInNestedNS<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableInNestedNS<'a> { type Inner = TableInNestedNS<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableInNestedNS<'a> { - pub const VT_FOO: flatbuffers::VOffsetT = 4; + pub const VT_FOO: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "NamespaceA.NamespaceB.TableInNestedNS" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableInNestedNS { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableInNestedNSArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = TableInNestedNSBuilder::new(_fbb); builder.add_foo(args.foo); builder.finish() @@ -61,12 +54,11 @@ impl<'a> TableInNestedNS<'a> { } } -impl flatbuffers::Verifiable for TableInNestedNS<'_> { +impl ::flatbuffers::Verifiable for TableInNestedNS<'_> { #[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::("foo", Self::VT_FOO, false)? .finish(); @@ -85,17 +77,17 @@ impl<'a> Default for TableInNestedNSArgs { } } -pub struct TableInNestedNSBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableInNestedNSBuilder<'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> TableInNestedNSBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableInNestedNSBuilder<'a, 'b, A> { #[inline] pub fn add_foo(&mut self, foo: i32) { self.fbb_.push_slot::(TableInNestedNS::VT_FOO, foo, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableInNestedNSBuilder { fbb_: _fbb, @@ -103,14 +95,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInNestedNSBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableInNestedNS<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableInNestedNS<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableInNestedNS"); ds.field("foo", &self.foo()); ds.finish() @@ -129,10 +121,10 @@ impl Default for TableInNestedNST { } } impl TableInNestedNST { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let foo = self.foo; TableInNestedNS::create(_fbb, &TableInNestedNSArgs{ foo, diff --git a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs index c31674983f6..0b876d3a8d7 100644 --- a/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs +++ b/tests/namespace_test/namespace_a/namespace_b/union_in_nested_ns_generated.rs @@ -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_UNION_IN_NESTED_NS: u8 = 0; @@ -43,8 +36,8 @@ impl UnionInNestedNS { } } } -impl core::fmt::Debug for UnionInNestedNS { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for UnionInNestedNS { + 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 UnionInNestedNS { } } } -impl<'a> flatbuffers::Follow<'a> for UnionInNestedNS { +impl<'a> ::flatbuffers::Follow<'a> for UnionInNestedNS { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for UnionInNestedNS { +impl ::flatbuffers::Push for UnionInNestedNS { type Output = UnionInNestedNS; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for UnionInNestedNS { +impl ::flatbuffers::EndianScalar for UnionInNestedNS { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -83,17 +76,16 @@ impl flatbuffers::EndianScalar for UnionInNestedNS { } } -impl<'a> flatbuffers::Verifiable for UnionInNestedNS { +impl<'a> ::flatbuffers::Verifiable for UnionInNestedNS { #[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 UnionInNestedNS {} +impl ::flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {} pub struct UnionInNestedNSUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -101,7 +93,7 @@ pub struct UnionInNestedNSUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum UnionInNestedNST { NONE, - TableInNestedNS(Box), + TableInNestedNS(alloc::boxed::Box), } impl Default for UnionInNestedNST { fn default() -> Self { @@ -115,16 +107,16 @@ impl UnionInNestedNST { Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::TableInNestedNS(v) => Some(v.pack(fbb).as_union_value()), } } /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE. - pub fn take_table_in_nested_ns(&mut self) -> Option> { + pub fn take_table_in_nested_ns(&mut self) -> Option> { if let Self::TableInNestedNS(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::TableInNestedNS(w) = v { Some(w) } else { diff --git a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs index 495b866cbf4..335edac8cca 100644 --- a/tests/namespace_test/namespace_a/second_table_in_a_generated.rs +++ b/tests/namespace_test/namespace_a/second_table_in_a_generated.rs @@ -1,45 +1,38 @@ // 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 SecondTableInAOffset {} #[derive(Copy, Clone, PartialEq)] pub struct SecondTableInA<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for SecondTableInA<'a> { +impl<'a> ::flatbuffers::Follow<'a> for SecondTableInA<'a> { type Inner = SecondTableInA<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> SecondTableInA<'a> { - pub const VT_REFER_TO_C: flatbuffers::VOffsetT = 4; + pub const VT_REFER_TO_C: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "NamespaceA.SecondTableInA" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { SecondTableInA { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 SecondTableInAArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = SecondTableInABuilder::new(_fbb); if let Some(x) = args.refer_to_c { builder.add_refer_to_c(x); } builder.finish() @@ -47,7 +40,7 @@ impl<'a> SecondTableInA<'a> { pub fn unpack(&self) -> SecondTableInAT { let refer_to_c = self.refer_to_c().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); SecondTableInAT { refer_to_c, @@ -59,24 +52,23 @@ impl<'a> SecondTableInA<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(SecondTableInA::VT_REFER_TO_C, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(SecondTableInA::VT_REFER_TO_C, None)} } } -impl flatbuffers::Verifiable for SecondTableInA<'_> { +impl ::flatbuffers::Verifiable for SecondTableInA<'_> { #[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::>("refer_to_c", Self::VT_REFER_TO_C, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("refer_to_c", Self::VT_REFER_TO_C, false)? .finish(); Ok(()) } } pub struct SecondTableInAArgs<'a> { - pub refer_to_c: Option>>, + pub refer_to_c: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for SecondTableInAArgs<'a> { #[inline] @@ -87,17 +79,17 @@ impl<'a> Default for SecondTableInAArgs<'a> { } } -pub struct SecondTableInABuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct SecondTableInABuilder<'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> SecondTableInABuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> SecondTableInABuilder<'a, 'b, A> { #[inline] - pub fn add_refer_to_c(&mut self, refer_to_c: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(SecondTableInA::VT_REFER_TO_C, refer_to_c); + pub fn add_refer_to_c(&mut self, refer_to_c: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(SecondTableInA::VT_REFER_TO_C, refer_to_c); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> SecondTableInABuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> SecondTableInABuilder<'a, 'b, A> { let start = _fbb.start_table(); SecondTableInABuilder { fbb_: _fbb, @@ -105,14 +97,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> SecondTableInABuilder<'a, 'b, A } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for SecondTableInA<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for SecondTableInA<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("SecondTableInA"); ds.field("refer_to_c", &self.refer_to_c()); ds.finish() @@ -121,7 +113,7 @@ impl core::fmt::Debug for SecondTableInA<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct SecondTableInAT { - pub refer_to_c: Option>, + pub refer_to_c: Option>, } impl Default for SecondTableInAT { fn default() -> Self { @@ -131,10 +123,10 @@ impl Default for SecondTableInAT { } } impl SecondTableInAT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let refer_to_c = self.refer_to_c.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs index 351009ac6a7..7eb19c6d1eb 100644 --- a/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs +++ b/tests/namespace_test/namespace_a/table_in_first_ns_generated.rs @@ -1,49 +1,42 @@ // 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 TableInFirstNSOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableInFirstNS<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableInFirstNS<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableInFirstNS<'a> { type Inner = TableInFirstNS<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableInFirstNS<'a> { - 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; + 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; pub const fn get_fully_qualified_name() -> &'static str { "NamespaceA.TableInFirstNS" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableInFirstNS { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableInFirstNSArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { 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); } @@ -55,12 +48,12 @@ impl<'a> TableInFirstNS<'a> { pub fn unpack(&self) -> TableInFirstNST { let foo_table = self.foo_table().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let foo_enum = self.foo_enum(); let foo_union = match self.foo_union_type() { namespace_b::UnionInNestedNS::NONE => namespace_b::UnionInNestedNST::NONE, - namespace_b::UnionInNestedNS::TableInNestedNS => namespace_b::UnionInNestedNST::TableInNestedNS(Box::new( + namespace_b::UnionInNestedNS::TableInNestedNS => namespace_b::UnionInNestedNST::TableInNestedNS(alloc::boxed::Box::new( self.foo_union_as_table_in_nested_ns() .expect("Invalid union table, expected `namespace_b::UnionInNestedNS::TableInNestedNS`.") .unpack() @@ -83,7 +76,7 @@ impl<'a> TableInFirstNS<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableInFirstNS::VT_FOO_TABLE, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableInFirstNS::VT_FOO_TABLE, None)} } #[inline] pub fn foo_enum(&self) -> namespace_b::EnumInNestedNS { @@ -100,11 +93,11 @@ impl<'a> TableInFirstNS<'a> { unsafe { self._tab.get::(TableInFirstNS::VT_FOO_UNION_TYPE, Some(namespace_b::UnionInNestedNS::NONE)).unwrap()} } #[inline] - pub fn foo_union(&self) -> Option> { + pub fn foo_union(&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::>>(TableInFirstNS::VT_FOO_UNION, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(TableInFirstNS::VT_FOO_UNION, None)} } #[inline] pub fn foo_struct(&self) -> Option<&'a namespace_b::StructInNestedNS> { @@ -130,18 +123,17 @@ impl<'a> TableInFirstNS<'a> { } -impl flatbuffers::Verifiable for TableInFirstNS<'_> { +impl ::flatbuffers::Verifiable for TableInFirstNS<'_> { #[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::>("foo_table", Self::VT_FOO_TABLE, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("foo_table", Self::VT_FOO_TABLE, false)? .visit_field::("foo_enum", Self::VT_FOO_ENUM, false)? .visit_union::("foo_union_type", Self::VT_FOO_UNION_TYPE, "foo_union", Self::VT_FOO_UNION, false, |key, v, pos| { match key { - namespace_b::UnionInNestedNS::TableInNestedNS => v.verify_union_variant::>("namespace_b::UnionInNestedNS::TableInNestedNS", pos), + namespace_b::UnionInNestedNS::TableInNestedNS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("namespace_b::UnionInNestedNS::TableInNestedNS", pos), _ => Ok(()), } })? @@ -151,10 +143,10 @@ impl flatbuffers::Verifiable for TableInFirstNS<'_> { } } pub struct TableInFirstNSArgs<'a> { - pub foo_table: Option>>, + pub foo_table: Option<::flatbuffers::WIPOffset>>, pub foo_enum: namespace_b::EnumInNestedNS, pub foo_union_type: namespace_b::UnionInNestedNS, - pub foo_union: Option>, + pub foo_union: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, pub foo_struct: Option<&'a namespace_b::StructInNestedNS>, } impl<'a> Default for TableInFirstNSArgs<'a> { @@ -170,14 +162,14 @@ impl<'a> Default for TableInFirstNSArgs<'a> { } } -pub struct TableInFirstNSBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableInFirstNSBuilder<'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> TableInFirstNSBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableInFirstNSBuilder<'a, 'b, A> { #[inline] - pub fn add_foo_table(&mut self, foo_table: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableInFirstNS::VT_FOO_TABLE, foo_table); + pub fn add_foo_table(&mut self, foo_table: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableInFirstNS::VT_FOO_TABLE, foo_table); } #[inline] pub fn add_foo_enum(&mut self, foo_enum: namespace_b::EnumInNestedNS) { @@ -188,15 +180,15 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInFirstNSBuilder<'a, 'b, A self.fbb_.push_slot::(TableInFirstNS::VT_FOO_UNION_TYPE, foo_union_type, namespace_b::UnionInNestedNS::NONE); } #[inline] - pub fn add_foo_union(&mut self, foo_union: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(TableInFirstNS::VT_FOO_UNION, foo_union); + pub fn add_foo_union(&mut self, foo_union: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(TableInFirstNS::VT_FOO_UNION, foo_union); } #[inline] pub fn add_foo_struct(&mut self, foo_struct: &namespace_b::StructInNestedNS) { self.fbb_.push_slot_always::<&namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, foo_struct); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableInFirstNSBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInFirstNSBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableInFirstNSBuilder { fbb_: _fbb, @@ -204,14 +196,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInFirstNSBuilder<'a, 'b, A } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableInFirstNS<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableInFirstNS<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableInFirstNS"); ds.field("foo_table", &self.foo_table()); ds.field("foo_enum", &self.foo_enum()); @@ -236,7 +228,7 @@ impl core::fmt::Debug for TableInFirstNS<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableInFirstNST { - pub foo_table: Option>, + pub foo_table: Option>, pub foo_enum: namespace_b::EnumInNestedNS, pub foo_union: namespace_b::UnionInNestedNST, pub foo_struct: Option, @@ -252,10 +244,10 @@ impl Default for TableInFirstNST { } } impl TableInFirstNST { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let foo_table = self.foo_table.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/namespace_test/namespace_c/table_in_c_generated.rs b/tests/namespace_test/namespace_c/table_in_c_generated.rs index e8062415322..96c6b5dd5d7 100644 --- a/tests/namespace_test/namespace_c/table_in_c_generated.rs +++ b/tests/namespace_test/namespace_c/table_in_c_generated.rs @@ -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 TableInCOffset {} #[derive(Copy, Clone, PartialEq)] pub struct TableInC<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for TableInC<'a> { +impl<'a> ::flatbuffers::Follow<'a> for TableInC<'a> { type Inner = TableInC<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> TableInC<'a> { - pub const VT_REFER_TO_A1: flatbuffers::VOffsetT = 4; - pub const VT_REFER_TO_A2: flatbuffers::VOffsetT = 6; + pub const VT_REFER_TO_A1: ::flatbuffers::VOffsetT = 4; + pub const VT_REFER_TO_A2: ::flatbuffers::VOffsetT = 6; pub const fn get_fully_qualified_name() -> &'static str { "NamespaceC.TableInC" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { TableInC { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 TableInCArgs<'args> - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { 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); } @@ -49,10 +42,10 @@ impl<'a> TableInC<'a> { pub fn unpack(&self) -> TableInCT { let refer_to_a1 = self.refer_to_a1().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); let refer_to_a2 = self.refer_to_a2().map(|x| { - Box::new(x.unpack()) + alloc::boxed::Box::new(x.unpack()) }); TableInCT { refer_to_a1, @@ -65,33 +58,32 @@ impl<'a> TableInC<'a> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableInC::VT_REFER_TO_A1, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableInC::VT_REFER_TO_A1, None)} } #[inline] pub fn refer_to_a2(&self) -> Option> { // Safety: // Created from valid Table for this object // which contains a valid value in this slot - unsafe { self._tab.get::>(TableInC::VT_REFER_TO_A2, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset>(TableInC::VT_REFER_TO_A2, None)} } } -impl flatbuffers::Verifiable for TableInC<'_> { +impl ::flatbuffers::Verifiable for TableInC<'_> { #[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::>("refer_to_a1", Self::VT_REFER_TO_A1, false)? - .visit_field::>("refer_to_a2", Self::VT_REFER_TO_A2, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("refer_to_a1", Self::VT_REFER_TO_A1, false)? + .visit_field::<::flatbuffers::ForwardsUOffset>("refer_to_a2", Self::VT_REFER_TO_A2, false)? .finish(); Ok(()) } } pub struct TableInCArgs<'a> { - pub refer_to_a1: Option>>, - pub refer_to_a2: Option>>, + pub refer_to_a1: Option<::flatbuffers::WIPOffset>>, + pub refer_to_a2: Option<::flatbuffers::WIPOffset>>, } impl<'a> Default for TableInCArgs<'a> { #[inline] @@ -103,21 +95,21 @@ impl<'a> Default for TableInCArgs<'a> { } } -pub struct TableInCBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct TableInCBuilder<'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> TableInCBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableInCBuilder<'a, 'b, A> { #[inline] - pub fn add_refer_to_a1(&mut self, refer_to_a1: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableInC::VT_REFER_TO_A1, refer_to_a1); + pub fn add_refer_to_a1(&mut self, refer_to_a1: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableInC::VT_REFER_TO_A1, refer_to_a1); } #[inline] - pub fn add_refer_to_a2(&mut self, refer_to_a2: flatbuffers::WIPOffset>) { - self.fbb_.push_slot_always::>(TableInC::VT_REFER_TO_A2, refer_to_a2); + pub fn add_refer_to_a2(&mut self, refer_to_a2: ::flatbuffers::WIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset>(TableInC::VT_REFER_TO_A2, refer_to_a2); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> TableInCBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInCBuilder<'a, 'b, A> { let start = _fbb.start_table(); TableInCBuilder { fbb_: _fbb, @@ -125,14 +117,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> TableInCBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for TableInC<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for TableInC<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("TableInC"); ds.field("refer_to_a1", &self.refer_to_a1()); ds.field("refer_to_a2", &self.refer_to_a2()); @@ -142,8 +134,8 @@ impl core::fmt::Debug for TableInC<'_> { #[non_exhaustive] #[derive(Debug, Clone, PartialEq)] pub struct TableInCT { - pub refer_to_a1: Option>, - pub refer_to_a2: Option>, + pub refer_to_a1: Option>, + pub refer_to_a2: Option>, } impl Default for TableInCT { fn default() -> Self { @@ -154,10 +146,10 @@ impl Default for TableInCT { } } impl TableInCT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let refer_to_a1 = self.refer_to_a1.as_ref().map(|x|{ x.pack(_fbb) }); diff --git a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs index 9cb47c699f2..af48629aba2 100644 --- a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs +++ b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs @@ -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_OPTIONAL_BYTE: i8 = 0; @@ -47,8 +40,8 @@ impl OptionalByte { } } } -impl core::fmt::Debug for OptionalByte { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for OptionalByte { + 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 OptionalByte { } } } -impl<'a> flatbuffers::Follow<'a> for OptionalByte { +impl<'a> ::flatbuffers::Follow<'a> for OptionalByte { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for OptionalByte { +impl ::flatbuffers::Push for OptionalByte { type Output = OptionalByte; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for OptionalByte { +impl ::flatbuffers::EndianScalar for OptionalByte { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -87,14 +80,13 @@ impl flatbuffers::EndianScalar for OptionalByte { } } -impl<'a> flatbuffers::Verifiable for OptionalByte { +impl<'a> ::flatbuffers::Verifiable for OptionalByte { #[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 OptionalByte {} +impl ::flatbuffers::SimpleToVerifyInSlice for OptionalByte {} diff --git a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs index f5e71f80248..2c8a4ff9358 100644 --- a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs +++ b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs @@ -1,80 +1,73 @@ // 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 ScalarStuffOffset {} #[derive(Copy, Clone, PartialEq)] pub struct ScalarStuff<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for ScalarStuff<'a> { +impl<'a> ::flatbuffers::Follow<'a> for ScalarStuff<'a> { type Inner = ScalarStuff<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> ScalarStuff<'a> { - 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; + 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; pub const fn get_fully_qualified_name() -> &'static str { "optional_scalars.ScalarStuff" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { ScalarStuff { _tab: table } } #[allow(unused_mut)] - pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, 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 ScalarStuffArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { 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); } @@ -446,12 +439,11 @@ impl<'a> ScalarStuff<'a> { } } -impl flatbuffers::Verifiable for ScalarStuff<'_> { +impl ::flatbuffers::Verifiable for ScalarStuff<'_> { #[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::("just_i8", Self::VT_JUST_I8, false)? .visit_field::("maybe_i8", Self::VT_MAYBE_I8, false)? @@ -575,11 +567,11 @@ impl<'a> Default for ScalarStuffArgs { } } -pub struct ScalarStuffBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct ScalarStuffBuilder<'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> ScalarStuffBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> ScalarStuffBuilder<'a, 'b, A> { #[inline] pub fn add_just_i8(&mut self, just_i8: i8) { self.fbb_.push_slot::(ScalarStuff::VT_JUST_I8, just_i8, 0); @@ -725,7 +717,7 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ScalarStuffBuilder<'a, 'b, A> { self.fbb_.push_slot::(ScalarStuff::VT_DEFAULT_ENUM, default_enum, OptionalByte::One); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarStuffBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarStuffBuilder<'a, 'b, A> { let start = _fbb.start_table(); ScalarStuffBuilder { fbb_: _fbb, @@ -733,14 +725,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> ScalarStuffBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for ScalarStuff<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for ScalarStuff<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("ScalarStuff"); ds.field("just_i8", &self.just_i8()); ds.field("maybe_i8", &self.maybe_i8()); @@ -864,10 +856,10 @@ impl Default for ScalarStuffT { } } impl ScalarStuffT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let just_i8 = self.just_i8; let maybe_i8 = self.maybe_i8; let default_i8 = self.default_i8; @@ -951,8 +943,8 @@ impl ScalarStuffT { /// catch every error, or be maximally performant. For the /// previous, unchecked, behavior use /// `root_as_scalar_stuff_unchecked`. -pub fn root_as_scalar_stuff(buf: &[u8]) -> Result { - flatbuffers::root::(buf) +pub fn root_as_scalar_stuff(buf: &[u8]) -> Result { + ::flatbuffers::root::(buf) } #[inline] /// Verifies that a buffer of bytes contains a size prefixed @@ -961,8 +953,8 @@ pub fn root_as_scalar_stuff(buf: &[u8]) -> Result Result { - flatbuffers::size_prefixed_root::(buf) +pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result { + ::flatbuffers::size_prefixed_root::(buf) } #[inline] /// Verifies, with the given options, that a buffer of bytes @@ -972,10 +964,10 @@ pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::root_with_opts::>(opts, buf) } #[inline] /// Verifies, with the given verifier options, that a buffer of @@ -985,47 +977,47 @@ pub fn root_as_scalar_stuff_with_opts<'b, 'o>( /// previous, unchecked, behavior use /// `root_as_scalar_stuff_unchecked`. pub fn size_prefixed_root_as_scalar_stuff_with_opts<'b, 'o>( - opts: &'o flatbuffers::VerifierOptions, + opts: &'o ::flatbuffers::VerifierOptions, buf: &'b [u8], -) -> Result, flatbuffers::InvalidFlatbuffer> { - flatbuffers::size_prefixed_root_with_opts::>(opts, buf) +) -> Result, ::flatbuffers::InvalidFlatbuffer> { + ::flatbuffers::size_prefixed_root_with_opts::>(opts, buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a ScalarStuff and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid `ScalarStuff`. pub unsafe fn root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff { - flatbuffers::root_unchecked::(buf) + ::flatbuffers::root_unchecked::(buf) } #[inline] /// Assumes, without verification, that a buffer of bytes contains a size prefixed ScalarStuff and returns it. /// # Safety /// Callers must trust the given bytes do indeed contain a valid size prefixed `ScalarStuff`. pub unsafe fn size_prefixed_root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff { - flatbuffers::size_prefixed_root_unchecked::(buf) + ::flatbuffers::size_prefixed_root_unchecked::(buf) } pub const SCALAR_STUFF_IDENTIFIER: &str = "NULL"; #[inline] pub fn scalar_stuff_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, SCALAR_STUFF_IDENTIFIER, false) + ::flatbuffers::buffer_has_identifier(buf, SCALAR_STUFF_IDENTIFIER, false) } #[inline] pub fn scalar_stuff_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool { - flatbuffers::buffer_has_identifier(buf, SCALAR_STUFF_IDENTIFIER, true) + ::flatbuffers::buffer_has_identifier(buf, SCALAR_STUFF_IDENTIFIER, true) } pub const SCALAR_STUFF_EXTENSION: &str = "mon"; #[inline] -pub fn finish_scalar_stuff_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>( - fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - root: flatbuffers::WIPOffset>) { +pub fn finish_scalar_stuff_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>( + fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, + root: ::flatbuffers::WIPOffset>) { fbb.finish(root, Some(SCALAR_STUFF_IDENTIFIER)); } #[inline] -pub fn finish_size_prefixed_scalar_stuff_buffer<'a, 'b, A: flatbuffers::Allocator + 'a>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, root: flatbuffers::WIPOffset>) { +pub fn finish_size_prefixed_scalar_stuff_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset>) { fbb.finish_size_prefixed(root, Some(SCALAR_STUFF_IDENTIFIER)); } diff --git a/tests/private_annotation_test/ab_generated.rs b/tests/private_annotation_test/ab_generated.rs index f2246488f83..9e8ecf6756f 100644 --- a/tests/private_annotation_test/ab_generated.rs +++ b/tests/private_annotation_test/ab_generated.rs @@ -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_AB: i8 = 0; @@ -43,8 +36,8 @@ impl AB { } } } -impl core::fmt::Debug for AB { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for AB { + 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 AB { } } } -impl<'a> flatbuffers::Follow<'a> for AB { +impl<'a> ::flatbuffers::Follow<'a> for AB { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for AB { +impl ::flatbuffers::Push for AB { type Output = AB; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for AB { +impl ::flatbuffers::EndianScalar for AB { type Scalar = i8; #[inline] fn to_little_endian(self) -> i8 { @@ -83,14 +76,13 @@ impl flatbuffers::EndianScalar for AB { } } -impl<'a> flatbuffers::Verifiable for AB { +impl<'a> ::flatbuffers::Verifiable for AB { #[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 AB {} +impl ::flatbuffers::SimpleToVerifyInSlice for AB {} diff --git a/tests/private_annotation_test/annotations_generated.rs b/tests/private_annotation_test/annotations_generated.rs index 324475632db..032497583c4 100644 --- a/tests/private_annotation_test/annotations_generated.rs +++ b/tests/private_annotation_test/annotations_generated.rs @@ -1,45 +1,38 @@ // 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(crate) enum AnnotationsOffset {} #[derive(Copy, Clone, PartialEq)] pub(crate) struct Annotations<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Annotations<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Annotations<'a> { type Inner = Annotations<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Annotations<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; + pub const VT_VALUE: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "Annotations" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Annotations { _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 AnnotationsArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = AnnotationsBuilder::new(_fbb); builder.add_value(args.value); builder.finish() @@ -61,12 +54,11 @@ impl<'a> Annotations<'a> { } } -impl flatbuffers::Verifiable for Annotations<'_> { +impl ::flatbuffers::Verifiable for Annotations<'_> { #[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::("value", Self::VT_VALUE, false)? .finish(); @@ -85,17 +77,17 @@ impl<'a> Default for AnnotationsArgs { } } -pub(crate) struct AnnotationsBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub(crate) struct AnnotationsBuilder<'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> AnnotationsBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> AnnotationsBuilder<'a, 'b, A> { #[inline] pub fn add_value(&mut self, value: i32) { self.fbb_.push_slot::(Annotations::VT_VALUE, value, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> AnnotationsBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> AnnotationsBuilder<'a, 'b, A> { let start = _fbb.start_table(); AnnotationsBuilder { fbb_: _fbb, @@ -103,14 +95,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> AnnotationsBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Annotations<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Annotations<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Annotations"); ds.field("value", &self.value()); ds.finish() @@ -129,10 +121,10 @@ impl Default for AnnotationsT { } } impl AnnotationsT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let value = self.value; Annotations::create(_fbb, &AnnotationsArgs{ value, diff --git a/tests/private_annotation_test/any_generated.rs b/tests/private_annotation_test/any_generated.rs index e7dcf9d903e..3ad2bd0ac2b 100644 --- a/tests/private_annotation_test/any_generated.rs +++ b/tests/private_annotation_test/any_generated.rs @@ -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_ANY: u8 = 0; @@ -47,8 +40,8 @@ impl Any { } } } -impl core::fmt::Debug for Any { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Any { + 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 Any { } } } -impl<'a> flatbuffers::Follow<'a> for Any { +impl<'a> ::flatbuffers::Follow<'a> for Any { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for Any { +impl ::flatbuffers::Push for Any { type Output = Any; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for Any { +impl ::flatbuffers::EndianScalar for Any { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -87,17 +80,16 @@ impl flatbuffers::EndianScalar for Any { } } -impl<'a> flatbuffers::Verifiable for Any { +impl<'a> ::flatbuffers::Verifiable for Any { #[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 Any {} +impl ::flatbuffers::SimpleToVerifyInSlice for Any {} pub(crate) struct AnyUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -105,8 +97,8 @@ pub(crate) struct AnyUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub(crate) enum AnyT { NONE, - Game(Box), - Annotations(Box), + Game(alloc::boxed::Box), + Annotations(alloc::boxed::Box), } impl Default for AnyT { fn default() -> Self { @@ -121,7 +113,7 @@ impl AnyT { Self::Annotations(_) => Any::Annotations, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::Game(v) => Some(v.pack(fbb).as_union_value()), @@ -129,9 +121,9 @@ impl AnyT { } } /// If the union variant matches, return the owned GameT, setting the union to NONE. - pub fn take_game(&mut self) -> Option> { + pub fn take_game(&mut self) -> Option> { if let Self::Game(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Game(w) = v { Some(w) } else { @@ -150,9 +142,9 @@ impl AnyT { if let Self::Game(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned AnnotationsT, setting the union to NONE. - pub fn take_annotations(&mut self) -> Option> { + pub fn take_annotations(&mut self) -> Option> { if let Self::Annotations(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::Annotations(w) = v { Some(w) } else { diff --git a/tests/private_annotation_test/game_generated.rs b/tests/private_annotation_test/game_generated.rs index 24d3b0f04a2..2289d14a7a8 100644 --- a/tests/private_annotation_test/game_generated.rs +++ b/tests/private_annotation_test/game_generated.rs @@ -1,45 +1,38 @@ // 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(crate) enum GameOffset {} #[derive(Copy, Clone, PartialEq)] pub(crate) struct Game<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for Game<'a> { +impl<'a> ::flatbuffers::Follow<'a> for Game<'a> { type Inner = Game<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> Game<'a> { - pub const VT_VALUE: flatbuffers::VOffsetT = 4; + pub const VT_VALUE: ::flatbuffers::VOffsetT = 4; pub const fn get_fully_qualified_name() -> &'static str { "Game" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { Game { _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 GameArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = GameBuilder::new(_fbb); builder.add_value(args.value); builder.finish() @@ -61,12 +54,11 @@ impl<'a> Game<'a> { } } -impl flatbuffers::Verifiable for Game<'_> { +impl ::flatbuffers::Verifiable for Game<'_> { #[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::("value", Self::VT_VALUE, false)? .finish(); @@ -85,17 +77,17 @@ impl<'a> Default for GameArgs { } } -pub(crate) struct GameBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub(crate) struct GameBuilder<'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> GameBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GameBuilder<'a, 'b, A> { #[inline] pub fn add_value(&mut self, value: i32) { self.fbb_.push_slot::(Game::VT_VALUE, value, 0); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> GameBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GameBuilder<'a, 'b, A> { let start = _fbb.start_table(); GameBuilder { fbb_: _fbb, @@ -103,14 +95,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> GameBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for Game<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for Game<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("Game"); ds.field("value", &self.value()); ds.finish() @@ -129,10 +121,10 @@ impl Default for GameT { } } impl GameT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let value = self.value; Game::create(_fbb, &GameArgs{ value, diff --git a/tests/private_annotation_test/object_generated.rs b/tests/private_annotation_test/object_generated.rs index 382b0e42e92..9cdc3922aee 100644 --- a/tests/private_annotation_test/object_generated.rs +++ b/tests/private_annotation_test/object_generated.rs @@ -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 Object, aligned to 4 #[repr(transparent)] @@ -18,48 +11,48 @@ impl Default for Object { Self([0; 4]) } } -impl core::fmt::Debug for Object { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for Object { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("Object") .field("value", &self.value()) .finish() } } -impl flatbuffers::SimpleToVerifyInSlice for Object {} -impl<'a> flatbuffers::Follow<'a> for Object { +impl ::flatbuffers::SimpleToVerifyInSlice for Object {} +impl<'a> ::flatbuffers::Follow<'a> for Object { type Inner = &'a Object; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a Object>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a Object { +impl<'a> ::flatbuffers::Follow<'a> for &'a Object { type Inner = &'a Object; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for Object { +impl<'b> ::flatbuffers::Push for Object { type Output = Object; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const Object as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const Object as *const u8, ::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 Object { +impl<'a> ::flatbuffers::Verifiable for Object { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -79,30 +72,30 @@ impl<'a> Object { } pub fn value(&self) -> i32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_value(&mut self, x: i32) { - 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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/rust_namer_test/rust_namer_test/field_table_generated.rs b/tests/rust_namer_test/rust_namer_test/field_table_generated.rs index 1355886f215..ca34c8cdd44 100644 --- a/tests/rust_namer_test/rust_namer_test/field_table_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/field_table_generated.rs @@ -1,26 +1,19 @@ // 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 FieldTableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct FieldTable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for FieldTable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for FieldTable<'a> { type Inner = FieldTable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> FieldTable<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { FieldTable { _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 FieldTableArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = FieldTableBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ impl<'a> FieldTable<'a> { } } -impl flatbuffers::Verifiable for FieldTable<'_> { +impl ::flatbuffers::Verifiable for FieldTable<'_> { #[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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for FieldTableArgs { } } -pub struct FieldTableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct FieldTableBuilder<'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> FieldTableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> FieldTableBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> FieldTableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FieldTableBuilder<'a, 'b, A> { let start = _fbb.start_table(); FieldTableBuilder { fbb_: _fbb, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> FieldTableBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for FieldTable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for FieldTable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("FieldTable"); ds.finish() } @@ -107,10 +99,10 @@ impl Default for FieldTableT { } } impl FieldTableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { FieldTable::create(_fbb, &FieldTableArgs{ }) } diff --git a/tests/rust_namer_test/rust_namer_test/field_union_generated.rs b/tests/rust_namer_test/rust_namer_test/field_union_generated.rs index 706095e4fff..82f9772732b 100644 --- a/tests/rust_namer_test/rust_namer_test/field_union_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/field_union_generated.rs @@ -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_FIELD_UNION: u8 = 0; @@ -43,8 +36,8 @@ impl FieldUnion { } } } -impl core::fmt::Debug for FieldUnion { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for FieldUnion { + 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 FieldUnion { } } } -impl<'a> flatbuffers::Follow<'a> for FieldUnion { +impl<'a> ::flatbuffers::Follow<'a> for FieldUnion { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for FieldUnion { +impl ::flatbuffers::Push for FieldUnion { type Output = FieldUnion; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for FieldUnion { +impl ::flatbuffers::EndianScalar for FieldUnion { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -83,17 +76,16 @@ impl flatbuffers::EndianScalar for FieldUnion { } } -impl<'a> flatbuffers::Verifiable for FieldUnion { +impl<'a> ::flatbuffers::Verifiable for FieldUnion { #[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 FieldUnion {} +impl ::flatbuffers::SimpleToVerifyInSlice for FieldUnion {} pub struct FieldUnionUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -101,7 +93,7 @@ pub struct FieldUnionUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum FieldUnionT { NONE, - F(Box), + F(alloc::boxed::Box), } impl Default for FieldUnionT { fn default() -> Self { @@ -115,16 +107,16 @@ impl FieldUnionT { Self::F(_) => FieldUnion::f, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::F(v) => Some(v.pack(fbb).as_union_value()), } } /// If the union variant matches, return the owned FieldTableT, setting the union to NONE. - pub fn take_f(&mut self) -> Option> { + pub fn take_f(&mut self) -> Option> { if let Self::F(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::F(w) = v { Some(w) } else { diff --git a/tests/rust_namer_test/rust_namer_test/game_message_generated.rs b/tests/rust_namer_test/rust_namer_test/game_message_generated.rs index dfab0ec3132..a2c3cbceb9b 100644 --- a/tests/rust_namer_test/rust_namer_test/game_message_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/game_message_generated.rs @@ -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_GAME_MESSAGE: u8 = 0; @@ -51,8 +44,8 @@ impl GameMessage { } } } -impl core::fmt::Debug for GameMessage { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for GameMessage { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { if let Some(name) = self.variant_name() { f.write_str(name) } else { @@ -60,24 +53,24 @@ impl core::fmt::Debug for GameMessage { } } } -impl<'a> flatbuffers::Follow<'a> for GameMessage { +impl<'a> ::flatbuffers::Follow<'a> for GameMessage { type Inner = Self; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - let b = flatbuffers::read_scalar_at::(buf, loc); + let b = ::flatbuffers::read_scalar_at::(buf, loc); Self(b) } } -impl flatbuffers::Push for GameMessage { +impl ::flatbuffers::Push for GameMessage { type Output = GameMessage; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - flatbuffers::emplace_scalar::(dst, self.0); + ::flatbuffers::emplace_scalar::(dst, self.0); } } -impl flatbuffers::EndianScalar for GameMessage { +impl ::flatbuffers::EndianScalar for GameMessage { type Scalar = u8; #[inline] fn to_little_endian(self) -> u8 { @@ -91,17 +84,16 @@ impl flatbuffers::EndianScalar for GameMessage { } } -impl<'a> flatbuffers::Verifiable for GameMessage { +impl<'a> ::flatbuffers::Verifiable for GameMessage { #[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 GameMessage {} +impl ::flatbuffers::SimpleToVerifyInSlice for GameMessage {} pub struct GameMessageUnionTableOffset {} #[allow(clippy::upper_case_acronyms)] @@ -109,9 +101,9 @@ pub struct GameMessageUnionTableOffset {} #[derive(Debug, Clone, PartialEq)] pub enum GameMessageT { NONE, - PlayerStatEvent(Box), - PlayerSpectate(Box), - PlayerInputChange(Box), + PlayerStatEvent(alloc::boxed::Box), + PlayerSpectate(alloc::boxed::Box), + PlayerInputChange(alloc::boxed::Box), } impl Default for GameMessageT { fn default() -> Self { @@ -127,7 +119,7 @@ impl GameMessageT { Self::PlayerInputChange(_) => GameMessage::PlayerInputChange, } } - pub fn pack<'b, A: flatbuffers::Allocator + 'b>(&self, fbb: &mut flatbuffers::FlatBufferBuilder<'b, A>) -> Option> { + 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::PlayerStatEvent(v) => Some(v.pack(fbb).as_union_value()), @@ -136,9 +128,9 @@ impl GameMessageT { } } /// If the union variant matches, return the owned PlayerStatEventT, setting the union to NONE. - pub fn take_player_stat_event(&mut self) -> Option> { + pub fn take_player_stat_event(&mut self) -> Option> { if let Self::PlayerStatEvent(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::PlayerStatEvent(w) = v { Some(w) } else { @@ -157,9 +149,9 @@ impl GameMessageT { if let Self::PlayerStatEvent(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned PlayerSpectateT, setting the union to NONE. - pub fn take_player_spectate(&mut self) -> Option> { + pub fn take_player_spectate(&mut self) -> Option> { if let Self::PlayerSpectate(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::PlayerSpectate(w) = v { Some(w) } else { @@ -178,9 +170,9 @@ impl GameMessageT { if let Self::PlayerSpectate(v) = self { Some(v.as_mut()) } else { None } } /// If the union variant matches, return the owned PlayerInputChangeT, setting the union to NONE. - pub fn take_player_input_change(&mut self) -> Option> { + pub fn take_player_input_change(&mut self) -> Option> { if let Self::PlayerInputChange(_) = self { - let v = core::mem::replace(self, Self::NONE); + let v = ::core::mem::replace(self, Self::NONE); if let Self::PlayerInputChange(w) = v { Some(w) } else { diff --git a/tests/rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs b/tests/rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs index ea3c2b20873..9ca9551c4dc 100644 --- a/tests/rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/game_message_wrapper_generated.rs @@ -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 GameMessageWrapperOffset {} #[derive(Copy, Clone, PartialEq)] pub struct GameMessageWrapper<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for GameMessageWrapper<'a> { +impl<'a> ::flatbuffers::Follow<'a> for GameMessageWrapper<'a> { type Inner = GameMessageWrapper<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> GameMessageWrapper<'a> { - pub const VT_MESSAGE_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_MESSAGE: flatbuffers::VOffsetT = 6; + pub const VT_MESSAGE_TYPE: ::flatbuffers::VOffsetT = 4; + pub const VT_MESSAGE: ::flatbuffers::VOffsetT = 6; pub const fn get_fully_qualified_name() -> &'static str { "RustNamerTest.GameMessageWrapper" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { GameMessageWrapper { _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 GameMessageWrapperArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = GameMessageWrapperBuilder::new(_fbb); if let Some(x) = args.Message { builder.add_Message(x); } builder.add_Message_type(args.Message_type); @@ -50,17 +43,17 @@ impl<'a> GameMessageWrapper<'a> { pub fn unpack(&self) -> GameMessageWrapperT { let Message = match self.Message_type() { GameMessage::NONE => GameMessageT::NONE, - GameMessage::PlayerStatEvent => GameMessageT::PlayerStatEvent(Box::new( + GameMessage::PlayerStatEvent => GameMessageT::PlayerStatEvent(alloc::boxed::Box::new( self.Message_as_player_stat_event() .expect("Invalid union table, expected `GameMessage::PlayerStatEvent`.") .unpack() )), - GameMessage::PlayerSpectate => GameMessageT::PlayerSpectate(Box::new( + GameMessage::PlayerSpectate => GameMessageT::PlayerSpectate(alloc::boxed::Box::new( self.Message_as_player_spectate() .expect("Invalid union table, expected `GameMessage::PlayerSpectate`.") .unpack() )), - GameMessage::PlayerInputChange => GameMessageT::PlayerInputChange(Box::new( + GameMessage::PlayerInputChange => GameMessageT::PlayerInputChange(alloc::boxed::Box::new( self.Message_as_player_input_change() .expect("Invalid union table, expected `GameMessage::PlayerInputChange`.") .unpack() @@ -80,11 +73,11 @@ impl<'a> GameMessageWrapper<'a> { unsafe { self._tab.get::(GameMessageWrapper::VT_MESSAGE_TYPE, Some(GameMessage::NONE)).unwrap()} } #[inline] - pub fn Message(&self) -> Option> { + pub fn Message(&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::>>(GameMessageWrapper::VT_MESSAGE, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(GameMessageWrapper::VT_MESSAGE, None)} } #[inline] #[allow(non_snake_case)] @@ -133,18 +126,17 @@ impl<'a> GameMessageWrapper<'a> { } -impl flatbuffers::Verifiable for GameMessageWrapper<'_> { +impl ::flatbuffers::Verifiable for GameMessageWrapper<'_> { #[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_union::("Message_type", Self::VT_MESSAGE_TYPE, "Message", Self::VT_MESSAGE, false, |key, v, pos| { match key { - GameMessage::PlayerStatEvent => v.verify_union_variant::>("GameMessage::PlayerStatEvent", pos), - GameMessage::PlayerSpectate => v.verify_union_variant::>("GameMessage::PlayerSpectate", pos), - GameMessage::PlayerInputChange => v.verify_union_variant::>("GameMessage::PlayerInputChange", pos), + GameMessage::PlayerStatEvent => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("GameMessage::PlayerStatEvent", pos), + GameMessage::PlayerSpectate => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("GameMessage::PlayerSpectate", pos), + GameMessage::PlayerInputChange => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("GameMessage::PlayerInputChange", pos), _ => Ok(()), } })? @@ -154,7 +146,7 @@ impl flatbuffers::Verifiable for GameMessageWrapper<'_> { } pub struct GameMessageWrapperArgs { pub Message_type: GameMessage, - pub Message: Option>, + pub Message: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, } impl<'a> Default for GameMessageWrapperArgs { #[inline] @@ -166,21 +158,21 @@ impl<'a> Default for GameMessageWrapperArgs { } } -pub struct GameMessageWrapperBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct GameMessageWrapperBuilder<'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> GameMessageWrapperBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GameMessageWrapperBuilder<'a, 'b, A> { #[inline] pub fn add_Message_type(&mut self, Message_type: GameMessage) { self.fbb_.push_slot::(GameMessageWrapper::VT_MESSAGE_TYPE, Message_type, GameMessage::NONE); } #[inline] - pub fn add_Message(&mut self, Message: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(GameMessageWrapper::VT_MESSAGE, Message); + pub fn add_Message(&mut self, Message: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(GameMessageWrapper::VT_MESSAGE, Message); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> GameMessageWrapperBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GameMessageWrapperBuilder<'a, 'b, A> { let start = _fbb.start_table(); GameMessageWrapperBuilder { fbb_: _fbb, @@ -188,14 +180,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> GameMessageWrapperBuilder<'a, ' } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for GameMessageWrapper<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for GameMessageWrapper<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("GameMessageWrapper"); ds.field("Message_type", &self.Message_type()); match self.Message_type() { @@ -241,10 +233,10 @@ impl Default for GameMessageWrapperT { } } impl GameMessageWrapperT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let Message_type = self.Message.game_message_type(); let Message = self.Message.pack(_fbb); GameMessageWrapper::create(_fbb, &GameMessageWrapperArgs{ diff --git a/tests/rust_namer_test/rust_namer_test/player_input_change_generated.rs b/tests/rust_namer_test/rust_namer_test/player_input_change_generated.rs index 76449d1bb76..cc8fd38fa50 100644 --- a/tests/rust_namer_test/rust_namer_test/player_input_change_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/player_input_change_generated.rs @@ -1,26 +1,19 @@ // 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 PlayerInputChangeOffset {} #[derive(Copy, Clone, PartialEq)] pub struct PlayerInputChange<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for PlayerInputChange<'a> { +impl<'a> ::flatbuffers::Follow<'a> for PlayerInputChange<'a> { type Inner = PlayerInputChange<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> PlayerInputChange<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { PlayerInputChange { _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 PlayerInputChangeArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = PlayerInputChangeBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ impl<'a> PlayerInputChange<'a> { } } -impl flatbuffers::Verifiable for PlayerInputChange<'_> { +impl ::flatbuffers::Verifiable for PlayerInputChange<'_> { #[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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for PlayerInputChangeArgs { } } -pub struct PlayerInputChangeBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct PlayerInputChangeBuilder<'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> PlayerInputChangeBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PlayerInputChangeBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerInputChangeBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerInputChangeBuilder<'a, 'b, A> { let start = _fbb.start_table(); PlayerInputChangeBuilder { fbb_: _fbb, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PlayerInputChangeBuilder<'a, 'b } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for PlayerInputChange<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for PlayerInputChange<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("PlayerInputChange"); ds.finish() } @@ -107,10 +99,10 @@ impl Default for PlayerInputChangeT { } } impl PlayerInputChangeT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { PlayerInputChange::create(_fbb, &PlayerInputChangeArgs{ }) } diff --git a/tests/rust_namer_test/rust_namer_test/player_spectate_generated.rs b/tests/rust_namer_test/rust_namer_test/player_spectate_generated.rs index ae025c3311d..4cbca2fc4e4 100644 --- a/tests/rust_namer_test/rust_namer_test/player_spectate_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/player_spectate_generated.rs @@ -1,26 +1,19 @@ // 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 PlayerSpectateOffset {} #[derive(Copy, Clone, PartialEq)] pub struct PlayerSpectate<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for PlayerSpectate<'a> { +impl<'a> ::flatbuffers::Follow<'a> for PlayerSpectate<'a> { type Inner = PlayerSpectate<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> PlayerSpectate<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { PlayerSpectate { _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 PlayerSpectateArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = PlayerSpectateBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ impl<'a> PlayerSpectate<'a> { } } -impl flatbuffers::Verifiable for PlayerSpectate<'_> { +impl ::flatbuffers::Verifiable for PlayerSpectate<'_> { #[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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for PlayerSpectateArgs { } } -pub struct PlayerSpectateBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct PlayerSpectateBuilder<'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> PlayerSpectateBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PlayerSpectateBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerSpectateBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerSpectateBuilder<'a, 'b, A> { let start = _fbb.start_table(); PlayerSpectateBuilder { fbb_: _fbb, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PlayerSpectateBuilder<'a, 'b, A } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for PlayerSpectate<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for PlayerSpectate<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("PlayerSpectate"); ds.finish() } @@ -107,10 +99,10 @@ impl Default for PlayerSpectateT { } } impl PlayerSpectateT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { PlayerSpectate::create(_fbb, &PlayerSpectateArgs{ }) } diff --git a/tests/rust_namer_test/rust_namer_test/player_stat_event_generated.rs b/tests/rust_namer_test/rust_namer_test/player_stat_event_generated.rs index 9ab29dd2686..4a141bf0aca 100644 --- a/tests/rust_namer_test/rust_namer_test/player_stat_event_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/player_stat_event_generated.rs @@ -1,26 +1,19 @@ // 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 PlayerStatEventOffset {} #[derive(Copy, Clone, PartialEq)] pub struct PlayerStatEvent<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for PlayerStatEvent<'a> { +impl<'a> ::flatbuffers::Follow<'a> for PlayerStatEvent<'a> { type Inner = PlayerStatEvent<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } @@ -31,14 +24,14 @@ impl<'a> PlayerStatEvent<'a> { } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { PlayerStatEvent { _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 PlayerStatEventArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = PlayerStatEventBuilder::new(_fbb); builder.finish() } @@ -49,12 +42,11 @@ impl<'a> PlayerStatEvent<'a> { } } -impl flatbuffers::Verifiable for PlayerStatEvent<'_> { +impl ::flatbuffers::Verifiable for PlayerStatEvent<'_> { #[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)? .finish(); Ok(()) @@ -70,13 +62,13 @@ impl<'a> Default for PlayerStatEventArgs { } } -pub struct PlayerStatEventBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct PlayerStatEventBuilder<'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> PlayerStatEventBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> PlayerStatEventBuilder<'a, 'b, A> { #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerStatEventBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerStatEventBuilder<'a, 'b, A> { let start = _fbb.start_table(); PlayerStatEventBuilder { fbb_: _fbb, @@ -84,14 +76,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> PlayerStatEventBuilder<'a, 'b, } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for PlayerStatEvent<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for PlayerStatEvent<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("PlayerStatEvent"); ds.finish() } @@ -107,10 +99,10 @@ impl Default for PlayerStatEventT { } } impl PlayerStatEventT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { PlayerStatEvent::create(_fbb, &PlayerStatEventArgs{ }) } diff --git a/tests/rust_namer_test/rust_namer_test/possibly_reserved_words_generated.rs b/tests/rust_namer_test/rust_namer_test/possibly_reserved_words_generated.rs index 3c21e0803ba..0c37b19bfe6 100644 --- a/tests/rust_namer_test/rust_namer_test/possibly_reserved_words_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/possibly_reserved_words_generated.rs @@ -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 PossiblyReservedWords, aligned to 4 #[repr(transparent)] @@ -18,8 +11,8 @@ impl Default for PossiblyReservedWords { Self([0; 16]) } } -impl core::fmt::Debug for PossiblyReservedWords { - fn fmt(&self, f: &mut core::fmt::Formatter) -> core::fmt::Result { +impl ::core::fmt::Debug for PossiblyReservedWords { + fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result { f.debug_struct("PossiblyReservedWords") .field("follow_", &self.follow_()) .field("push_", &self.push_()) @@ -29,40 +22,40 @@ impl core::fmt::Debug for PossiblyReservedWords { } } -impl flatbuffers::SimpleToVerifyInSlice for PossiblyReservedWords {} -impl<'a> flatbuffers::Follow<'a> for PossiblyReservedWords { +impl ::flatbuffers::SimpleToVerifyInSlice for PossiblyReservedWords {} +impl<'a> ::flatbuffers::Follow<'a> for PossiblyReservedWords { type Inner = &'a PossiblyReservedWords; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { <&'a PossiblyReservedWords>::follow(buf, loc) } } -impl<'a> flatbuffers::Follow<'a> for &'a PossiblyReservedWords { +impl<'a> ::flatbuffers::Follow<'a> for &'a PossiblyReservedWords { type Inner = &'a PossiblyReservedWords; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - flatbuffers::follow_cast_ref::(buf, loc) + ::flatbuffers::follow_cast_ref::(buf, loc) } } -impl<'b> flatbuffers::Push for PossiblyReservedWords { +impl<'b> ::flatbuffers::Push for PossiblyReservedWords { type Output = PossiblyReservedWords; #[inline] unsafe fn push(&self, dst: &mut [u8], _written_len: usize) { - let src = ::core::slice::from_raw_parts(self as *const PossiblyReservedWords as *const u8, ::size()); + let src = ::core::slice::from_raw_parts(self as *const PossiblyReservedWords as *const u8, ::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 PossiblyReservedWords { +impl<'a> ::flatbuffers::Verifiable for PossiblyReservedWords { #[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> { + use ::flatbuffers::Verifiable; v.in_buffer::(pos) } } @@ -88,117 +81,117 @@ impl<'a> PossiblyReservedWords { } pub fn follow_(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_follow_(&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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn push_(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_push_(&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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn size(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_size(&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::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } pub fn alignment(&self) -> f32 { - let mut mem = core::mem::MaybeUninit::<::Scalar>::uninit(); + let mut mem = ::core::mem::MaybeUninit::<::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[12..].as_ptr(), mem.as_mut_ptr() as *mut u8, - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); mem.assume_init() }) } pub fn set_alignment(&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[12..].as_mut_ptr(), - core::mem::size_of::<::Scalar>(), + ::core::mem::size_of::<::Scalar>(), ); } } diff --git a/tests/rust_namer_test/rust_namer_test/root_table_generated.rs b/tests/rust_namer_test/rust_namer_test/root_table_generated.rs index d49ae92abba..2f5402a6614 100644 --- a/tests/rust_namer_test/rust_namer_test/root_table_generated.rs +++ b/tests/rust_namer_test/rust_namer_test/root_table_generated.rs @@ -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 RootTableOffset {} #[derive(Copy, Clone, PartialEq)] pub struct RootTable<'a> { - pub _tab: flatbuffers::Table<'a>, + pub _tab: ::flatbuffers::Table<'a>, } -impl<'a> flatbuffers::Follow<'a> for RootTable<'a> { +impl<'a> ::flatbuffers::Follow<'a> for RootTable<'a> { type Inner = RootTable<'a>; #[inline] unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { - Self { _tab: flatbuffers::Table::new(buf, loc) } + Self { _tab: ::flatbuffers::Table::new(buf, loc) } } } impl<'a> RootTable<'a> { - pub const VT_FIELD42_TYPE: flatbuffers::VOffsetT = 4; - pub const VT_FIELD42: flatbuffers::VOffsetT = 6; + pub const VT_FIELD42_TYPE: ::flatbuffers::VOffsetT = 4; + pub const VT_FIELD42: ::flatbuffers::VOffsetT = 6; pub const fn get_fully_qualified_name() -> &'static str { "RustNamerTest.RootTable" } #[inline] - pub unsafe fn init_from_table(table: flatbuffers::Table<'a>) -> Self { + pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self { RootTable { _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 RootTableArgs - ) -> flatbuffers::WIPOffset> { + ) -> ::flatbuffers::WIPOffset> { let mut builder = RootTableBuilder::new(_fbb); if let Some(x) = args.field42 { builder.add_field42(x); } builder.add_field42_type(args.field42_type); @@ -50,7 +43,7 @@ impl<'a> RootTable<'a> { pub fn unpack(&self) -> RootTableT { let field42 = match self.field42_type() { FieldUnion::NONE => FieldUnionT::NONE, - FieldUnion::f => FieldUnionT::F(Box::new( + FieldUnion::f => FieldUnionT::F(alloc::boxed::Box::new( self.field42_as_f() .expect("Invalid union table, expected `FieldUnion::f`.") .unpack() @@ -70,11 +63,11 @@ impl<'a> RootTable<'a> { unsafe { self._tab.get::(RootTable::VT_FIELD42_TYPE, Some(FieldUnion::NONE)).unwrap()} } #[inline] - pub fn field42(&self) -> Option> { + pub fn field42(&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::>>(RootTable::VT_FIELD42, None)} + unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(RootTable::VT_FIELD42, None)} } #[inline] #[allow(non_snake_case)] @@ -93,16 +86,15 @@ impl<'a> RootTable<'a> { } -impl flatbuffers::Verifiable for RootTable<'_> { +impl ::flatbuffers::Verifiable for RootTable<'_> { #[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_union::("field42_type", Self::VT_FIELD42_TYPE, "field42", Self::VT_FIELD42, false, |key, v, pos| { match key { - FieldUnion::f => v.verify_union_variant::>("FieldUnion::f", pos), + FieldUnion::f => v.verify_union_variant::<::flatbuffers::ForwardsUOffset>("FieldUnion::f", pos), _ => Ok(()), } })? @@ -112,7 +104,7 @@ impl flatbuffers::Verifiable for RootTable<'_> { } pub struct RootTableArgs { pub field42_type: FieldUnion, - pub field42: Option>, + pub field42: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>, } impl<'a> Default for RootTableArgs { #[inline] @@ -124,21 +116,21 @@ impl<'a> Default for RootTableArgs { } } -pub struct RootTableBuilder<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> { - fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a, A>, - start_: flatbuffers::WIPOffset, +pub struct RootTableBuilder<'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> RootTableBuilder<'a, 'b, A> { +impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> RootTableBuilder<'a, 'b, A> { #[inline] pub fn add_field42_type(&mut self, field42_type: FieldUnion) { self.fbb_.push_slot::(RootTable::VT_FIELD42_TYPE, field42_type, FieldUnion::NONE); } #[inline] - pub fn add_field42(&mut self, field42: flatbuffers::WIPOffset) { - self.fbb_.push_slot_always::>(RootTable::VT_FIELD42, field42); + pub fn add_field42(&mut self, field42: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) { + self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(RootTable::VT_FIELD42, field42); } #[inline] - pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a, A>) -> RootTableBuilder<'a, 'b, A> { + pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> RootTableBuilder<'a, 'b, A> { let start = _fbb.start_table(); RootTableBuilder { fbb_: _fbb, @@ -146,14 +138,14 @@ impl<'a: 'b, 'b, A: flatbuffers::Allocator + 'a> RootTableBuilder<'a, 'b, A> { } } #[inline] - pub fn finish(self) -> flatbuffers::WIPOffset> { + pub fn finish(self) -> ::flatbuffers::WIPOffset> { let o = self.fbb_.end_table(self.start_); - flatbuffers::WIPOffset::new(o.value()) + ::flatbuffers::WIPOffset::new(o.value()) } } -impl core::fmt::Debug for RootTable<'_> { - fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result { +impl ::core::fmt::Debug for RootTable<'_> { + fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result { let mut ds = f.debug_struct("RootTable"); ds.field("field42_type", &self.field42_type()); match self.field42_type() { @@ -185,10 +177,10 @@ impl Default for RootTableT { } } impl RootTableT { - 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> { + _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A> + ) -> ::flatbuffers::WIPOffset> { let field42_type = self.field42.field_union_type(); let field42 = self.field42.pack(_fbb); RootTable::create(_fbb, &RootTableArgs{ diff --git a/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs b/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs index 8a77c0e0e5b..1815d9fbbb2 100644 --- a/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs +++ b/tests/rust_usage_test/bin/flatbuffers_alloc_check.rs @@ -146,10 +146,10 @@ fn main() { // We know the bits should be exactly equal here but compilers may // optimize floats in subtle ways so we're playing it safe and using // epsilon comparison - assert!((pos.x() - 1.0f32).abs() < std::f32::EPSILON); - assert!((pos.y() - 2.0f32).abs() < std::f32::EPSILON); - assert!((pos.z() - 3.0f32).abs() < std::f32::EPSILON); - assert!((pos.test1() - 3.0f64).abs() < std::f64::EPSILON); + assert!((pos.x() - 1.0f32).abs() < f32::EPSILON); + assert!((pos.y() - 2.0f32).abs() < f32::EPSILON); + assert!((pos.z() - 3.0f32).abs() < f32::EPSILON); + assert!((pos.test1() - 3.0f64).abs() < f64::EPSILON); assert_eq!(pos.test2(), my_game::example::Color::Green); let pos_test3 = pos.test3(); assert_eq!(pos_test3.a(), 5i16);