Updates Rust codegen to use proper indentation (#8952)
* Fixes identation of generated Rust code
* Regenerates generated schemas
diff --git a/goldens/rust/basic_generated.rs b/goldens/rust/basic_generated.rs
index 941408d..b8a699b 100644
--- a/goldens/rust/basic_generated.rs
+++ b/goldens/rust/basic_generated.rs
@@ -4,315 +4,319 @@
#[allow(unused_imports, dead_code)]
pub mod flatbuffers {
- extern crate alloc;
-
- #[allow(unused_imports, dead_code)]
- pub mod goldens {
extern crate alloc;
- pub enum GalaxyOffset {}
+ #[allow(unused_imports, dead_code)]
+ pub mod goldens {
+ extern crate alloc;
- #[derive(Copy, Clone, PartialEq)]
- pub struct Galaxy<'a> {
- pub _tab: ::flatbuffers::Table<'a>,
- }
+ pub enum GalaxyOffset {}
- impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
- type Inner = Galaxy<'a>;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
- }
-
- impl<'a> Galaxy<'a> {
- pub const VT_NUM_STARS: ::flatbuffers::VOffsetT = 4;
-
- #[inline]
- pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
- Galaxy { _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>,
- args: &'args GalaxyArgs
- ) -> ::flatbuffers::WIPOffset<Galaxy<'bldr>> {
- let mut builder = GalaxyBuilder::new(_fbb);
- builder.add_num_stars(args.num_stars);
- builder.finish()
- }
-
-
- #[inline]
- pub fn num_stars(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Galaxy::VT_NUM_STARS, Some(0)).unwrap()}
- }
- }
-
- impl ::flatbuffers::Verifiable for Galaxy<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i64>("num_stars", Self::VT_NUM_STARS, false)?
- .finish();
- Ok(())
- }
- }
-
- pub struct GalaxyArgs {
- pub num_stars: i64,
- }
-
- impl<'a> Default for GalaxyArgs {
- #[inline]
- fn default() -> Self {
- GalaxyArgs {
- num_stars: 0,
+ #[derive(Copy, Clone, PartialEq)]
+ pub struct Galaxy<'a> {
+ pub _tab: ::flatbuffers::Table<'a>,
}
- }
- }
- pub struct GalaxyBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
- }
+ impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
+ type Inner = Galaxy<'a>;
- impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_num_stars(&mut self, num_stars: i64) {
- self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- GalaxyBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
- }
+ impl<'a> Galaxy<'a> {
+ pub const VT_NUM_STARS: ::flatbuffers::VOffsetT = 4;
- impl ::core::fmt::Debug for Galaxy<'_> {
- fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
- let mut ds = f.debug_struct("Galaxy");
- ds.field("num_stars", &self.num_stars());
- ds.finish()
- }
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Galaxy { _tab: table }
+ }
- pub enum UniverseOffset {}
-
- #[derive(Copy, Clone, PartialEq)]
- pub struct Universe<'a> {
- pub _tab: ::flatbuffers::Table<'a>,
- }
-
- impl<'a> ::flatbuffers::Follow<'a> for Universe<'a> {
- type Inner = Universe<'a>;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
- }
-
- impl<'a> Universe<'a> {
- pub const VT_AGE: ::flatbuffers::VOffsetT = 4;
- pub const VT_GALAXIES: ::flatbuffers::VOffsetT = 6;
-
- #[inline]
- pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
- Universe { _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>,
- args: &'args UniverseArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Universe<'bldr>> {
- let mut builder = UniverseBuilder::new(_fbb);
- builder.add_age(args.age);
- if let Some(x) = args.galaxies { builder.add_galaxies(x); }
- builder.finish()
- }
+ #[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>,
+ args: &'args GalaxyArgs
+ ) -> ::flatbuffers::WIPOffset<Galaxy<'bldr>> {
+ let mut builder = GalaxyBuilder::new(_fbb);
+ builder.add_num_stars(args.num_stars);
+ builder.finish()
+ }
- #[inline]
- pub fn age(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
- }
-
- #[inline]
- pub fn galaxies(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy>>>>(Universe::VT_GALAXIES, None)}
- }
- }
-
- impl ::flatbuffers::Verifiable for Universe<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<f64>("age", Self::VT_AGE, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Galaxy>>>>("galaxies", Self::VT_GALAXIES, false)?
- .finish();
- Ok(())
- }
- }
-
- pub struct UniverseArgs<'a> {
- pub age: f64,
- pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
- }
-
- impl<'a> Default for UniverseArgs<'a> {
- #[inline]
- fn default() -> Self {
- UniverseArgs {
- age: 0.0,
- galaxies: None,
+ #[inline]
+ pub fn num_stars(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Galaxy::VT_NUM_STARS, Some(0)).unwrap()}
+ }
}
- }
- }
- pub struct UniverseBuilder<'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> UniverseBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_age(&mut self, age: f64) {
- self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
- }
-
- #[inline]
- pub fn add_galaxies(&mut self, galaxies: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- UniverseBuilder {
- fbb_: _fbb,
- start_: start,
+ impl ::flatbuffers::Verifiable for Galaxy<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i64>("num_stars", Self::VT_NUM_STARS, false)?
+ .finish();
+ Ok(())
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Universe<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
- }
+ pub struct GalaxyArgs {
+ pub num_stars: i64,
+ }
- impl ::core::fmt::Debug for Universe<'_> {
- fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
- let mut ds = f.debug_struct("Universe");
- ds.field("age", &self.age());
- ds.field("galaxies", &self.galaxies());
- ds.finish()
- }
- }
+ impl<'a> Default for GalaxyArgs {
+ #[inline]
+ fn default() -> Self {
+ GalaxyArgs {
+ num_stars: 0,
+ }
+ }
+ }
- /// Verifies that a buffer of bytes contains a `Universe`
- /// and returns it.
- /// Note that verification is still experimental and may not
- /// catch every error, or be maximally performant. For the
- /// previous, unchecked, behavior use
- /// `root_as_universe_unchecked`.
- #[inline]
- pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<Universe>(buf)
- }
+ pub struct GalaxyBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ }
- /// Verifies that a buffer of bytes contains a size prefixed
- /// `Universe` and returns it.
- /// Note that verification is still experimental and may not
- /// catch every error, or be maximally performant. For the
- /// previous, unchecked, behavior use
- /// `size_prefixed_root_as_universe_unchecked`.
- #[inline]
- pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<Universe>(buf)
- }
+ impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> GalaxyBuilder<'a, 'b, A> {
+ #[inline]
+ pub fn add_num_stars(&mut self, num_stars: i64) {
+ self.fbb_.push_slot::<i64>(Galaxy::VT_NUM_STARS, num_stars, 0);
+ }
- /// Verifies, with the given options, that a buffer of bytes
- /// contains a `Universe` and returns it.
- /// Note that verification is still experimental and may not
- /// catch every error, or be maximally performant. For the
- /// previous, unchecked, behavior use
- /// `root_as_universe_unchecked`.
- #[inline]
- pub fn root_as_universe_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
- ) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GalaxyBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ GalaxyBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
- /// Verifies, with the given verifier options, that a buffer of
- /// bytes contains a size prefixed `Universe` and returns
- /// it. Note that verification is still experimental and may not
- /// catch every error, or be maximally performant. For the
- /// previous, unchecked, behavior use
- /// `root_as_universe_unchecked`.
- #[inline]
- pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
- ) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
+ }
- /// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
- /// # Safety
- /// Callers must trust the given bytes do indeed contain a valid `Universe`.
- #[inline]
- pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
- unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
- }
+ impl ::core::fmt::Debug for Galaxy<'_> {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("Galaxy");
+ ds.field("num_stars", &self.num_stars());
+ ds.finish()
+ }
+ }
- /// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
- /// # Safety
- /// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
- #[inline]
- pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
- }
+ pub enum UniverseOffset {}
- #[inline]
- pub fn finish_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
- fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<Universe<'a>>) {
- fbb.finish(root, None);
- }
+ #[derive(Copy, Clone, PartialEq)]
+ pub struct Universe<'a> {
+ pub _tab: ::flatbuffers::Table<'a>,
+ }
- #[inline]
- pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Universe<'a>>) {
- fbb.finish_size_prefixed(root, None);
- }
- } // pub mod goldens
+ impl<'a> ::flatbuffers::Follow<'a> for Universe<'a> {
+ type Inner = Universe<'a>;
+
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
+ }
+
+ impl<'a> Universe<'a> {
+ pub const VT_AGE: ::flatbuffers::VOffsetT = 4;
+ pub const VT_GALAXIES: ::flatbuffers::VOffsetT = 6;
+
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Universe { _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>,
+ args: &'args UniverseArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Universe<'bldr>> {
+ let mut builder = UniverseBuilder::new(_fbb);
+ builder.add_age(args.age);
+ if let Some(x) = args.galaxies { builder.add_galaxies(x); }
+ builder.finish()
+ }
+
+
+ #[inline]
+ pub fn age(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(Universe::VT_AGE, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn galaxies(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy>>>>(Universe::VT_GALAXIES, None)}
+ }
+ }
+
+ impl ::flatbuffers::Verifiable for Universe<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<f64>("age", Self::VT_AGE, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Galaxy>>>>("galaxies", Self::VT_GALAXIES, false)?
+ .finish();
+ Ok(())
+ }
+ }
+
+ pub struct UniverseArgs<'a> {
+ pub age: f64,
+ pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
+ }
+
+ impl<'a> Default for UniverseArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ UniverseArgs {
+ age: 0.0,
+ galaxies: None,
+ }
+ }
+ }
+
+ pub struct UniverseBuilder<'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> UniverseBuilder<'a, 'b, A> {
+ #[inline]
+ pub fn add_age(&mut self, age: f64) {
+ self.fbb_.push_slot::<f64>(Universe::VT_AGE, age, 0.0);
+ }
+
+ #[inline]
+ pub fn add_galaxies(&mut self, galaxies: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Galaxy<'b >>>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Universe::VT_GALAXIES, galaxies);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> UniverseBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ UniverseBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Universe<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
+ }
+
+ impl ::core::fmt::Debug for Universe<'_> {
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("Universe");
+ ds.field("age", &self.age());
+ ds.field("galaxies", &self.galaxies());
+ ds.finish()
+ }
+ }
+
+ /// Verifies that a buffer of bytes contains a `Universe`
+ /// and returns it.
+ /// Note that verification is still experimental and may not
+ /// catch every error, or be maximally performant. For the
+ /// previous, unchecked, behavior use
+ /// `root_as_universe_unchecked`.
+ #[inline]
+ pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
+ ::flatbuffers::root::<Universe>(buf)
+ }
+
+ /// Verifies that a buffer of bytes contains a size prefixed
+ /// `Universe` and returns it.
+ /// Note that verification is still experimental and may not
+ /// catch every error, or be maximally performant. For the
+ /// previous, unchecked, behavior use
+ /// `size_prefixed_root_as_universe_unchecked`.
+ #[inline]
+ pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
+ ::flatbuffers::size_prefixed_root::<Universe>(buf)
+ }
+
+ /// Verifies, with the given options, that a buffer of bytes
+ /// contains a `Universe` and returns it.
+ /// Note that verification is still experimental and may not
+ /// catch every error, or be maximally performant. For the
+ /// previous, unchecked, behavior use
+ /// `root_as_universe_unchecked`.
+ #[inline]
+ pub fn root_as_universe_with_opts<'b, 'o>(
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+ ) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
+ ::flatbuffers::root_with_opts::<Universe<'b>>(opts, buf)
+ }
+
+ /// Verifies, with the given verifier options, that a buffer of
+ /// bytes contains a size prefixed `Universe` and returns
+ /// it. Note that verification is still experimental and may not
+ /// catch every error, or be maximally performant. For the
+ /// previous, unchecked, behavior use
+ /// `root_as_universe_unchecked`.
+ #[inline]
+ pub fn size_prefixed_root_as_universe_with_opts<'b, 'o>(
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
+ ) -> Result<Universe<'b>, ::flatbuffers::InvalidFlatbuffer> {
+ ::flatbuffers::size_prefixed_root_with_opts::<Universe<'b>>(opts, buf)
+ }
+
+ /// Assumes, without verification, that a buffer of bytes contains a Universe and returns it.
+ /// # Safety
+ /// Callers must trust the given bytes do indeed contain a valid `Universe`.
+ #[inline]
+ pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
+ unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
+ }
+
+ /// Assumes, without verification, that a buffer of bytes contains a size prefixed Universe and returns it.
+ /// # Safety
+ /// Callers must trust the given bytes do indeed contain a valid size prefixed `Universe`.
+ #[inline]
+ pub unsafe fn size_prefixed_root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Universe>(buf) }
+ }
+
+ #[inline]
+ pub fn finish_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<Universe<'a>>
+ ) {
+ fbb.finish(root, None);
+ }
+
+ #[inline]
+ pub fn finish_size_prefixed_universe_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<Universe<'a>>
+ ) {
+ fbb.finish_size_prefixed(root, None);
+ }
+ } // pub mod goldens
} // pub mod flatbuffers
diff --git a/samples/rust_generated/mod.rs b/samples/rust_generated/mod.rs
index 5f7e924..50e577a 100644
--- a/samples/rust_generated/mod.rs
+++ b/samples/rust_generated/mod.rs
@@ -1,18 +1,18 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod sample {
use super::*;
- mod color_generated;
- pub use self::color_generated::*;
- mod equipment_generated;
- pub use self::equipment_generated::*;
- mod vec_3_generated;
- pub use self::vec_3_generated::*;
- mod monster_generated;
- pub use self::monster_generated::*;
- mod weapon_generated;
- pub use self::weapon_generated::*;
- } // sample
+ pub mod sample {
+ use super::*;
+ mod color_generated;
+ pub use self::color_generated::*;
+ mod equipment_generated;
+ pub use self::equipment_generated::*;
+ mod vec_3_generated;
+ pub use self::vec_3_generated::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ mod weapon_generated;
+ pub use self::weapon_generated::*;
+ } // sample
} // my_game
diff --git a/samples/rust_generated/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs
index 88ed9ea..df74180 100644
--- a/samples/rust_generated/my_game/sample/color_generated.rs
+++ b/samples/rust_generated/my_game/sample/color_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_COLOR: [Color; 3] = [
- Color::Red,
- Color::Green,
- Color::Blue,
+ Color::Red,
+ Color::Green,
+ Color::Blue,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl Color {
- pub const Red: Self = Self(0);
- pub const Green: Self = Self(1);
- pub const Blue: Self = Self(2);
+ pub const Red: Self = Self(0);
+ pub const Green: Self = Self(1);
+ pub const Blue: Self = Self(2);
- pub const ENUM_MIN: i8 = 0;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::Red,
- Self::Green,
- Self::Blue,
- ];
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::Red,
+ Self::Green,
+ Self::Blue,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::Red => Some("Red"),
- Self::Green => Some("Green"),
- Self::Blue => Some("Blue"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::Red => Some("Red"),
+ Self::Green => Some("Green"),
+ Self::Blue => Some("Blue"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for Color {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Color {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for Color {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Color {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
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 de61cf7..e347757 100644
--- a/samples/rust_generated/my_game/sample/equipment_generated.rs
+++ b/samples/rust_generated/my_game/sample/equipment_generated.rs
@@ -12,8 +12,8 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_EQUIPMENT: [Equipment; 2] = [
- Equipment::NONE,
- Equipment::Weapon,
+ Equipment::NONE,
+ Equipment::Weapon,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -22,44 +22,44 @@
#[allow(non_upper_case_globals)]
impl Equipment {
- pub const NONE: Self = Self(0);
- pub const Weapon: Self = Self(1);
+ pub const NONE: Self = Self(0);
+ pub const Weapon: Self = Self(1);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 1;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::Weapon,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Weapon,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::Weapon => Some("Weapon"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Weapon => Some("Weapon"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for Equipment {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Equipment {
@@ -72,28 +72,28 @@
}
impl ::flatbuffers::EndianScalar for Equipment {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Equipment {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Equipment {}
@@ -104,53 +104,53 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum EquipmentT {
- NONE,
- Weapon(alloc::boxed::Box<WeaponT>),
+ NONE,
+ Weapon(alloc::boxed::Box<WeaponT>),
}
impl Default for EquipmentT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl EquipmentT {
- pub fn equipment_type(&self) -> Equipment {
- match self {
- Self::NONE => Equipment::NONE,
- Self::Weapon(_) => Equipment::Weapon,
+ pub fn equipment_type(&self) -> Equipment {
+ match self {
+ Self::NONE => Equipment::NONE,
+ Self::Weapon(_) => Equipment::Weapon,
+ }
}
- }
- 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()),
+ 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<alloc::boxed::Box<WeaponT>> {
- if let Self::Weapon(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Weapon(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned WeaponT, setting the union to NONE.
+ pub fn take_weapon(&mut self) -> Option<alloc::boxed::Box<WeaponT>> {
+ if let Self::Weapon(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Weapon(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the WeaponT.
- pub fn as_weapon(&self) -> Option<&WeaponT> {
- if let Self::Weapon(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return a reference to the WeaponT.
+ pub fn as_weapon(&self) -> Option<&WeaponT> {
+ if let Self::Weapon(v) = self { Some(v.as_ref()) } else { None }
+ }
- /// If the union variant matches, return a mutable reference to the WeaponT.
- pub fn as_weapon_mut(&mut self) -> Option<&mut WeaponT> {
- if let Self::Weapon(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a mutable reference to the WeaponT.
+ pub fn as_weapon_mut(&mut self) -> Option<&mut WeaponT> {
+ if let Self::Weapon(v) = self { Some(v.as_mut()) } else { None }
+ }
}
diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs
index 645c1c2..fa36fbf 100644
--- a/samples/rust_generated/my_game/sample/monster_generated.rs
+++ b/samples/rust_generated/my_game/sample/monster_generated.rs
@@ -7,218 +7,218 @@
#[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> {
- type Inner = Monster<'a>;
+ type Inner = Monster<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Monster<'a> {
- pub const VT_POS: ::flatbuffers::VOffsetT = 4;
- pub const VT_MANA: ::flatbuffers::VOffsetT = 6;
- pub const VT_HP: ::flatbuffers::VOffsetT = 8;
- pub const VT_NAME: ::flatbuffers::VOffsetT = 10;
- pub const VT_INVENTORY: ::flatbuffers::VOffsetT = 14;
- pub const VT_COLOR: ::flatbuffers::VOffsetT = 16;
- pub const VT_WEAPONS: ::flatbuffers::VOffsetT = 18;
- pub const VT_EQUIPPED_TYPE: ::flatbuffers::VOffsetT = 20;
- pub const VT_EQUIPPED: ::flatbuffers::VOffsetT = 22;
- pub const VT_PATH: ::flatbuffers::VOffsetT = 24;
+ pub const VT_POS: ::flatbuffers::VOffsetT = 4;
+ pub const VT_MANA: ::flatbuffers::VOffsetT = 6;
+ pub const VT_HP: ::flatbuffers::VOffsetT = 8;
+ pub const VT_NAME: ::flatbuffers::VOffsetT = 10;
+ pub const VT_INVENTORY: ::flatbuffers::VOffsetT = 14;
+ pub const VT_COLOR: ::flatbuffers::VOffsetT = 16;
+ pub const VT_WEAPONS: ::flatbuffers::VOffsetT = 18;
+ pub const VT_EQUIPPED_TYPE: ::flatbuffers::VOffsetT = 20;
+ pub const VT_EQUIPPED: ::flatbuffers::VOffsetT = 22;
+ pub const VT_PATH: ::flatbuffers::VOffsetT = 24;
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Sample.Monster"
- }
-
- #[inline]
- pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
- 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>,
- args: &'args MonsterArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
- let mut builder = MonsterBuilder::new(_fbb);
- if let Some(x) = args.path { builder.add_path(x); }
- if let Some(x) = args.equipped { builder.add_equipped(x); }
- if let Some(x) = args.weapons { builder.add_weapons(x); }
- if let Some(x) = args.inventory { builder.add_inventory(x); }
- if let Some(x) = args.name { builder.add_name(x); }
- if let Some(x) = args.pos { builder.add_pos(x); }
- builder.add_hp(args.hp);
- builder.add_mana(args.mana);
- builder.add_equipped_type(args.equipped_type);
- builder.add_color(args.color);
- builder.finish()
- }
-
- pub fn unpack(&self) -> MonsterT {
- let pos = self.pos().map(|x| {
- x.unpack()
- });
- let mana = self.mana();
- let hp = self.hp();
- let name = self.name().map(|x| {
- alloc::string::ToString::to_string(x)
- });
- let inventory = self.inventory().map(|x| {
- x.into_iter().collect()
- });
- let color = self.color();
- let weapons = self.weapons().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let equipped = match self.equipped_type() {
- Equipment::NONE => EquipmentT::NONE,
- Equipment::Weapon => EquipmentT::Weapon(alloc::boxed::Box::new(
- self.equipped_as_weapon()
- .expect("Invalid union table, expected `Equipment::Weapon`.")
- .unpack()
- )),
- _ => EquipmentT::NONE,
- };
- let path = self.path().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- MonsterT {
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- weapons,
- equipped,
- path,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Sample.Monster"
}
- }
- #[inline]
- pub fn pos(&self) -> Option<&'a Vec3> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
- }
-
- #[inline]
- pub fn mana(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
- }
-
- #[inline]
- pub fn hp(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
- }
-
- #[inline]
- pub fn name(&self) -> Option<&'a str> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
- }
-
- #[inline]
- pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
- }
-
- #[inline]
- pub fn color(&self) -> Color {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
- }
-
- #[inline]
- pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
- }
-
- #[inline]
- pub fn equipped_type(&self) -> Equipment {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
- }
-
- #[inline]
- pub fn equipped(&self) -> Option<::flatbuffers::Table<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
- }
-
- #[inline]
- pub fn path(&self) -> Option<::flatbuffers::Vector<'a, Vec3>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
- if self.equipped_type() == Equipment::Weapon {
- self.equipped().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Weapon::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ 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>,
+ args: &'args MonsterArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
+ let mut builder = MonsterBuilder::new(_fbb);
+ if let Some(x) = args.path { builder.add_path(x); }
+ if let Some(x) = args.equipped { builder.add_equipped(x); }
+ if let Some(x) = args.weapons { builder.add_weapons(x); }
+ if let Some(x) = args.inventory { builder.add_inventory(x); }
+ if let Some(x) = args.name { builder.add_name(x); }
+ if let Some(x) = args.pos { builder.add_pos(x); }
+ builder.add_hp(args.hp);
+ builder.add_mana(args.mana);
+ builder.add_equipped_type(args.equipped_type);
+ builder.add_color(args.color);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> MonsterT {
+ let pos = self.pos().map(|x| {
+ x.unpack()
+ });
+ let mana = self.mana();
+ let hp = self.hp();
+ let name = self.name().map(|x| {
+ alloc::string::ToString::to_string(x)
+ });
+ let inventory = self.inventory().map(|x| {
+ x.into_iter().collect()
+ });
+ let color = self.color();
+ let weapons = self.weapons().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let equipped = match self.equipped_type() {
+ Equipment::NONE => EquipmentT::NONE,
+ Equipment::Weapon => EquipmentT::Weapon(alloc::boxed::Box::new(
+ self.equipped_as_weapon()
+ .expect("Invalid union table, expected `Equipment::Weapon`.")
+ .unpack()
+ )),
+ _ => EquipmentT::NONE,
+ };
+ let path = self.path().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ MonsterT {
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ weapons,
+ equipped,
+ path,
+ }
+ }
+
+ #[inline]
+ pub fn pos(&self) -> Option<&'a Vec3> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
+ }
+
+ #[inline]
+ pub fn mana(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
+ }
+
+ #[inline]
+ pub fn hp(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
+ }
+
+ #[inline]
+ pub fn name(&self) -> Option<&'a str> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None)}
+ }
+
+ #[inline]
+ pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
+ }
+
+ #[inline]
+ pub fn weapons(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Weapon>>>>(Monster::VT_WEAPONS, None)}
+ }
+
+ #[inline]
+ pub fn equipped_type(&self) -> Equipment {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Equipment>(Monster::VT_EQUIPPED_TYPE, Some(Equipment::NONE)).unwrap()}
+ }
+
+ #[inline]
+ pub fn equipped(&self) -> Option<::flatbuffers::Table<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_EQUIPPED, None)}
+ }
+
+ #[inline]
+ pub fn path(&self) -> Option<::flatbuffers::Vector<'a, Vec3>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Vec3>>>(Monster::VT_PATH, None)}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn equipped_as_weapon(&self) -> Option<Weapon<'a>> {
+ if self.equipped_type() == Equipment::Weapon {
+ self.equipped().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Weapon::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for Monster<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<Vec3>("pos", Self::VT_POS, false)?
- .visit_field::<i16>("mana", Self::VT_MANA, false)?
- .visit_field::<i16>("hp", Self::VT_HP, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
- .visit_field::<Color>("color", Self::VT_COLOR, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Weapon>>>>("weapons", Self::VT_WEAPONS, false)?
- .visit_union::<Equipment, _>("equipped_type", Self::VT_EQUIPPED_TYPE, "equipped", Self::VT_EQUIPPED, false, |key, v, pos| {
- match key {
- Equipment::Weapon => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Weapon>>("Equipment::Weapon", pos),
- _ => Ok(()),
- }
- })?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Vec3>>>("path", Self::VT_PATH, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<Vec3>("pos", Self::VT_POS, false)?
+ .visit_field::<i16>("mana", Self::VT_MANA, false)?
+ .visit_field::<i16>("hp", Self::VT_HP, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Weapon>>>>("weapons", Self::VT_WEAPONS, false)?
+ .visit_union::<Equipment, _>("equipped_type", Self::VT_EQUIPPED_TYPE, "equipped", Self::VT_EQUIPPED, false, |key, v, pos| {
+ match key {
+ Equipment::Weapon => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Weapon>>("Equipment::Weapon", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Vec3>>>("path", Self::VT_PATH, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct MonsterArgs<'a> {
@@ -235,191 +235,191 @@
}
impl<'a> Default for MonsterArgs<'a> {
- #[inline]
- fn default() -> Self {
- MonsterArgs {
- pos: None,
- mana: 150,
- hp: 100,
- name: None,
- inventory: None,
- color: Color::Blue,
- weapons: None,
- equipped_type: Equipment::NONE,
- equipped: None,
- path: None,
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: None,
+ inventory: None,
+ color: Color::Blue,
+ weapons: None,
+ equipped_type: Equipment::NONE,
+ equipped: None,
+ path: None,
+ }
}
- }
}
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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);
- }
-
- #[inline]
- pub fn add_mana(&mut self, mana: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
- }
-
- #[inline]
- pub fn add_hp(&mut self, hp: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
- }
-
- #[inline]
- pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
- }
-
- #[inline]
- pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
- }
-
- #[inline]
- pub fn add_color(&mut self, color: Color) {
- self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
- }
-
- #[inline]
- pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
- }
-
- #[inline]
- pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
- self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
- }
-
- #[inline]
- pub fn add_equipped(&mut self, equipped: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
- }
-
- #[inline]
- pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Vec3>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- MonsterBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_pos(&mut self, pos: &Vec3) {
+ self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_mana(&mut self, mana: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
+ }
+
+ #[inline]
+ pub fn add_hp(&mut self, hp: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
+ }
+
+ #[inline]
+ pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
+ }
+
+ #[inline]
+ pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
+ }
+
+ #[inline]
+ pub fn add_color(&mut self, color: Color) {
+ self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
+ }
+
+ #[inline]
+ pub fn add_weapons(&mut self, weapons: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Weapon<'b >>>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_WEAPONS, weapons);
+ }
+
+ #[inline]
+ pub fn add_equipped_type(&mut self, equipped_type: Equipment) {
+ self.fbb_.push_slot::<Equipment>(Monster::VT_EQUIPPED_TYPE, equipped_type, Equipment::NONE);
+ }
+
+ #[inline]
+ pub fn add_equipped(&mut self, equipped: ::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_EQUIPPED, equipped);
+ }
+
+ #[inline]
+ pub fn add_path(&mut self, path: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , Vec3>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_PATH, path);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("hp", &self.hp());
- ds.field("name", &self.name());
- ds.field("inventory", &self.inventory());
- ds.field("color", &self.color());
- ds.field("weapons", &self.weapons());
- ds.field("equipped_type", &self.equipped_type());
- match self.equipped_type() {
- Equipment::Weapon => {
- if let Some(x) = self.equipped_as_weapon() {
- ds.field("equipped", &x)
- } else {
- ds.field("equipped", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("equipped", &x)
- },
- };
- ds.field("path", &self.path());
- ds.finish()
- }
+ 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());
+ ds.field("hp", &self.hp());
+ ds.field("name", &self.name());
+ ds.field("inventory", &self.inventory());
+ ds.field("color", &self.color());
+ ds.field("weapons", &self.weapons());
+ ds.field("equipped_type", &self.equipped_type());
+ match self.equipped_type() {
+ Equipment::Weapon => {
+ if let Some(x) = self.equipped_as_weapon() {
+ ds.field("equipped", &x)
+ } else {
+ ds.field("equipped", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("equipped", &x)
+ },
+ };
+ ds.field("path", &self.path());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
- pub pos: Option<Vec3T>,
- pub mana: i16,
- pub hp: i16,
- pub name: Option<alloc::string::String>,
- pub inventory: Option<alloc::vec::Vec<u8>>,
- pub color: Color,
- pub weapons: Option<alloc::vec::Vec<WeaponT>>,
- pub equipped: EquipmentT,
- pub path: Option<alloc::vec::Vec<Vec3T>>,
+ pub pos: Option<Vec3T>,
+ pub mana: i16,
+ pub hp: i16,
+ pub name: Option<alloc::string::String>,
+ pub inventory: Option<alloc::vec::Vec<u8>>,
+ pub color: Color,
+ pub weapons: Option<alloc::vec::Vec<WeaponT>>,
+ pub equipped: EquipmentT,
+ pub path: Option<alloc::vec::Vec<Vec3T>>,
}
impl Default for MonsterT {
- fn default() -> Self {
- Self {
- pos: None,
- mana: 150,
- hp: 100,
- name: None,
- inventory: None,
- color: Color::Blue,
- weapons: None,
- equipped: EquipmentT::NONE,
- path: None,
+ fn default() -> Self {
+ Self {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: None,
+ inventory: None,
+ color: Color::Blue,
+ weapons: None,
+ equipped: EquipmentT::NONE,
+ path: None,
+ }
}
- }
}
impl MonsterT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
- let pos_tmp = self.pos.as_ref().map(|x| x.pack());
- let pos = pos_tmp.as_ref();
- let mana = self.mana;
- let hp = self.hp;
- let name = self.name.as_ref().map(|x|{
- _fbb.create_string(x)
- });
- let inventory = self.inventory.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let color = self.color;
- let weapons = self.weapons.as_ref().map(|x|{
- 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: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
- });
- Monster::create(_fbb, &MonsterArgs{
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- weapons,
- equipped_type,
- equipped,
- path,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
+ let pos_tmp = self.pos.as_ref().map(|x| x.pack());
+ let pos = pos_tmp.as_ref();
+ let mana = self.mana;
+ let hp = self.hp;
+ let name = self.name.as_ref().map(|x|{
+ _fbb.create_string(x)
+ });
+ let inventory = self.inventory.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let color = self.color;
+ let weapons = self.weapons.as_ref().map(|x|{
+ 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: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ Monster::create(_fbb, &MonsterArgs{
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ weapons,
+ equipped_type,
+ equipped,
+ path,
+ })
+ }
}
/// Verifies that a buffer of bytes contains a `Monster`
@@ -430,7 +430,7 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<Monster>(buf)
+ ::flatbuffers::root::<Monster>(buf)
}
/// Verifies that a buffer of bytes contains a size prefixed
@@ -441,7 +441,7 @@
/// `size_prefixed_root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<Monster>(buf)
+ ::flatbuffers::size_prefixed_root::<Monster>(buf)
}
/// Verifies, with the given options, that a buffer of bytes
@@ -452,10 +452,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
/// Verifies, with the given verifier options, that a buffer of
@@ -466,10 +466,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
@@ -477,7 +477,7 @@
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
@@ -485,17 +485,21 @@
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
#[inline]
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<Monster<'a>>) {
- fbb.finish(root, None);
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ fbb.finish(root, None);
}
#[inline]
-pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>, root: ::flatbuffers::WIPOffset<Monster<'a>>) {
- fbb.finish_size_prefixed(root, None);
+pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ fbb.finish_size_prefixed(root, None);
}
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 cc2c5c1..5b2aca7 100644
--- a/samples/rust_generated/my_game/sample/vec_3_generated.rs
+++ b/samples/rust_generated/my_game/sample/vec_3_generated.rs
@@ -8,40 +8,40 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 12]);
-impl Default for Vec3 {
- fn default() -> Self {
- Self([0; 12])
- }
+impl Default for Vec3 {
+ fn default() -> Self {
+ Self([0; 12])
+ }
}
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())
- .field("z", &self.z())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Vec3")
+ .field("x", &self.x())
+ .field("y", &self.y())
+ .field("z", &self.z())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Vec3>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Vec3>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Vec3 {
@@ -60,141 +60,141 @@
}
impl<'a> ::flatbuffers::Verifiable for Vec3 {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Vec3 {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- x: f32,
- y: f32,
- z: f32,
- ) -> Self {
- let mut s = Self([0; 12]);
- s.set_x(x);
- s.set_y(y);
- s.set_z(z);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Sample.Vec3"
- }
-
- pub fn x(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[0..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_x(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ x: f32,
+ y: f32,
+ z: f32,
+ ) -> Self {
+ let mut s = Self([0; 12]);
+ s.set_x(x);
+ s.set_y(y);
+ s.set_z(z);
+ s
}
- }
- pub fn y(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[4..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_y(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Sample.Vec3"
}
- }
- pub fn z(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[8..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_z(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[8..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn x(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn unpack(&self) -> Vec3T {
- Vec3T {
- x: self.x(),
- y: self.y(),
- z: self.z(),
+ pub fn set_x(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
+
+ pub fn y(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_y(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn z(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[8..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_z(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[8..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> Vec3T {
+ Vec3T {
+ x: self.x(),
+ y: self.y(),
+ z: self.z(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Vec3T {
- pub x: f32,
- pub y: f32,
- pub z: f32,
+ pub x: f32,
+ pub y: f32,
+ pub z: f32,
}
impl Vec3T {
- pub fn pack(&self) -> Vec3 {
- Vec3::new(
- self.x,
- self.y,
- self.z,
- )
- }
+ pub fn pack(&self) -> Vec3 {
+ Vec3::new(
+ self.x,
+ self.y,
+ self.z,
+ )
+ }
}
diff --git a/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs
index d11525f..f6598ec 100644
--- a/samples/rust_generated/my_game/sample/weapon_generated.rs
+++ b/samples/rust_generated/my_game/sample/weapon_generated.rs
@@ -7,81 +7,81 @@
#[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> {
- type Inner = Weapon<'a>;
+ type Inner = Weapon<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Weapon<'a> {
- pub const VT_NAME: ::flatbuffers::VOffsetT = 4;
- pub const VT_DAMAGE: ::flatbuffers::VOffsetT = 6;
+ pub const VT_NAME: ::flatbuffers::VOffsetT = 4;
+ pub const VT_DAMAGE: ::flatbuffers::VOffsetT = 6;
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Sample.Weapon"
- }
-
- #[inline]
- pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
- 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>,
- args: &'args WeaponArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Weapon<'bldr>> {
- let mut builder = WeaponBuilder::new(_fbb);
- if let Some(x) = args.name { builder.add_name(x); }
- builder.add_damage(args.damage);
- builder.finish()
- }
-
- pub fn unpack(&self) -> WeaponT {
- let name = self.name().map(|x| {
- alloc::string::ToString::to_string(x)
- });
- let damage = self.damage();
- WeaponT {
- name,
- damage,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Sample.Weapon"
}
- }
- #[inline]
- pub fn name(&self) -> Option<&'a str> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Weapon { _tab: table }
+ }
- #[inline]
- pub fn damage(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()}
- }
+ #[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>,
+ args: &'args WeaponArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Weapon<'bldr>> {
+ let mut builder = WeaponBuilder::new(_fbb);
+ if let Some(x) = args.name { builder.add_name(x); }
+ builder.add_damage(args.damage);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> WeaponT {
+ let name = self.name().map(|x| {
+ alloc::string::ToString::to_string(x)
+ });
+ let damage = self.damage();
+ WeaponT {
+ name,
+ damage,
+ }
+ }
+
+ #[inline]
+ pub fn name(&self) -> Option<&'a str> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Weapon::VT_NAME, None)}
+ }
+
+ #[inline]
+ pub fn damage(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Weapon::VT_DAMAGE, Some(0)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for Weapon<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
- .visit_field::<i16>("damage", Self::VT_DAMAGE, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, false)?
+ .visit_field::<i16>("damage", Self::VT_DAMAGE, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct WeaponArgs<'a> {
@@ -90,84 +90,84 @@
}
impl<'a> Default for WeaponArgs<'a> {
- #[inline]
- fn default() -> Self {
- WeaponArgs {
- name: None,
- damage: 0,
+ #[inline]
+ fn default() -> Self {
+ WeaponArgs {
+ name: None,
+ damage: 0,
+ }
}
- }
}
pub struct WeaponBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> WeaponBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Weapon::VT_NAME, name);
- }
-
- #[inline]
- pub fn add_damage(&mut self, damage: i16) {
- self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- WeaponBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ 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 finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_damage(&mut self, damage: i16) {
+ self.fbb_.push_slot::<i16>(Weapon::VT_DAMAGE, damage, 0);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> WeaponBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ WeaponBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.finish()
- }
+ 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());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct WeaponT {
- pub name: Option<alloc::string::String>,
- pub damage: i16,
+ pub name: Option<alloc::string::String>,
+ pub damage: i16,
}
impl Default for WeaponT {
- fn default() -> Self {
- Self {
- name: None,
- damage: 0,
+ fn default() -> Self {
+ Self {
+ name: None,
+ damage: 0,
+ }
}
- }
}
impl WeaponT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Weapon<'b>> {
- let name = self.name.as_ref().map(|x|{
- _fbb.create_string(x)
- });
- let damage = self.damage;
- Weapon::create(_fbb, &WeaponArgs{
- name,
- damage,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Weapon<'b>> {
+ let name = self.name.as_ref().map(|x|{
+ _fbb.create_string(x)
+ });
+ let damage = self.damage;
+ Weapon::create(_fbb, &WeaponArgs{
+ name,
+ damage,
+ })
+ }
}
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index 398475f..13a0241 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -330,7 +330,7 @@
it++) {
root_module.Insert(namer, *it);
}
- CodeWriter code(" ");
+ CodeWriter code(" ");
// TODO(caspern): Move generated warning out of BaseGenerator.
code +=
"// Automatically generated by the Flatbuffers compiler. "
@@ -354,7 +354,7 @@
namer_(WithFlagOptions(RustDefaultConfig(), parser.opts, path),
RustKeywords()) {
// TODO: Namer flag overrides should be in flatc or flatc_main.
- code_.SetPadding(" ");
+ code_.SetPadding(" ");
}
bool generate() {
@@ -729,16 +729,16 @@
// constants but in camel case.
code_ += "#[allow(non_upper_case_globals)]";
code_ += "mod bitflags_{{ENUM_NAMESPACE}} {";
- code_ += " ::flatbuffers::bitflags::bitflags! {";
- GenComment(enum_def.doc_comment, " ");
- code_ += " #[derive(Default, Debug, Clone, Copy, PartialEq)]";
- code_ += " {{ACCESS_TYPE}} struct {{ENUM_TY}}: {{BASE_TYPE}} {";
+ code_ += " ::flatbuffers::bitflags::bitflags! {";
+ GenComment(enum_def.doc_comment, " ");
+ code_ += " #[derive(Default, Debug, Clone, Copy, PartialEq)]";
+ code_ += " {{ACCESS_TYPE}} struct {{ENUM_TY}}: {{BASE_TYPE}} {";
ForAllEnumValues1(enum_def, [&](const EnumVal& ev) {
- this->GenComment(ev.doc_comment, " ");
- code_ += " const {{VARIANT}} = {{VALUE}};";
+ this->GenComment(ev.doc_comment, " ");
+ code_ += " const {{VARIANT}} = {{VALUE}};";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "}";
code_ += "";
@@ -794,36 +794,39 @@
});
code_ += "";
// Generate Associated constants
- code_ += " pub const ENUM_MIN: {{BASE_TYPE}} = {{ENUM_MIN_BASE_VALUE}};";
- code_ += " pub const ENUM_MAX: {{BASE_TYPE}} = {{ENUM_MAX_BASE_VALUE}};";
- code_ += " pub const ENUM_VALUES: &'static [Self] = &[";
- ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
- code_ += " ];";
+ code_ +=
+ " pub const ENUM_MIN: {{BASE_TYPE}} = {{ENUM_MIN_BASE_VALUE}};";
+ code_ +=
+ " pub const ENUM_MAX: {{BASE_TYPE}} = {{ENUM_MAX_BASE_VALUE}};";
+ code_ += " pub const ENUM_VALUES: &'static [Self] = &[";
+ ForAllEnumValues(enum_def, [&]() { code_ += " Self::{{VARIANT}},"; });
+ code_ += " ];";
code_ += "";
- code_ += " /// Returns the variant's name or \"\" if unknown.";
- code_ += " pub fn variant_name(self) -> Option<&'static str> {";
- code_ += " match self {";
+ code_ += " /// Returns the variant's name or \"\" if unknown.";
+ code_ += " pub fn variant_name(self) -> Option<&'static str> {";
+ code_ += " match self {";
ForAllEnumValues(enum_def, [&]() {
- code_ += " Self::{{VARIANT}} => Some(\"{{VARIANT}}\"),";
+ code_ += " Self::{{VARIANT}} => Some(\"{{VARIANT}}\"),";
});
- code_ += " _ => None,";
+ code_ += " _ => None,";
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "}";
code_ += "";
// Generate Debug. Unknown variants are printed like "<UNKNOWN 42>".
code_ += "impl ::core::fmt::Debug for {{ENUM_TY}} {";
code_ +=
- " fn fmt(&self, f: &mut ::core::fmt::Formatter) ->"
+ " 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 {";
- code_ += " f.write_fmt(format_args!(\"<UNKNOWN {:?}>\", self.0))";
+ code_ += " if let Some(name) = self.variant_name() {";
+ code_ += " f.write_str(name)";
+ code_ += " } else {";
+ code_ +=
+ " f.write_fmt(format_args!(\"<UNKNOWN {:?}>\", self.0))";
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "}";
code_ += "";
@@ -834,19 +837,20 @@
if (parser_.opts.rust_serialize) {
code_ += "impl Serialize for {{ENUM_TY}} {";
code_ +=
- " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
- code_ += " where";
- code_ += " S: Serializer,";
- code_ += " {";
+ " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
+ "S::Error>";
+ code_ += " where";
+ code_ += " S: Serializer,";
+ code_ += " {";
if (IsBitFlagsEnum(enum_def)) {
- code_ += " serializer.serialize_u32(self.bits() as u32)";
+ code_ += " serializer.serialize_u32(self.bits() as u32)";
} else {
code_ +=
- " serializer.serialize_unit_variant(\"{{ENUM_TY}}\", self.0 "
+ " serializer.serialize_unit_variant(\"{{ENUM_TY}}\", self.0 "
"as "
"u32, self.variant_name().unwrap())";
}
- code_ += " }";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -859,7 +863,9 @@
code_ += " {";
code_ += " let s = String::deserialize(deserializer)?;";
code_ += " for item in {{ENUM_TY}}::ENUM_VALUES {";
- code_ += " if let Some(item_name) = item.variant_name() {";
+ code_ +=
+ " if let Some(item_name) = "
+ "item.variant_name() {";
code_ += " if item_name == s {";
code_ += " return Ok(item.clone());";
code_ += " }";
@@ -876,19 +882,19 @@
// Generate Follow and Push so we can serialize and stuff.
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{ENUM_TY}} {";
- code_ += " type Inner = Self;";
+ code_ += " type Inner = Self;";
code_ += "";
- code_ += " #[inline]";
- code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
+ code_ += " #[inline]";
+ code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
- " let b = unsafe { "
+ " let b = unsafe { "
"::flatbuffers::read_scalar_at::<{{BASE_TYPE}}>(buf, loc) };";
if (IsBitFlagsEnum(enum_def)) {
- code_ += " Self::from_bits_retain(b)";
+ code_ += " Self::from_bits_retain(b)";
} else {
- code_ += " Self(b)";
+ code_ += " Self(b)";
}
- code_ += " }";
+ code_ += " }";
code_ += "}";
code_ += "";
code_ += "impl ::flatbuffers::Push for {{ENUM_TY}} {";
@@ -903,34 +909,34 @@
code_ += "}";
code_ += "";
code_ += "impl ::flatbuffers::EndianScalar for {{ENUM_TY}} {";
- code_ += " type Scalar = {{BASE_TYPE}};";
+ code_ += " type Scalar = {{BASE_TYPE}};";
code_ += "";
- code_ += " #[inline]";
- code_ += " fn to_little_endian(self) -> {{BASE_TYPE}} {";
- code_ += " {{INTO_BASE}}.to_le()";
- code_ += " }";
+ code_ += " #[inline]";
+ code_ += " fn to_little_endian(self) -> {{BASE_TYPE}} {";
+ code_ += " {{INTO_BASE}}.to_le()";
+ code_ += " }";
code_ += "";
- code_ += " #[inline]";
- code_ += " #[allow(clippy::wrong_self_convention)]";
- code_ += " fn from_little_endian(v: {{BASE_TYPE}}) -> Self {";
- code_ += " let b = {{BASE_TYPE}}::from_le(v);";
+ code_ += " #[inline]";
+ code_ += " #[allow(clippy::wrong_self_convention)]";
+ code_ += " fn from_little_endian(v: {{BASE_TYPE}}) -> Self {";
+ code_ += " let b = {{BASE_TYPE}}::from_le(v);";
if (IsBitFlagsEnum(enum_def)) {
- code_ += " Self::from_bits_retain(b)";
+ code_ += " Self::from_bits_retain(b)";
} else {
- code_ += " Self(b)";
+ code_ += " Self(b)";
}
- code_ += " }";
+ code_ += " }";
code_ += "}";
code_ += "";
// Generate verifier - deferring to the base type.
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_ += " {{BASE_TYPE}}::run_verifier(v, pos)";
- code_ += " }";
+ code_ += " #[inline]";
+ code_ += " fn run_verifier(";
+ 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.
@@ -978,7 +984,7 @@
code_ += "#[non_exhaustive]";
code_ += "#[derive(Debug, Clone, PartialEq)]";
code_ += "{{ACCESS_TYPE}} enum {{ENUM_OTY}} {";
- code_ += " NONE,";
+ code_ += " NONE,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
code_ +=
"{{NATIVE_VARIANT}}(alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>),";
@@ -988,9 +994,9 @@
// Generate Default (NONE).
code_ += "impl Default for {{ENUM_OTY}} {";
- code_ += " fn default() -> Self {";
- code_ += " Self::NONE";
- code_ += " }";
+ code_ += " fn default() -> Self {";
+ code_ += " Self::NONE";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -999,32 +1005,33 @@
// Get flatbuffers union key.
// TODO(cneo): add docstrings?
- code_ += " pub fn {{ENUM_FN}}_type(&self) -> {{ENUM_TY}} {";
- code_ += " match self {";
- code_ += " Self::NONE => {{ENUM_TY}}::NONE,";
+ code_ += " pub fn {{ENUM_FN}}_type(&self) -> {{ENUM_TY}} {";
+ code_ += " match self {";
+ code_ += " Self::NONE => {{ENUM_TY}}::NONE,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
code_ +=
- " Self::{{NATIVE_VARIANT}}(_) => {{ENUM_TY}}::"
+ " Self::{{NATIVE_VARIANT}}(_) => {{ENUM_TY}}::"
"{{VARIANT_NAME}},";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "";
// Pack flatbuffers union value
code_ +=
- " pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut "
+ " 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,";
+ code_ += " match self {";
+ code_ += " Self::NONE => None,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
- code_ += " Self::{{NATIVE_VARIANT}}(v) => \\";
+ code_ += " Self::{{NATIVE_VARIANT}}(v) => \\";
code_ += "Some(v.pack(fbb).as_union_value()),";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
// Generate some accessors;
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
@@ -1036,16 +1043,16 @@
code_ +=
"pub fn take_{{U_ELEMENT_NAME}}(&mut self) -> "
"Option<alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>> {";
- code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {";
- code_ += " let v = ::core::mem::replace(self, Self::NONE);";
- code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {";
- code_ += " Some(w)";
+ code_ += " if let Self::{{NATIVE_VARIANT}}(_) = self {";
+ code_ += " let v = ::core::mem::replace(self, Self::NONE);";
+ code_ += " if let Self::{{NATIVE_VARIANT}}(w) = v {";
+ code_ += " Some(w)";
+ code_ += " } else {";
+ code_ += " unreachable!()";
+ code_ += " }";
code_ += " } else {";
- code_ += " unreachable!()";
+ code_ += " None";
code_ += " }";
- code_ += " } else {";
- code_ += " None";
- code_ += " }";
code_ += "}";
// Immutable reference accessor.
@@ -1057,7 +1064,7 @@
"pub fn as_{{U_ELEMENT_NAME}}(&self) -> "
"Option<&{{U_ELEMENT_TABLE_TYPE}}> {";
code_ +=
- " if let Self::{{NATIVE_VARIANT}}(v) = self "
+ " if let Self::{{NATIVE_VARIANT}}(v) = self "
"{ Some(v.as_ref()) } else { None }";
code_ += "}";
@@ -1070,7 +1077,7 @@
"pub fn as_{{U_ELEMENT_NAME}}_mut(&mut self) -> "
"Option<&mut {{U_ELEMENT_TABLE_TYPE}}> {";
code_ +=
- " if let Self::{{NATIVE_VARIANT}}(v) = self "
+ " if let Self::{{NATIVE_VARIANT}}(v) = self "
"{ Some(v.as_mut()) } else { None }";
code_ += "}";
});
@@ -1649,9 +1656,9 @@
const std::string& name) {
const std::string fully_qualified_name =
struct_def.defined_namespace->GetFullyQualifiedName(name);
- code_ += " pub const fn get_fully_qualified_name() -> &'static str {";
- code_ += " \"" + fully_qualified_name + "\"";
- code_ += " }";
+ code_ += " pub const fn get_fully_qualified_name() -> &'static str {";
+ code_ += " \"" + fully_qualified_name + "\"";
+ code_ += " }";
code_ += "";
}
@@ -1721,17 +1728,17 @@
code_ += "#[derive(Copy, Clone, PartialEq)]";
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_ += " type Inner = {{STRUCT_TY}}<'a>;";
+ code_ += " type Inner = {{STRUCT_TY}}<'a>;";
code_ += "";
- code_ += " #[inline]";
- code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
+ code_ += " #[inline]";
+ code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
- " Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }";
- code_ += " }";
+ " Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }";
+ code_ += " }";
code_ += "}";
code_ += "";
code_ += "impl<'a> {{STRUCT_TY}}<'a> {";
@@ -1750,12 +1757,12 @@
GenFullyQualifiedNameGetter(struct_def, struct_def.name);
}
- code_ += " #[inline]";
+ 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_ += " }";
+ code_ += " {{STRUCT_TY}} { _tab: table }";
+ code_ += " }";
code_ += "";
// Generate a convenient create* function that uses the above builder
@@ -1763,16 +1770,17 @@
code_.SetValue("MAYBE_US", struct_def.fields.vec.size() == 0 ? "_" : "");
code_.SetValue("MAYBE_LT",
TableBuilderArgsNeedsLifetime(struct_def) ? "<'args>" : "");
- code_ += " #[allow(unused_mut)]";
+ code_ += " #[allow(unused_mut)]";
code_ +=
- " pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: "
+ " pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr, A: "
"::flatbuffers::Allocator + 'bldr>(";
code_ +=
- " _fbb: &'mut_bldr mut ::flatbuffers::FlatBufferBuilder<'bldr, A>,";
- code_ += " {{MAYBE_US}}args: &'args {{STRUCT_TY}}Args{{MAYBE_LT}}";
- code_ += " ) -> ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'bldr>> {";
+ " _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_ += " let mut builder = {{STRUCT_TY}}Builder::new(_fbb);";
+ code_ += " let mut builder = {{STRUCT_TY}}Builder::new(_fbb);";
for (size_t size = struct_def.sortbysize ? sizeof(largest_scalar_t) : 1;
size; size /= 2) {
ForAllTableFields(
@@ -1783,16 +1791,16 @@
return;
if (IsOptionalToBuilder(field)) {
code_ +=
- " if let Some(x) = args.{{FIELD}} "
+ " if let Some(x) = args.{{FIELD}} "
"{ builder.add_{{FIELD}}(x); }";
} else {
- code_ += " builder.add_{{FIELD}}(args.{{FIELD}});";
+ code_ += " builder.add_{{FIELD}}(args.{{FIELD}});";
}
},
/*reverse=*/true);
}
- code_ += " builder.finish()";
- code_ += " }";
+ code_ += " builder.finish()";
+ code_ += " }";
code_ += "";
// Generate Object API Packer function.
@@ -1800,7 +1808,7 @@
// TODO(cneo): Replace more for loops with ForAllX stuff.
// TODO(cneo): Manage indentation with IncrementIdentLevel?
code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def));
- code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
+ code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
ForAllObjectTableFields(struct_def, [&](const FieldDef& field) {
const Type& type = field.value.type;
switch (GetFullType(type)) {
@@ -1808,7 +1816,7 @@
case ftBool:
case ftFloat:
case ftEnumKey: {
- code_ += " let {{FIELD}} = self.{{FIELD}}();";
+ code_ += " let {{FIELD}} = self.{{FIELD}}();";
return;
}
case ftUnionKey:
@@ -1820,23 +1828,23 @@
code_.SetValue("UNION_TYPE_METHOD",
namer_.LegacyRustUnionTypeMethod(field));
- code_ += " let {{FIELD}} = match self.{{UNION_TYPE_METHOD}}() {";
- code_ += " {{ENUM_TY}}::NONE => {{NATIVE_ENUM_NAME}}::NONE,";
+ code_ += " let {{FIELD}} = match self.{{UNION_TYPE_METHOD}}() {";
+ code_ += " {{ENUM_TY}}::NONE => {{NATIVE_ENUM_NAME}}::NONE,";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
code_ +=
- " {{ENUM_TY}}::{{VARIANT_NAME}} => "
+ " {{ENUM_TY}}::{{VARIANT_NAME}} => "
"{{NATIVE_ENUM_NAME}}::{{NATIVE_VARIANT}}(alloc::boxed::Box::"
"new(";
- code_ += " self.{{FIELD}}_as_{{U_ELEMENT_NAME}}()";
+ code_ += " self.{{FIELD}}_as_{{U_ELEMENT_NAME}}()";
code_ +=
- " .expect(\"Invalid union table, "
+ " .expect(\"Invalid union table, "
"expected `{{ENUM_TY}}::{{VARIANT_NAME}}`.\")";
- code_ += " .unpack()";
- code_ += " )),";
+ code_ += " .unpack()";
+ code_ += " )),";
});
// Maybe we shouldn't throw away unknown discriminants?
- code_ += " _ => {{NATIVE_ENUM_NAME}}::NONE,";
- code_ += " };";
+ code_ += " _ => {{NATIVE_ENUM_NAME}}::NONE,";
+ code_ += " };";
return;
}
// The rest of the types need special handling based on if the field
@@ -1884,24 +1892,24 @@
}
}
if (field.IsOptional()) {
- code_ += " let {{FIELD}} = self.{{FIELD}}().map(|x| {";
- code_ += " {{EXPR}}";
- code_ += " });";
+ code_ += " let {{FIELD}} = self.{{FIELD}}().map(|x| {";
+ code_ += " {{EXPR}}";
+ code_ += " });";
} else {
- code_ += " let {{FIELD}} = {";
- code_ += " let x = self.{{FIELD}}();";
- code_ += " {{EXPR}}";
- code_ += " };";
+ code_ += " let {{FIELD}} = {";
+ code_ += " let x = self.{{FIELD}}();";
+ code_ += " {{EXPR}}";
+ code_ += " };";
}
});
- code_ += " {{STRUCT_OTY}} {";
+ code_ += " {{STRUCT_OTY}} {";
ForAllObjectTableFields(struct_def, [&](const FieldDef& field) {
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
- code_ += " {{FIELD}},";
+ code_ += " {{FIELD}},";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
}
// Generate the accessors. Each has one of two forms:
@@ -1923,10 +1931,10 @@
this->GenComment(field.doc_comment);
code_ += "#[inline]";
code_ += "pub fn {{FIELD}}(&self) -> {{RETURN_TYPE}} {";
- code_ += " // Safety:";
- code_ += " // Created from valid Table for this object";
- code_ += " // which contains a valid value in this slot";
- code_ += " " + GenTableAccessorFuncBody(field, "'a");
+ code_ += " // Safety:";
+ code_ += " // Created from valid Table for this object";
+ code_ += " // which contains a valid value in this slot";
+ code_ += " " + GenTableAccessorFuncBody(field, "'a");
code_ += "}";
// Generate a comparison function for this field if it is a key.
@@ -1951,17 +1959,7 @@
code_ += "pub fn {{FIELD}}_nested_flatbuffer(&'a self) -> \\";
if (field.IsRequired()) {
code_ += "{{NESTED}}<'a> {";
- code_ += " let data = self.{{FIELD}}();";
- 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 { <::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
- "::follow(data.bytes(), 0) }";
- } else {
- code_ += "Option<{{NESTED}}<'a>> {";
- code_ += " self.{{FIELD}}().map(|data| {";
+ code_ += " let data = self.{{FIELD}}();";
code_ += " use ::flatbuffers::Follow;";
code_ += " // Safety:";
code_ += " // Created from a valid Table for this object";
@@ -1969,7 +1967,18 @@
code_ +=
" unsafe { <::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
"::follow(data.bytes(), 0) }";
- code_ += " })";
+ } else {
+ code_ += "Option<{{NESTED}}<'a>> {";
+ code_ += " self.{{FIELD}}().map(|data| {";
+ 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 { "
+ "<::flatbuffers::ForwardsUOffset<{{NESTED}}<'a>>>"
+ "::follow(data.bytes(), 0) }";
+ code_ += " })";
}
code_ += "}";
}
@@ -1999,31 +2008,34 @@
//
// To avoid this problem the type field name is used unescaped here:
code_ +=
- " if self.{{DISCRIMINANT}}() == {{U_ELEMENT_ENUM_TYPE}} {";
+ " if self.{{DISCRIMINANT}}() == {{U_ELEMENT_ENUM_TYPE}} {";
// The following logic is not tested in the integration test,
// as of April 10, 2020
if (field.IsRequired()) {
- code_ += " let u = self.{{FIELD}}();";
- code_ += " // Safety:";
- code_ += " // Created from a valid Table for this object";
- code_ += " // Which contains a valid union in this slot";
+ code_ += " let u = self.{{FIELD}}();";
+ code_ += " // Safety:";
+ code_ += " // Created from a valid Table for this object";
+ code_ += " // Which contains a valid union in this slot";
code_ +=
" Some(unsafe { "
"{{U_ELEMENT_TABLE_TYPE}}::init_from_table(u) })";
} else {
- code_ += " self.{{FIELD}}().map(|t| {";
- code_ += " // Safety:";
- code_ += " // Created from a valid Table for this object";
- code_ += " // Which contains a valid union in this slot";
+ code_ += " self.{{FIELD}}().map(|t| {";
+ code_ += " // Safety:";
code_ +=
- " unsafe { {{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) "
+ " // Created from a valid Table for this object";
+ code_ +=
+ " // Which contains a valid union in this slot";
+ code_ +=
+ " unsafe { "
+ "{{U_ELEMENT_TABLE_TYPE}}::init_from_table(t) "
"}";
- code_ += " })";
+ code_ += " })";
}
- code_ += " } else {";
- code_ += " None";
- code_ += " }";
+ code_ += " } else {";
+ code_ += " None";
+ code_ += " }";
code_ += "}";
});
});
@@ -2032,11 +2044,11 @@
// Generate Verifier;
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_ += " v.visit_table(pos)?\\";
+ code_ += " #[inline]";
+ code_ += " fn run_verifier(";
+ 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.
ForAllTableFields(struct_def, [&](const FieldDef& field) {
@@ -2047,8 +2059,8 @@
// All types besides unions.
code_.SetValue("TY", FollowType(field.value.type, "'_"));
code_ +=
- "\n .visit_field::<{{TY}}>(\"{{FIELD}}\", "
- "Self::{{OFFSET_NAME}}, {{IS_REQ}})?\\";
+ " .visit_field::<{{TY}}>(\"{{FIELD}}\", "
+ "Self::{{OFFSET_NAME}}, {{IS_REQ}})?";
return;
}
// Unions.
@@ -2059,25 +2071,26 @@
code_.SetValue("UNION_TYPE_METHOD",
namer_.LegacyRustUnionTypeMethod(field));
code_ +=
- "\n .visit_union::<{{UNION_TYPE}}, _>("
+ " .visit_union::<{{UNION_TYPE}}, _>("
"\"{{UNION_TYPE_METHOD}}\", Self::{{UNION_TYPE_OFFSET_NAME}}, "
"\"{{FIELD}}\", Self::{{OFFSET_NAME}}, {{IS_REQ}}, "
"|key, v, pos| {";
- code_ += " match key {";
+ code_ += " match key {";
ForAllUnionVariantsBesidesNone(union_def, [&](const EnumVal& unused) {
(void)unused;
code_ +=
- " {{U_ELEMENT_ENUM_TYPE}} => v.verify_union_variant::"
+ " {{U_ELEMENT_ENUM_TYPE}} => "
+ "v.verify_union_variant::"
"<::flatbuffers::ForwardsUOffset<{{U_ELEMENT_TABLE_TYPE}}>>("
"\"{{U_ELEMENT_ENUM_TYPE}}\", pos),";
});
- code_ += " _ => Ok(()),";
- code_ += " }";
- code_ += " })?\\";
+ code_ += " _ => Ok(()),";
+ code_ += " }";
+ code_ += " })?";
});
- code_ += "\n .finish();";
- code_ += " Ok(())";
- code_ += " }";
+ code_ += " .finish();";
+ code_ += " Ok(())";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -2087,22 +2100,22 @@
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}Args{{MAYBE_LT}} {";
ForAllTableFields(struct_def, [&](const FieldDef& field) {
code_.SetValue("PARAM_TYPE", TableBuilderArgsDefnType(field, "'a"));
- code_ += " pub {{FIELD}}: {{PARAM_TYPE}},";
+ code_ += "pub {{FIELD}}: {{PARAM_TYPE}},";
});
code_ += "}";
code_ += "";
// Generate an impl of Default for the *Args type:
code_ += "impl<'a> Default for {{STRUCT_TY}}Args{{MAYBE_LT}} {";
- code_ += " #[inline]";
- code_ += " fn default() -> Self {";
- code_ += " {{STRUCT_TY}}Args {";
+ code_ += " #[inline]";
+ code_ += " fn default() -> Self {";
+ code_ += " {{STRUCT_TY}}Args {";
ForAllTableFields(struct_def, [&](const FieldDef& field) {
- code_ += " {{FIELD}}: {{BLDR_DEF_VAL}},\\";
+ code_ += " {{FIELD}}: {{BLDR_DEF_VAL}},\\";
code_ += field.IsRequired() ? " // required field" : "";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "}";
code_ += "";
@@ -2112,17 +2125,19 @@
code_.SetValue("NUM_FIELDS", NumToString(numFields));
code_ += "impl Serialize for {{STRUCT_TY}}<'_> {";
code_ +=
- " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
- code_ += " where";
- code_ += " S: Serializer,";
- code_ += " {";
+ " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
+ "S::Error>";
+ code_ += " where";
+ code_ += " S: Serializer,";
+ code_ += " {";
if (numFields == 0) {
code_ +=
- " let s = serializer.serialize_struct(\"{{STRUCT_TY}}\", 0)?;";
+ " let s = serializer.serialize_struct(\"{{STRUCT_TY}}\", "
+ "0)?;";
} else {
code_ +=
- " let mut s = serializer.serialize_struct(\"{{STRUCT_TY}}\", "
- "{{NUM_FIELDS}})?;";
+ " let mut s = "
+ "serializer.serialize_struct(\"{{STRUCT_TY}}\", {{NUM_FIELDS}})?;";
}
ForAllTableFields(struct_def, [&](const FieldDef& field) {
const Type& type = field.value.type;
@@ -2135,20 +2150,20 @@
namer_.LegacyRustUnionTypeMethod(field));
code_ += " match self.{{UNION_TYPE_METHOD}}() {";
- code_ += " {{ENUM_TY}}::NONE => (),";
+ code_ += " {{ENUM_TY}}::NONE => (),";
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
code_.SetValue("FIELD", namer_.Field(field));
- code_ += " {{ENUM_TY}}::{{VARIANT_NAME}} => {";
+ code_ += " {{ENUM_TY}}::{{VARIANT_NAME}} => {";
code_ +=
- " let f = "
+ " let f = "
"self.{{FIELD}}_as_{{U_ELEMENT_NAME}}()";
code_ +=
- " .expect(\"Invalid union table, expected "
+ " .expect(\"Invalid union table, expected "
"`{{ENUM_TY}}::{{VARIANT_NAME}}`.\");";
- code_ += " s.serialize_field(\"{{FIELD}}\", &f)?;";
- code_ += " }";
+ code_ += " s.serialize_field(\"{{FIELD}}\", &f)?;";
+ code_ += " }";
});
- code_ += " _ => unimplemented!(),";
+ code_ += " _ => unimplemented!(),";
code_ += " }";
} else {
code_ +=
@@ -2158,9 +2173,9 @@
} else {
if (field.IsOptional()) {
code_ += " if let Some(f) = self.{{FIELD}}() {";
- code_ += " s.serialize_field(\"{{FIELD}}\", &f)?;";
+ code_ += " s.serialize_field(\"{{FIELD}}\", &f)?;";
code_ += " } else {";
- code_ += " s.skip_field(\"{{FIELD}}\")?;";
+ code_ += " s.skip_field(\"{{FIELD}}\")?;";
code_ += " }";
} else {
code_ +=
@@ -2169,8 +2184,8 @@
}
}
});
- code_ += " s.end()";
- code_ += " }";
+ code_ += " s.end()";
+ code_ += " }";
code_ += "}";
code_ += "";
}
@@ -2179,9 +2194,9 @@
code_ +=
"{{ACCESS_TYPE}} struct {{STRUCT_TY}}Builder<'a: 'b, 'b, A: "
"::flatbuffers::Allocator + 'a> {";
- code_ += " fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
+ code_ += " fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
code_ +=
- " start_: ::flatbuffers::WIPOffset<"
+ " start_: ::flatbuffers::WIPOffset<"
"::flatbuffers::TableUnfinishedWIPOffset>,";
code_ += "}";
code_ += "";
@@ -2214,53 +2229,53 @@
"{{FIELD_TYPE}}) {";
if (is_scalar && !field.IsOptional()) {
code_ +=
- " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}}, "
+ " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}}, "
"{{BLDR_DEF_VAL}});";
} else {
- code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}});";
+ code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}});";
}
code_ += "}";
code_ += "";
});
// Struct initializer (all fields required);
- code_ += " #[inline]";
+ 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();";
- code_ += " {{STRUCT_TY}}Builder {";
- code_ += " fbb_: _fbb,";
- code_ += " start_: start,";
+ code_ += " let start = _fbb.start_table();";
+ code_ += " {{STRUCT_TY}}Builder {";
+ code_ += " fbb_: _fbb,";
+ code_ += " start_: start,";
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "";
// finish() function.
- code_ += " #[inline]";
+ code_ += " #[inline]";
code_ +=
- " pub fn finish(self) -> "
+ " pub fn finish(self) -> "
"::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>> {";
- code_ += " let o = self.fbb_.end_table(self.start_);";
+ code_ += " let o = self.fbb_.end_table(self.start_);";
ForAllTableFields(struct_def, [&](const FieldDef& field) {
if (!field.IsRequired()) return;
code_ +=
- " self.fbb_.required(o, {{STRUCT_TY}}::{{OFFSET_NAME}},"
+ " self.fbb_.required(o, {{STRUCT_TY}}::{{OFFSET_NAME}},"
"\"{{FIELD}}\");";
});
- code_ += " ::flatbuffers::WIPOffset::new(o.value())";
- code_ += " }";
+ code_ += " ::flatbuffers::WIPOffset::new(o.value())";
+ code_ += " }";
code_ += "}";
code_ += "";
code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}}<'_> {";
code_ +=
- " fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>"
+ " fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>"
") -> ::core::fmt::Result {";
- code_ += " let mut ds = f.debug_struct(\"{{STRUCT_TY}}\");";
+ code_ += " let mut ds = f.debug_struct(\"{{STRUCT_TY}}\");";
ForAllTableFields(struct_def, [&](const FieldDef& field) {
if (GetFullType(field.value.type) == ftUnionValue) {
// Generate a match statement to handle unions properly.
@@ -2273,29 +2288,29 @@
ForAllUnionVariantsBesidesNone(
*field.value.type.enum_def, [&](const EnumVal& unused) {
(void)unused;
- code_ += " {{U_ELEMENT_ENUM_TYPE}} => {";
+ code_ += " {{U_ELEMENT_ENUM_TYPE}} => {";
code_ +=
- " if let Some(x) = "
+ " if let Some(x) = "
"self.{{FIELD}}_as_"
"{{U_ELEMENT_NAME}}() {";
- code_ += " ds.field(\"{{FIELD}}\", &x)";
- code_ += " } else {";
- code_ += " ds.field(\"{{FIELD}}\", {{UNION_ERR}})";
- code_ += " }";
- code_ += " },";
+ code_ += " ds.field(\"{{FIELD}}\", &x)";
+ code_ += " } else {";
+ code_ += " ds.field(\"{{FIELD}}\", {{UNION_ERR}})";
+ code_ += " }";
+ code_ += " },";
});
- code_ += " _ => {";
- code_ += " let x: Option<()> = None;";
- code_ += " ds.field(\"{{FIELD}}\", &x)";
- code_ += " },";
+ code_ += " _ => {";
+ code_ += " let x: Option<()> = None;";
+ code_ += " ds.field(\"{{FIELD}}\", &x)";
+ code_ += " },";
code_ += " };";
} else {
// Most fields.
code_ += " ds.field(\"{{FIELD}}\", &self.{{FIELD}}());";
}
});
- code_ += " ds.finish()";
- code_ += " }";
+ code_ += " ds.finish()";
+ code_ += " }";
code_ += "}";
}
@@ -2319,15 +2334,15 @@
code_ += "";
code_ += "impl Default for {{STRUCT_OTY}} {";
- code_ += " fn default() -> Self {";
- code_ += " Self {";
+ code_ += " fn default() -> Self {";
+ code_ += " Self {";
ForAllObjectTableFields(table, [&](const FieldDef& field) {
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
std::string default_value = GetDefaultValue(field, kObject);
- code_ += " {{FIELD}}: " + default_value + ",";
+ code_ += " {{FIELD}}: " + default_value + ",";
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
code_ += "}";
code_ += "";
@@ -2336,10 +2351,10 @@
// Generate pack function.
code_ += "impl {{STRUCT_OTY}} {";
- 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_ += " pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(";
+ code_ += " &self,";
+ 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) {
@@ -2349,7 +2364,7 @@
case ftBool:
case ftFloat:
case ftEnumKey: {
- code_ += " let {{FIELD}} = self.{{FIELD}};";
+ code_ += " let {{FIELD}} = self.{{FIELD}};";
return;
}
case ftUnionKey:
@@ -2360,9 +2375,9 @@
code_.SetValue("DISCRIMINANT",
namer_.LegacyRustUnionTypeMethod(field));
code_ +=
- " let {{DISCRIMINANT}} = "
+ " let {{DISCRIMINANT}} = "
"self.{{FIELD}}.{{ENUM_METHOD}}_type();";
- code_ += " let {{FIELD}} = self.{{FIELD}}.pack(_fbb);";
+ code_ += " let {{FIELD}} = self.{{FIELD}}.pack(_fbb);";
return;
}
// The rest of the types require special casing around optionalness
@@ -2374,13 +2389,13 @@
case ftStruct: {
// Hold the struct in a variable so we can reference it.
if (field.IsRequired()) {
- code_ += " let {{FIELD}}_tmp = Some(self.{{FIELD}}.pack());";
+ code_ += " let {{FIELD}}_tmp = Some(self.{{FIELD}}.pack());";
} else {
code_ +=
- " let {{FIELD}}_tmp = self.{{FIELD}}"
+ " let {{FIELD}}_tmp = self.{{FIELD}}"
".as_ref().map(|x| x.pack());";
}
- code_ += " let {{FIELD}} = {{FIELD}}_tmp.as_ref();";
+ code_ += " let {{FIELD}} = {{FIELD}}_tmp.as_ref();";
return;
}
@@ -2431,13 +2446,13 @@
}
}
});
- code_ += " {{STRUCT_TY}}::create(_fbb, &{{STRUCT_TY}}Args{";
+ code_ += " {{STRUCT_TY}}::create(_fbb, &{{STRUCT_TY}}Args{";
ForAllObjectTableFields(table, [&](const FieldDef& field) {
(void)field; // Unused.
- code_ += " {{FIELD}},";
+ code_ += " {{FIELD}},";
});
- code_ += " })";
- code_ += " }";
+ code_ += " })";
+ code_ += " }";
code_ += "}";
}
void ForAllObjectTableFields(const StructDef& table,
@@ -2455,16 +2470,16 @@
}
void MapNativeTableField(const FieldDef& field, const std::string& expr) {
if (field.IsOptional()) {
- code_ += " let {{FIELD}} = self.{{FIELD}}.as_ref().map(|x|{";
- code_ += " " + expr;
- code_ += " });";
+ code_ += " let {{FIELD}} = self.{{FIELD}}.as_ref().map(|x|{";
+ code_ += " " + expr;
+ code_ += " });";
} else {
// For some reason Args has optional types for required fields.
// TODO(cneo): Fix this... but its a breaking change?
- code_ += " let {{FIELD}} = Some({";
- code_ += " let x = &self.{{FIELD}};";
- code_ += " " + expr;
- code_ += " });";
+ code_ += " let {{FIELD}} = Some({";
+ code_ += " let x = &self.{{FIELD}};";
+ code_ += " " + expr;
+ code_ += " });";
}
}
@@ -2482,7 +2497,7 @@
code_ +=
"pub fn key_compare_less_than(&self, o: &{{STRUCT_TY}}) -> "
"bool {";
- code_ += " self.{{FIELD}}() < o.{{FIELD}}()";
+ code_ += " self.{{FIELD}}() < o.{{FIELD}}()";
code_ += "}";
code_ += "";
@@ -2490,8 +2505,8 @@
code_ +=
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
"::core::cmp::Ordering {";
- code_ += " let key = self.{{FIELD}}();";
- code_ += " key.cmp({{REF}}val)";
+ code_ += " let key = self.{{FIELD}}();";
+ code_ += " key.cmp({{REF}}val)";
code_ += "}";
}
@@ -2516,7 +2531,7 @@
code_ +=
"pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) "
"-> Result<{{STRUCT_TY}}<'_>, ::flatbuffers::InvalidFlatbuffer> {";
- code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)";
+ code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
code_ += "";
@@ -2531,7 +2546,7 @@
"pub fn size_prefixed_root_as_{{STRUCT_FN}}"
"(buf: &[u8]) -> Result<{{STRUCT_TY}}<'_>, "
"::flatbuffers::InvalidFlatbuffer> {";
- code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
+ code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
code_ += "";
@@ -2544,12 +2559,13 @@
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
code_ += "#[inline]";
code_ += "pub fn root_as_{{STRUCT_FN}}_with_opts<'b, 'o>(";
- code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
- code_ += " buf: &'b [u8],";
+ code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
+ code_ += " buf: &'b [u8],";
code_ +=
") -> 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_ += "";
@@ -2563,13 +2579,13 @@
code_ +=
"pub fn size_prefixed_root_as_{{STRUCT_FN}}_with_opts"
"<'b, 'o>(";
- code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
- code_ += " buf: &'b [u8],";
+ code_ += " opts: &'o ::flatbuffers::VerifierOptions,";
+ code_ += " buf: &'b [u8],";
code_ +=
") -> 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_ += "}";
code_ += "";
@@ -2586,7 +2602,8 @@
code_ +=
"pub unsafe fn root_as_{{STRUCT_FN}}_unchecked"
"(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
- code_ += " unsafe { ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
+ code_ +=
+ " unsafe { ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
code_ += "}";
code_ += "";
@@ -2602,7 +2619,7 @@
"pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}"
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
code_ +=
- " unsafe { "
+ " unsafe { "
"::flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>"
"(buf) }";
code_ += "}";
@@ -2619,14 +2636,14 @@
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_ += "";
@@ -2645,26 +2662,28 @@
"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>>) {";
+ code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>";
+ code_ += ") {";
if (parser_.file_identifier_.length()) {
- code_ += " fbb.finish(root, Some({{STRUCT_CONST}}_IDENTIFIER));";
+ code_ += " fbb.finish(root, Some({{STRUCT_CONST}}_IDENTIFIER));";
} else {
- code_ += " fbb.finish(root, None);";
+ code_ += " fbb.finish(root, None);";
}
code_ += "}";
code_ += "";
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>(";
+ code_ += " fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,";
+ code_ += " root: ::flatbuffers::WIPOffset<{{STRUCT_TY}}<'a>>";
+ code_ += ") {";
if (parser_.file_identifier_.length()) {
code_ +=
- " fbb.finish_size_prefixed(root, "
+ " fbb.finish_size_prefixed(root, "
"Some({{STRUCT_CONST}}_IDENTIFIER));";
} else {
- code_ += " fbb.finish_size_prefixed(root, None);";
+ code_ += " fbb.finish_size_prefixed(root, None);";
}
code_ += "}";
}
@@ -2740,25 +2759,25 @@
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}(pub [u8; {{STRUCT_SIZE}}]);";
code_ += "";
- code_ += "impl Default for {{STRUCT_TY}} { ";
- code_ += " fn default() -> Self { ";
- code_ += " Self([0; {{STRUCT_SIZE}}])";
- code_ += " }";
+ code_ += "impl Default for {{STRUCT_TY}} {";
+ code_ += " fn default() -> Self {";
+ code_ += " Self([0; {{STRUCT_SIZE}}])";
+ code_ += " }";
code_ += "}";
code_ += "";
// Debug for structs.
code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}} {";
code_ +=
- " fn fmt(&self, f: &mut ::core::fmt::Formatter"
+ " fn fmt(&self, f: &mut ::core::fmt::Formatter"
") -> ::core::fmt::Result {";
- code_ += " f.debug_struct(\"{{STRUCT_TY}}\")";
+ code_ += " f.debug_struct(\"{{STRUCT_TY}}\")";
ForAllStructFields(struct_def, [&](const FieldDef& unused) {
(void)unused;
- code_ += " .field(\"{{FIELD}}\", &self.{{FIELD}}())";
+ code_ += " .field(\"{{FIELD}}\", &self.{{FIELD}}())";
});
- code_ += " .finish()";
- code_ += " }";
+ code_ += " .finish()";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -2769,24 +2788,24 @@
code_ += "";
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{STRUCT_TY}} {";
- code_ += " type Inner = &'a {{STRUCT_TY}};";
+ code_ += " type Inner = &'a {{STRUCT_TY}};";
code_ += "";
- code_ += " #[inline]";
- code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
- code_ += " unsafe { <&'a {{STRUCT_TY}}>::follow(buf, loc) }";
- code_ += " }";
+ code_ += " #[inline]";
+ code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
+ code_ += " unsafe { <&'a {{STRUCT_TY}}>::follow(buf, loc) }";
+ code_ += " }";
code_ += "}";
code_ += "";
code_ += "impl<'a> ::flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {";
- code_ += " type Inner = &'a {{STRUCT_TY}};";
+ code_ += " type Inner = &'a {{STRUCT_TY}};";
code_ += "";
- code_ += " #[inline]";
- code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
+ code_ += " #[inline]";
+ code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
- " unsafe { ::flatbuffers::follow_cast_ref::<{{STRUCT_TY}}>(buf, "
+ " unsafe { ::flatbuffers::follow_cast_ref::<{{STRUCT_TY}}>(buf, "
"loc) }";
- code_ += " }";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -2813,12 +2832,12 @@
// 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_ += " #[inline]";
- code_ += " fn run_verifier(";
- code_ += " v: &mut ::flatbuffers::Verifier, pos: usize";
- code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {";
- code_ += " v.in_buffer::<Self>(pos)";
- code_ += " }";
+ code_ += " #[inline]";
+ code_ += " fn run_verifier(";
+ code_ += " v: &mut ::flatbuffers::Verifier, pos: usize";
+ code_ += " ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {";
+ code_ += " v.in_buffer::<Self>(pos)";
+ code_ += " }";
code_ += "}";
code_ += "";
@@ -2828,10 +2847,11 @@
code_.SetValue("NUM_FIELDS", NumToString(numFields));
code_ += "impl Serialize for {{STRUCT_TY}} {";
code_ +=
- " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>";
- code_ += " where";
- code_ += " S: Serializer,";
- code_ += " {";
+ " fn serialize<S>(&self, serializer: S) -> Result<S::Ok, "
+ "S::Error>";
+ code_ += " where";
+ code_ += " S: Serializer,";
+ code_ += " {";
if (numFields == 0) {
code_ +=
" let s = serializer.serialize_struct(\"{{STRUCT_TY}}\", 0)?;";
@@ -2846,28 +2866,28 @@
" s.serialize_field(\"{{FIELD}}\", "
"&self.{{FIELD}}())?;";
});
- code_ += " s.end()";
- code_ += " }";
+ code_ += " s.end()";
+ code_ += " }";
code_ += "}";
code_ += "";
}
// Generate a constructor that takes all fields as arguments.
code_ += "impl<'a> {{STRUCT_TY}} {";
- code_ += " #[allow(clippy::too_many_arguments)]";
- code_ += " pub fn new(";
+ code_ += " #[allow(clippy::too_many_arguments)]";
+ code_ += " pub fn new(";
ForAllStructFields(struct_def, [&](const FieldDef& unused) {
(void)unused;
- code_ += " {{FIELD}}: {{REF}}{{FIELD_TYPE}},";
+ code_ += " {{FIELD}}: {{REF}}{{FIELD_TYPE}},";
});
- code_ += " ) -> Self {";
- code_ += " let mut s = Self([0; {{STRUCT_SIZE}}]);";
+ code_ += " ) -> Self {";
+ code_ += " let mut s = Self([0; {{STRUCT_SIZE}}]);";
ForAllStructFields(struct_def, [&](const FieldDef& unused) {
(void)unused;
- code_ += " s.set_{{FIELD}}({{FIELD}});";
+ code_ += " s.set_{{FIELD}}({{FIELD}});";
});
- code_ += " s";
- code_ += " }";
+ code_ += " s";
+ code_ += " }";
code_ += "";
if (parser_.opts.generate_name_strings) {
@@ -2880,11 +2900,11 @@
// Getter.
if (IsStruct(field.value.type)) {
code_ += "pub fn {{FIELD}}(&self) -> &{{FIELD_TYPE}} {";
- code_ += " // Safety:";
- code_ += " // Created from a valid Table for this object";
- code_ += " // Which contains a valid struct in this slot";
+ code_ += " // Safety:";
+ code_ += " // Created from a valid Table for this object";
+ code_ += " // Which contains a valid struct in this slot";
code_ +=
- " unsafe {"
+ " unsafe {"
" &*(self.0[{{FIELD_OFFSET}}..].as_ptr() as *const"
" {{FIELD_TYPE}}) }";
} else if (IsArray(field.value.type)) {
@@ -2894,33 +2914,33 @@
code_ +=
"pub fn {{FIELD}}(&'a self) -> "
"::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_ += " // 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, "
+ " unsafe { ::flatbuffers::Array::follow(&self.0, "
"{{FIELD_OFFSET}}) "
"}";
} else {
code_ += "pub fn {{FIELD}}(&self) -> {{FIELD_TYPE}} {";
code_ +=
- " let mut mem = ::core::mem::MaybeUninit::"
+ " 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_ += " ::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_ += " // Safety:";
+ code_ += " // Created from a valid Table for this object";
+ code_ += " // Which contains a valid value in this slot";
+ 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 "
+ " ::core::mem::size_of::<<{{FIELD_TYPE}} as "
"::flatbuffers::EndianScalar>::Scalar>(),";
- code_ += " );";
- code_ += " mem.assume_init()";
- code_ += " })";
+ code_ += " );";
+ code_ += " mem.assume_init()";
+ code_ += " })";
}
code_ += "}\n";
// Setter.
@@ -2929,7 +2949,7 @@
code_ += "#[allow(clippy::identity_op)]"; // If FIELD_OFFSET=0.
code_ += "pub fn set_{{FIELD}}(&mut self, x: &{{FIELD_TYPE}}) {";
code_ +=
- " self.0[{{FIELD_OFFSET}}..{{FIELD_OFFSET}} + {{FIELD_SIZE}}]"
+ " self.0[{{FIELD_OFFSET}}..{{FIELD_OFFSET}} + {{FIELD_SIZE}}]"
".copy_from_slice(&x.0)";
} else if (IsArray(field.value.type)) {
if (GetFullType(field.value.type) == ftArrayOfBuiltin) {
@@ -2941,43 +2961,43 @@
code_ +=
"pub fn set_{{FIELD}}(&mut self, items: &{{FIELD_TYPE}}) "
"{";
- code_ += " // Safety:";
- code_ += " // Created from a valid Table for this object";
- code_ += " // Which contains a valid array in this slot";
+ code_ += " // Safety:";
+ 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",
NumToString(InlineSize(field.value.type)));
code_ += "pub fn set_{{FIELD}}(&mut self, x: &{{FIELD_TYPE}}) {";
- code_ += " // Safety:";
- 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_ += " x.as_ptr() as *const u8,";
- code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),";
- code_ += " {{FIELD_SIZE}},";
- code_ += " );";
- code_ += " }";
+ code_ += " // Safety:";
+ 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_ += " x.as_ptr() as *const u8,";
+ code_ += " self.0.as_mut_ptr().add({{FIELD_OFFSET}}),";
+ code_ += " {{FIELD_SIZE}},";
+ code_ += " );";
+ code_ += " }";
}
} else {
code_ += "pub fn set_{{FIELD}}(&mut self, x: {{FIELD_TYPE}}) {";
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_ += " &x_le as *const _ as *const u8,";
- code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),";
+ " 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_ += " &x_le as *const _ as *const u8,";
+ code_ += " self.0[{{FIELD_OFFSET}}..].as_mut_ptr(),";
code_ +=
- " ::core::mem::size_of::<<{{FIELD_TYPE}} as "
+ " ::core::mem::size_of::<<{{FIELD_TYPE}} as "
"::flatbuffers::EndianScalar>::Scalar>(),";
- code_ += " );";
- code_ += " }";
+ code_ += " );";
+ code_ += " }";
}
code_ += "}\n";
@@ -2990,8 +3010,8 @@
// Generate Object API unpack method.
if (parser_.opts.generate_object_based_api) {
code_.SetValue("STRUCT_OTY", namer_.ObjectType(struct_def));
- code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
- code_ += " {{STRUCT_OTY}} {";
+ code_ += " pub fn unpack(&self) -> {{STRUCT_OTY}} {";
+ code_ += " {{STRUCT_OTY}} {";
ForAllStructFields(struct_def, [&](const FieldDef& field) {
if (IsArray(field.value.type)) {
if (GetFullType(field.value.type) == ftArrayOfStruct) {
@@ -3000,15 +3020,15 @@
"self.{{FIELD}}(); ::flatbuffers::array_init(|i| "
"{{FIELD}}.get(i).unpack()) },";
} else {
- code_ += " {{FIELD}}: self.{{FIELD}}().into(),";
+ code_ += " {{FIELD}}: self.{{FIELD}}().into(),";
}
} else {
std::string unpack = IsStruct(field.value.type) ? ".unpack()" : "";
- code_ += " {{FIELD}}: self.{{FIELD}}()" + unpack + ",";
+ code_ += " {{FIELD}}: self.{{FIELD}}()" + unpack + ",";
}
});
+ code_ += " }";
code_ += " }";
- code_ += " }";
}
code_ += "}"; // End impl Struct methods.
@@ -3029,25 +3049,25 @@
// The `pack` method that turns the native struct into its Flatbuffers
// counterpart.
code_ += "impl {{STRUCT_OTY}} {";
- code_ += " pub fn pack(&self) -> {{STRUCT_TY}} {";
- code_ += " {{STRUCT_TY}}::new(";
+ code_ += " pub fn pack(&self) -> {{STRUCT_TY}} {";
+ code_ += " {{STRUCT_TY}}::new(";
ForAllStructFields(struct_def, [&](const FieldDef& field) {
if (IsStruct(field.value.type)) {
- code_ += " &self.{{FIELD}}.pack(),";
+ code_ += " &self.{{FIELD}}.pack(),";
} 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}},";
+ code_ += " &self.{{FIELD}},";
}
} else {
- code_ += " self.{{FIELD}},";
+ code_ += " self.{{FIELD}},";
}
});
- code_ += " )";
- code_ += " }";
+ code_ += " )";
+ code_ += " }";
code_ += "}";
}
}
diff --git a/tests/arrays_test/mod.rs b/tests/arrays_test/mod.rs
index 5a649d5..129b395 100644
--- a/tests/arrays_test/mod.rs
+++ b/tests/arrays_test/mod.rs
@@ -1,16 +1,16 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod example {
use super::*;
- mod test_enum_generated;
- pub use self::test_enum_generated::*;
- mod nested_struct_generated;
- pub use self::nested_struct_generated::*;
- mod array_struct_generated;
- pub use self::array_struct_generated::*;
- mod array_table_generated;
- pub use self::array_table_generated::*;
- } // example
+ pub mod example {
+ use super::*;
+ mod test_enum_generated;
+ pub use self::test_enum_generated::*;
+ mod nested_struct_generated;
+ pub use self::nested_struct_generated::*;
+ mod array_struct_generated;
+ pub use self::array_struct_generated::*;
+ mod array_table_generated;
+ pub use self::array_table_generated::*;
+ } // example
} // my_game
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 2f446d4..031d872 100644
--- a/tests/arrays_test/my_game/example/array_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/array_struct_generated.rs
@@ -8,43 +8,43 @@
#[derive(Clone, Copy, PartialEq)]
pub struct ArrayStruct(pub [u8; 160]);
-impl Default for ArrayStruct {
- fn default() -> Self {
- Self([0; 160])
- }
+impl Default for ArrayStruct {
+ fn default() -> Self {
+ Self([0; 160])
+ }
}
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())
- .field("c", &self.c())
- .field("d", &self.d())
- .field("e", &self.e())
- .field("f", &self.f())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("ArrayStruct")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .field("c", &self.c())
+ .field("d", &self.d())
+ .field("e", &self.e())
+ .field("f", &self.f())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
- type Inner = &'a ArrayStruct;
+ type Inner = &'a ArrayStruct;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a ArrayStruct>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a ArrayStruct>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a ArrayStruct {
- type Inner = &'a ArrayStruct;
+ type Inner = &'a ArrayStruct;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<ArrayStruct>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for ArrayStruct {
@@ -63,207 +63,207 @@
}
impl<'a> ::flatbuffers::Verifiable for ArrayStruct {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> ArrayStruct {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: f32,
- b: &[i32; 15],
- c: i8,
- d: &[NestedStruct; 2],
- e: i32,
- f: &[i64; 2],
- ) -> Self {
- let mut s = Self([0; 160]);
- s.set_a(a);
- s.set_b(b);
- s.set_c(c);
- s.set_d(d);
- s.set_e(e);
- s.set_f(f);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.ArrayStruct"
- }
-
- pub fn a(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[0..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: f32,
+ b: &[i32; 15],
+ c: i8,
+ d: &[NestedStruct; 2],
+ e: i32,
+ f: &[i64; 2],
+ ) -> Self {
+ let mut s = Self([0; 160]);
+ s.set_a(a);
+ s.set_b(b);
+ s.set_c(c);
+ s.set_d(d);
+ s.set_e(e);
+ s.set_f(f);
+ s
}
- }
- 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
- 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) };
- }
-
- pub fn c(&self) -> i8 {
- let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_c(&mut self, x: i8) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[64..].as_mut_ptr(),
- ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.ArrayStruct"
}
- }
- 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
- use ::flatbuffers::Follow;
- unsafe { ::flatbuffers::Array::follow(&self.0, 72) }
- }
-
- pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid array in this slot
- unsafe {
- ::core::ptr::copy(
- x.as_ptr() as *const u8,
- self.0.as_mut_ptr().add(72),
- 64,
- );
+ pub fn a(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn e(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_e(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[136..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn set_a(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
- 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
- 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) };
- }
-
- pub fn unpack(&self) -> ArrayStructT {
- ArrayStructT {
- a: self.a(),
- b: self.b().into(),
- c: self.c(),
- d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) },
- e: self.e(),
- f: self.f().into(),
+ 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
+ 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) };
+ }
+
+ pub fn c(&self) -> i8 {
+ let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_c(&mut self, x: i8) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[64..].as_mut_ptr(),
+ ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ 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
+ use ::flatbuffers::Follow;
+ unsafe { ::flatbuffers::Array::follow(&self.0, 72) }
+ }
+
+ pub fn set_d(&mut self, x: &[NestedStruct; 2]) {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid array in this slot
+ unsafe {
+ ::core::ptr::copy(
+ x.as_ptr() as *const u8,
+ self.0.as_mut_ptr().add(72),
+ 64,
+ );
+ }
+ }
+
+ pub fn e(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_e(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[136..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ 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
+ 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) };
+ }
+
+ pub fn unpack(&self) -> ArrayStructT {
+ ArrayStructT {
+ a: self.a(),
+ b: self.b().into(),
+ c: self.c(),
+ d: { let d = self.d(); ::flatbuffers::array_init(|i| d.get(i).unpack()) },
+ e: self.e(),
+ f: self.f().into(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct ArrayStructT {
- pub a: f32,
- pub b: [i32; 15],
- pub c: i8,
- pub d: [NestedStructT; 2],
- pub e: i32,
- pub f: [i64; 2],
+ pub a: f32,
+ pub b: [i32; 15],
+ pub c: i8,
+ pub d: [NestedStructT; 2],
+ pub e: i32,
+ pub f: [i64; 2],
}
impl ArrayStructT {
- pub fn pack(&self) -> ArrayStruct {
- ArrayStruct::new(
- self.a,
- &self.b,
- self.c,
- &::flatbuffers::array_init(|i| self.d[i].pack()),
- self.e,
- &self.f,
- )
- }
+ pub fn pack(&self) -> ArrayStruct {
+ ArrayStruct::new(
+ self.a,
+ &self.b,
+ self.c,
+ &::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 449f187..525a755 100644
--- a/tests/arrays_test/my_game/example/array_table_generated.rs
+++ b/tests/arrays_test/my_game/example/array_table_generated.rs
@@ -7,68 +7,68 @@
#[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> {
- type Inner = ArrayTable<'a>;
+ type Inner = ArrayTable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args ArrayTableArgs<'args>
- ) -> ::flatbuffers::WIPOffset<ArrayTable<'bldr>> {
- let mut builder = ArrayTableBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> ArrayTableT {
- let a = self.a().map(|x| {
- x.unpack()
- });
- ArrayTableT {
- a,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.ArrayTable"
}
- }
- #[inline]
- pub fn a(&self) -> Option<&'a ArrayStruct> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<ArrayStruct>(ArrayTable::VT_A, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args ArrayTableArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<ArrayTable<'bldr>> {
+ let mut builder = ArrayTableBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> ArrayTableT {
+ let a = self.a().map(|x| {
+ x.unpack()
+ });
+ ArrayTableT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<&'a ArrayStruct> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<ArrayStruct>(ArrayTable::VT_A, None)}
+ }
}
impl ::flatbuffers::Verifiable for ArrayTable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<ArrayStruct>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<ArrayStruct>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct ArrayTableArgs<'a> {
@@ -76,74 +76,74 @@
}
impl<'a> Default for ArrayTableArgs<'a> {
- #[inline]
- fn default() -> Self {
- ArrayTableArgs {
- a: None,
+ #[inline]
+ fn default() -> Self {
+ ArrayTableArgs {
+ a: None,
+ }
}
- }
}
pub struct ArrayTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- ArrayTableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_a(&mut self, a: &ArrayStruct) {
+ self.fbb_.push_slot_always::<&ArrayStruct>(ArrayTable::VT_A, a);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ArrayTableBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ ArrayTableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ArrayTableT {
- pub a: Option<ArrayStructT>,
+ pub a: Option<ArrayStructT>,
}
impl Default for ArrayTableT {
- fn default() -> Self {
- Self {
- a: None,
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
}
- }
}
impl ArrayTableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<ArrayTable<'b>> {
- let a_tmp = self.a.as_ref().map(|x| x.pack());
- let a = a_tmp.as_ref();
- ArrayTable::create(_fbb, &ArrayTableArgs{
- a,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<ArrayTable<'b>> {
+ let a_tmp = self.a.as_ref().map(|x| x.pack());
+ let a = a_tmp.as_ref();
+ ArrayTable::create(_fbb, &ArrayTableArgs{
+ a,
+ })
+ }
}
/// Verifies that a buffer of bytes contains a `ArrayTable`
@@ -154,7 +154,7 @@
/// `root_as_array_table_unchecked`.
#[inline]
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<ArrayTable>(buf)
+ ::flatbuffers::root::<ArrayTable>(buf)
}
/// Verifies that a buffer of bytes contains a size prefixed
@@ -165,7 +165,7 @@
/// `size_prefixed_root_as_array_table_unchecked`.
#[inline]
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
+ ::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
}
/// Verifies, with the given options, that a buffer of bytes
@@ -176,10 +176,10 @@
/// `root_as_array_table_unchecked`.
#[inline]
pub fn root_as_array_table_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
+ ::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
}
/// Verifies, with the given verifier options, that a buffer of
@@ -190,10 +190,10 @@
/// `root_as_array_table_unchecked`.
#[inline]
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
+ ::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
}
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
@@ -201,7 +201,7 @@
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
#[inline]
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
- unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
+ unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
}
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
@@ -209,19 +209,19 @@
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
#[inline]
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(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";
@@ -229,11 +229,15 @@
#[inline]
pub fn finish_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<ArrayTable<'a>>) {
- fbb.finish(root, Some(ARRAY_TABLE_IDENTIFIER));
+ root: ::flatbuffers::WIPOffset<ArrayTable<'a>>
+) {
+ 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<ArrayTable<'a>>) {
- fbb.finish_size_prefixed(root, Some(ARRAY_TABLE_IDENTIFIER));
+pub fn finish_size_prefixed_array_table_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<ArrayTable<'a>>
+) {
+ 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 40134ea..6515914 100644
--- a/tests/arrays_test/my_game/example/nested_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/nested_struct_generated.rs
@@ -8,41 +8,41 @@
#[derive(Clone, Copy, PartialEq)]
pub struct NestedStruct(pub [u8; 32]);
-impl Default for NestedStruct {
- fn default() -> Self {
- Self([0; 32])
- }
+impl Default for NestedStruct {
+ fn default() -> Self {
+ Self([0; 32])
+ }
}
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())
- .field("c", &self.c())
- .field("d", &self.d())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("NestedStruct")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .field("c", &self.c())
+ .field("d", &self.d())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
- type Inner = &'a NestedStruct;
+ type Inner = &'a NestedStruct;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a NestedStruct>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a NestedStruct>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a NestedStruct {
- type Inner = &'a NestedStruct;
+ type Inner = &'a NestedStruct;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<NestedStruct>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for NestedStruct {
@@ -61,139 +61,139 @@
}
impl<'a> ::flatbuffers::Verifiable for NestedStruct {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> NestedStruct {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: &[i32; 2],
- b: TestEnum,
- c: &[TestEnum; 2],
- d: &[i64; 2],
- ) -> Self {
- let mut s = Self([0; 32]);
- s.set_a(a);
- s.set_b(b);
- s.set_c(c);
- s.set_d(d);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.NestedStruct"
- }
-
- 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
- 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) };
- }
-
- pub fn b(&self) -> TestEnum {
- let mut mem = ::core::mem::MaybeUninit::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_b(&mut self, x: TestEnum) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[8..].as_mut_ptr(),
- ::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &[i32; 2],
+ b: TestEnum,
+ c: &[TestEnum; 2],
+ d: &[i64; 2],
+ ) -> Self {
+ let mut s = Self([0; 32]);
+ s.set_a(a);
+ s.set_b(b);
+ s.set_c(c);
+ s.set_d(d);
+ s
}
- }
- 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
- use ::flatbuffers::Follow;
- unsafe { ::flatbuffers::Array::follow(&self.0, 9) }
- }
-
- pub fn set_c(&mut self, x: &[TestEnum; 2]) {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid array in this slot
- unsafe {
- ::core::ptr::copy(
- x.as_ptr() as *const u8,
- self.0.as_mut_ptr().add(9),
- 2,
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.NestedStruct"
}
- }
- 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
- 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) };
- }
-
- pub fn unpack(&self) -> NestedStructT {
- NestedStructT {
- a: self.a().into(),
- b: self.b(),
- c: self.c().into(),
- d: self.d().into(),
+ 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
+ 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) };
+ }
+
+ pub fn b(&self) -> TestEnum {
+ let mut mem = ::core::mem::MaybeUninit::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_b(&mut self, x: TestEnum) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[8..].as_mut_ptr(),
+ ::core::mem::size_of::<<TestEnum as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ 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
+ use ::flatbuffers::Follow;
+ unsafe { ::flatbuffers::Array::follow(&self.0, 9) }
+ }
+
+ pub fn set_c(&mut self, x: &[TestEnum; 2]) {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid array in this slot
+ unsafe {
+ ::core::ptr::copy(
+ x.as_ptr() as *const u8,
+ self.0.as_mut_ptr().add(9),
+ 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
+ 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) };
+ }
+
+ pub fn unpack(&self) -> NestedStructT {
+ NestedStructT {
+ a: self.a().into(),
+ b: self.b(),
+ c: self.c().into(),
+ d: self.d().into(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct NestedStructT {
- pub a: [i32; 2],
- pub b: TestEnum,
- pub c: [TestEnum; 2],
- pub d: [i64; 2],
+ pub a: [i32; 2],
+ pub b: TestEnum,
+ pub c: [TestEnum; 2],
+ pub d: [i64; 2],
}
impl NestedStructT {
- pub fn pack(&self) -> NestedStruct {
- NestedStruct::new(
- &self.a,
- self.b,
- &self.c,
- &self.d,
- )
- }
+ pub fn pack(&self) -> NestedStruct {
+ NestedStruct::new(
+ &self.a,
+ self.b,
+ &self.c,
+ &self.d,
+ )
+ }
}
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 de750a1..ff0f426 100644
--- a/tests/arrays_test/my_game/example/test_enum_generated.rs
+++ b/tests/arrays_test/my_game/example/test_enum_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_TEST_ENUM: [TestEnum; 3] = [
- TestEnum::A,
- TestEnum::B,
- TestEnum::C,
+ TestEnum::A,
+ TestEnum::B,
+ TestEnum::C,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl TestEnum {
- pub const A: Self = Self(0);
- pub const B: Self = Self(1);
- pub const C: Self = Self(2);
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
+ pub const C: Self = Self(2);
- pub const ENUM_MIN: i8 = 0;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::A,
- Self::B,
- Self::C,
- ];
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ Self::C,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::A => Some("A"),
- Self::B => Some("B"),
- Self::C => Some("C"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::A => Some("A"),
+ Self::B => Some("B"),
+ Self::C => Some("C"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for TestEnum {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for TestEnum {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for TestEnum {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for TestEnum {}
diff --git a/tests/include_test1/mod.rs b/tests/include_test1/mod.rs
index ca4894d..a69094e 100644
--- a/tests/include_test1/mod.rs
+++ b/tests/include_test1/mod.rs
@@ -1,16 +1,16 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod other_name_space {
use super::*;
- mod from_include_generated;
- pub use self::from_include_generated::*;
- mod unused_generated;
- pub use self::unused_generated::*;
- mod table_b_generated;
- pub use self::table_b_generated::*;
- } // other_name_space
+ pub mod other_name_space {
+ use super::*;
+ mod from_include_generated;
+ pub use self::from_include_generated::*;
+ mod unused_generated;
+ pub use self::unused_generated::*;
+ mod table_b_generated;
+ pub use self::table_b_generated::*;
+ } // other_name_space
} // my_game
mod table_a_generated;
pub use self::table_a_generated::*;
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 4e03e2d..ada2947 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
@@ -12,7 +12,7 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
+ FromInclude::IncludeVal,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -21,41 +21,41 @@
#[allow(non_upper_case_globals)]
impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ pub const IncludeVal: Self = Self(0);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for FromInclude {
@@ -68,28 +68,28 @@
}
impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
+ type Scalar = i64;
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
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 5e969c2..5434e44 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
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableB<'a>;
+ type Inner = TableB<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.TableB"
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableBArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
}
- }
}
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
}
impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
}
- }
}
impl TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
}
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 e8639ac..12f7fa7 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
@@ -8,38 +8,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Unused(pub [u8; 4]);
-impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Unused {
@@ -58,73 +58,73 @@
}
impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
}
- }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct UnusedT {
- pub a: i32,
+ pub a: i32,
}
impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
}
diff --git a/tests/include_test1/table_a_generated.rs b/tests/include_test1/table_a_generated.rs
index 2558b84..467c514 100644
--- a/tests/include_test1/table_a_generated.rs
+++ b/tests/include_test1/table_a_generated.rs
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
diff --git a/tests/include_test1_generated.rs b/tests/include_test1_generated.rs
index bb00aa8..708e862 100644
--- a/tests/include_test1_generated.rs
+++ b/tests/include_test1_generated.rs
@@ -6,68 +6,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -75,444 +75,444 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
#[allow(unused_imports, dead_code)]
pub mod my_game {
- extern crate alloc;
-
- #[allow(unused_imports, dead_code)]
- pub mod other_name_space {
extern crate alloc;
- #[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;
+ #[allow(unused_imports, dead_code)]
+ pub mod other_name_space {
+ extern crate alloc;
- #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
- pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
+ #[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;
- #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
- #[allow(non_camel_case_types)]
- pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
- ];
+ #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+ pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
- #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
- #[repr(transparent)]
- pub struct FromInclude(pub i64);
+ #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+ #[allow(non_camel_case_types)]
+ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
+ FromInclude::IncludeVal,
+ ];
- #[allow(non_upper_case_globals)]
- impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+ #[repr(transparent)]
+ pub struct FromInclude(pub i64);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ #[allow(non_upper_case_globals)]
+ impl FromInclude {
+ pub const IncludeVal: Self = Self(0);
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
- }
- }
- }
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- 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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
- }
- }
- }
-
- impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
- }
-
- impl ::flatbuffers::Push for FromInclude {
- type Output = FromInclude;
-
- #[inline]
- unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
- }
- }
-
- impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
-
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
-
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
- }
-
- impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
- }
-
- impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
-
- // struct Unused, aligned to 4
- #[repr(transparent)]
- #[derive(Clone, Copy, PartialEq)]
- pub struct Unused(pub [u8; 4]);
-
- impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
- }
-
- 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 {
- type Inner = &'a Unused;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
- }
-
- impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
- }
-
- impl<'b> ::flatbuffers::Push for Unused {
- type Output = Unused;
-
- #[inline]
- unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
- dst.copy_from_slice(src);
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
+ }
}
- #[inline]
- fn alignment() -> ::flatbuffers::PushAlignment {
- ::flatbuffers::PushAlignment::new(4)
+ 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 {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
}
- }
- impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
- }
+ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
+ type Inner = Self;
- impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ impl ::flatbuffers::Push for FromInclude {
+ type Output = FromInclude;
+
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
+ }
}
- }
- }
- #[derive(Debug, Clone, PartialEq, Default)]
- pub struct UnusedT {
- pub a: i32,
- }
+ impl ::flatbuffers::EndianScalar for FromInclude {
+ type Scalar = i64;
- impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- pub enum TableBOffset {}
-
- #[derive(Copy, Clone, PartialEq)]
- pub struct TableB<'a> {
- pub _tab: ::flatbuffers::Table<'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: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
- }
-
- impl<'a> TableB<'a> {
- 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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
- }
-
- impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
- }
-
- pub struct TableBArgs<'a> {
- pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
- }
-
- impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ impl<'a> ::flatbuffers::Verifiable for FromInclude {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
- }
- }
- pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
- }
+ impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
- impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
+ // struct Unused, aligned to 4
+ #[repr(transparent)]
+ #[derive(Clone, Copy, PartialEq)]
+ pub struct Unused(pub [u8; 4]);
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
- }
-
- 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()
- }
- }
-
- #[non_exhaustive]
- #[derive(Debug, Clone, PartialEq)]
- pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
- }
-
- impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ 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 TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
- }
- } // pub mod OtherNameSpace
+ 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 {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
+ }
+
+ impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
+ type Inner = &'a Unused;
+
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
+ }
+
+ impl<'b> ::flatbuffers::Push for Unused {
+ type Output = Unused;
+
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
+ dst.copy_from_slice(src);
+ }
+
+ #[inline]
+ fn alignment() -> ::flatbuffers::PushAlignment {
+ ::flatbuffers::PushAlignment::new(4)
+ }
+ }
+
+ impl<'a> ::flatbuffers::Verifiable for Unused {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
+ }
+
+ impl<'a> Unused {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
+ }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
+ }
+
+ #[derive(Debug, Clone, PartialEq, Default)]
+ pub struct UnusedT {
+ pub a: i32,
+ }
+
+ impl UnusedT {
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
+ }
+
+ pub enum TableBOffset {}
+
+ #[derive(Copy, Clone, PartialEq)]
+ pub struct TableB<'a> {
+ pub _tab: ::flatbuffers::Table<'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: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
+ }
+
+ impl<'a> TableB<'a> {
+ 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 {
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
+ }
+
+ impl ::flatbuffers::Verifiable for TableB<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
+ }
+
+ pub struct TableBArgs<'a> {
+ pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
+ }
+
+ impl<'a> Default for TableBArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
+ }
+ }
+
+ 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> {
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
+ }
+
+ 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()
+ }
+ }
+
+ #[non_exhaustive]
+ #[derive(Debug, Clone, PartialEq)]
+ pub struct TableBT {
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ }
+
+ impl Default for TableBT {
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
+ }
+ }
+
+ impl TableBT {
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
+ }
+ } // pub mod OtherNameSpace
} // pub mod MyGame
diff --git a/tests/include_test2/mod.rs b/tests/include_test2/mod.rs
index ca4894d..a69094e 100644
--- a/tests/include_test2/mod.rs
+++ b/tests/include_test2/mod.rs
@@ -1,16 +1,16 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod other_name_space {
use super::*;
- mod from_include_generated;
- pub use self::from_include_generated::*;
- mod unused_generated;
- pub use self::unused_generated::*;
- mod table_b_generated;
- pub use self::table_b_generated::*;
- } // other_name_space
+ pub mod other_name_space {
+ use super::*;
+ mod from_include_generated;
+ pub use self::from_include_generated::*;
+ mod unused_generated;
+ pub use self::unused_generated::*;
+ mod table_b_generated;
+ pub use self::table_b_generated::*;
+ } // other_name_space
} // my_game
mod table_a_generated;
pub use self::table_a_generated::*;
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 4e03e2d..ada2947 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
@@ -12,7 +12,7 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
+ FromInclude::IncludeVal,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -21,41 +21,41 @@
#[allow(non_upper_case_globals)]
impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ pub const IncludeVal: Self = Self(0);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for FromInclude {
@@ -68,28 +68,28 @@
}
impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
+ type Scalar = i64;
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
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 5e969c2..5434e44 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
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableB<'a>;
+ type Inner = TableB<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.TableB"
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableBArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
}
- }
}
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
}
impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
}
- }
}
impl TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
}
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 e8639ac..12f7fa7 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
@@ -8,38 +8,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Unused(pub [u8; 4]);
-impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Unused {
@@ -58,73 +58,73 @@
}
impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
}
- }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct UnusedT {
- pub a: i32,
+ pub a: i32,
}
impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
}
diff --git a/tests/include_test2/table_a_generated.rs b/tests/include_test2/table_a_generated.rs
index 2558b84..467c514 100644
--- a/tests/include_test2/table_a_generated.rs
+++ b/tests/include_test2/table_a_generated.rs
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
diff --git a/tests/include_test2_generated.rs b/tests/include_test2_generated.rs
index bb00aa8..708e862 100644
--- a/tests/include_test2_generated.rs
+++ b/tests/include_test2_generated.rs
@@ -6,68 +6,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -75,444 +75,444 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
#[allow(unused_imports, dead_code)]
pub mod my_game {
- extern crate alloc;
-
- #[allow(unused_imports, dead_code)]
- pub mod other_name_space {
extern crate alloc;
- #[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;
+ #[allow(unused_imports, dead_code)]
+ pub mod other_name_space {
+ extern crate alloc;
- #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
- pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
+ #[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;
- #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
- #[allow(non_camel_case_types)]
- pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
- ];
+ #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+ pub const ENUM_MAX_FROM_INCLUDE: i64 = 0;
- #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
- #[repr(transparent)]
- pub struct FromInclude(pub i64);
+ #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+ #[allow(non_camel_case_types)]
+ pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
+ FromInclude::IncludeVal,
+ ];
- #[allow(non_upper_case_globals)]
- impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+ #[repr(transparent)]
+ pub struct FromInclude(pub i64);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ #[allow(non_upper_case_globals)]
+ impl FromInclude {
+ pub const IncludeVal: Self = Self(0);
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
- }
- }
- }
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- 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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
- }
- }
- }
-
- impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
- }
-
- impl ::flatbuffers::Push for FromInclude {
- type Output = FromInclude;
-
- #[inline]
- unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
- }
- }
-
- impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
-
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
-
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
- }
-
- impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
- }
-
- impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
-
- // struct Unused, aligned to 4
- #[repr(transparent)]
- #[derive(Clone, Copy, PartialEq)]
- pub struct Unused(pub [u8; 4]);
-
- impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
- }
-
- 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 {
- type Inner = &'a Unused;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
- }
-
- impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
-
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
- }
-
- impl<'b> ::flatbuffers::Push for Unused {
- type Output = Unused;
-
- #[inline]
- unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
- let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
- dst.copy_from_slice(src);
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
+ }
}
- #[inline]
- fn alignment() -> ::flatbuffers::PushAlignment {
- ::flatbuffers::PushAlignment::new(4)
+ 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 {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
}
- }
- impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
- }
+ impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
+ type Inner = Self;
- impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ impl ::flatbuffers::Push for FromInclude {
+ type Output = FromInclude;
+
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
+ }
}
- }
- }
- #[derive(Debug, Clone, PartialEq, Default)]
- pub struct UnusedT {
- pub a: i32,
- }
+ impl ::flatbuffers::EndianScalar for FromInclude {
+ type Scalar = i64;
- impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- pub enum TableBOffset {}
-
- #[derive(Copy, Clone, PartialEq)]
- pub struct TableB<'a> {
- pub _tab: ::flatbuffers::Table<'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: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
- }
-
- impl<'a> TableB<'a> {
- 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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
- }
-
- impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
- }
-
- pub struct TableBArgs<'a> {
- pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
- }
-
- impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ impl<'a> ::flatbuffers::Verifiable for FromInclude {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
- }
- }
- pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
- }
+ impl ::flatbuffers::SimpleToVerifyInSlice for FromInclude {}
- impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
+ // struct Unused, aligned to 4
+ #[repr(transparent)]
+ #[derive(Clone, Copy, PartialEq)]
+ pub struct Unused(pub [u8; 4]);
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
- }
-
- 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()
- }
- }
-
- #[non_exhaustive]
- #[derive(Debug, Clone, PartialEq)]
- pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
- }
-
- impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ 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 TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
- }
- } // pub mod OtherNameSpace
+ 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 {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
+ }
+
+ impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
+ type Inner = &'a Unused;
+
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
+ }
+
+ impl<'b> ::flatbuffers::Push for Unused {
+ type Output = Unused;
+
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ let src = unsafe { ::core::slice::from_raw_parts(self as *const Unused as *const u8, <Self as ::flatbuffers::Push>::size()) };
+ dst.copy_from_slice(src);
+ }
+
+ #[inline]
+ fn alignment() -> ::flatbuffers::PushAlignment {
+ ::flatbuffers::PushAlignment::new(4)
+ }
+ }
+
+ impl<'a> ::flatbuffers::Verifiable for Unused {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
+ }
+
+ impl<'a> Unused {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
+ }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
+ }
+
+ #[derive(Debug, Clone, PartialEq, Default)]
+ pub struct UnusedT {
+ pub a: i32,
+ }
+
+ impl UnusedT {
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
+ }
+
+ pub enum TableBOffset {}
+
+ #[derive(Copy, Clone, PartialEq)]
+ pub struct TableB<'a> {
+ pub _tab: ::flatbuffers::Table<'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: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
+ }
+
+ impl<'a> TableB<'a> {
+ 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 {
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
+ }
+
+ impl ::flatbuffers::Verifiable for TableB<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
+ }
+
+ pub struct TableBArgs<'a> {
+ pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
+ }
+
+ impl<'a> Default for TableBArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
+ }
+ }
+
+ 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> {
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
+ }
+
+ 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()
+ }
+ }
+
+ #[non_exhaustive]
+ #[derive(Debug, Clone, PartialEq)]
+ pub struct TableBT {
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ }
+
+ impl Default for TableBT {
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
+ }
+ }
+
+ impl TableBT {
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
+ }
+ } // pub mod OtherNameSpace
} // pub mod MyGame
diff --git a/tests/keyword_test/keyword_test/abc_generated.rs b/tests/keyword_test/keyword_test/abc_generated.rs
index a8da058..cac5832 100644
--- a/tests/keyword_test/keyword_test/abc_generated.rs
+++ b/tests/keyword_test/keyword_test/abc_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ABC: [ABC; 3] = [
- ABC::void,
- ABC::where_,
- ABC::stackalloc,
+ ABC::void,
+ ABC::where_,
+ ABC::stackalloc,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl ABC {
- pub const void: Self = Self(0);
- pub const where_: Self = Self(1);
- pub const stackalloc: Self = Self(2);
+ pub const void: Self = Self(0);
+ pub const where_: Self = Self(1);
+ pub const stackalloc: Self = Self(2);
- pub const ENUM_MIN: i32 = 0;
- pub const ENUM_MAX: i32 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::void,
- Self::where_,
- Self::stackalloc,
- ];
+ pub const ENUM_MIN: i32 = 0;
+ pub const ENUM_MAX: i32 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::void,
+ Self::where_,
+ Self::stackalloc,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::void => Some("void"),
- Self::where_ => Some("where_"),
- Self::stackalloc => Some("stackalloc"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::void => Some("void"),
+ Self::where_ => Some("where_"),
+ Self::stackalloc => Some("stackalloc"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for ABC {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for ABC {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for ABC {
- type Scalar = i32;
+ type Scalar = i32;
- #[inline]
- fn to_little_endian(self) -> i32 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i32 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i32) -> Self {
- let b = i32::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i32) -> Self {
+ let b = i32::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for ABC {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i32::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i32::run_verifier(v, pos)
+ }
}
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 f8c0505..c8dc456 100644
--- a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
@@ -7,105 +7,105 @@
#[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> {
- type Inner = KeywordsInTable<'a>;
+ type Inner = KeywordsInTable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args KeywordsInTableArgs
- ) -> ::flatbuffers::WIPOffset<KeywordsInTable<'bldr>> {
- let mut builder = KeywordsInTableBuilder::new(_fbb);
- builder.add_type_(args.type_);
- builder.add_private(args.private);
- builder.add_is(args.is);
- builder.add_default(args.default);
- builder.finish()
- }
-
- pub fn unpack(&self) -> KeywordsInTableT {
- let is = self.is();
- let private = self.private();
- let type_ = self.type_();
- let default = self.default();
- KeywordsInTableT {
- is,
- private,
- type_,
- default,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "KeywordTest.KeywordsInTable"
}
- }
- #[inline]
- pub fn is(&self) -> ABC {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<ABC>(KeywordsInTable::VT_IS, Some(ABC::void)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ KeywordsInTable { _tab: table }
+ }
- #[inline]
- pub fn private(&self) -> public {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<public>(KeywordsInTable::VT_PRIVATE, Some(public::NONE)).unwrap()}
- }
+ #[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>,
+ args: &'args KeywordsInTableArgs
+ ) -> ::flatbuffers::WIPOffset<KeywordsInTable<'bldr>> {
+ let mut builder = KeywordsInTableBuilder::new(_fbb);
+ builder.add_type_(args.type_);
+ builder.add_private(args.private);
+ builder.add_is(args.is);
+ builder.add_default(args.default);
+ builder.finish()
+ }
- #[inline]
- pub fn type_(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()}
- }
+ pub fn unpack(&self) -> KeywordsInTableT {
+ let is = self.is();
+ let private = self.private();
+ let type_ = self.type_();
+ let default = self.default();
+ KeywordsInTableT {
+ is,
+ private,
+ type_,
+ default,
+ }
+ }
- #[inline]
- pub fn default(&self) -> bool {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(KeywordsInTable::VT_DEFAULT, Some(false)).unwrap()}
- }
+ #[inline]
+ pub fn is(&self) -> ABC {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<ABC>(KeywordsInTable::VT_IS, Some(ABC::void)).unwrap()}
+ }
+
+ #[inline]
+ pub fn private(&self) -> public {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<public>(KeywordsInTable::VT_PRIVATE, Some(public::NONE)).unwrap()}
+ }
+
+ #[inline]
+ pub fn type_(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(KeywordsInTable::VT_TYPE_, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn default(&self) -> bool {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(KeywordsInTable::VT_DEFAULT, Some(false)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for KeywordsInTable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<ABC>("is", Self::VT_IS, false)?
- .visit_field::<public>("private", Self::VT_PRIVATE, false)?
- .visit_field::<i32>("type_", Self::VT_TYPE_, false)?
- .visit_field::<bool>("default", Self::VT_DEFAULT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<ABC>("is", Self::VT_IS, false)?
+ .visit_field::<public>("private", Self::VT_PRIVATE, false)?
+ .visit_field::<i32>("type_", Self::VT_TYPE_, false)?
+ .visit_field::<bool>("default", Self::VT_DEFAULT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct KeywordsInTableArgs {
@@ -116,104 +116,104 @@
}
impl<'a> Default for KeywordsInTableArgs {
- #[inline]
- fn default() -> Self {
- KeywordsInTableArgs {
- is: ABC::void,
- private: public::NONE,
- type_: 0,
- default: false,
+ #[inline]
+ fn default() -> Self {
+ KeywordsInTableArgs {
+ is: ABC::void,
+ private: public::NONE,
+ type_: 0,
+ default: false,
+ }
}
- }
}
pub struct KeywordsInTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<ABC>(KeywordsInTable::VT_IS, is, ABC::void);
- }
-
- #[inline]
- pub fn add_private(&mut self, private: public) {
- self.fbb_.push_slot::<public>(KeywordsInTable::VT_PRIVATE, private, public::NONE);
- }
-
- #[inline]
- pub fn add_type_(&mut self, type_: i32) {
- self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
- }
-
- #[inline]
- pub fn add_default(&mut self, default: bool) {
- self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- KeywordsInTableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_is(&mut self, is: ABC) {
+ self.fbb_.push_slot::<ABC>(KeywordsInTable::VT_IS, is, ABC::void);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_private(&mut self, private: public) {
+ self.fbb_.push_slot::<public>(KeywordsInTable::VT_PRIVATE, private, public::NONE);
+ }
+
+ #[inline]
+ pub fn add_type_(&mut self, type_: i32) {
+ self.fbb_.push_slot::<i32>(KeywordsInTable::VT_TYPE_, type_, 0);
+ }
+
+ #[inline]
+ pub fn add_default(&mut self, default: bool) {
+ self.fbb_.push_slot::<bool>(KeywordsInTable::VT_DEFAULT, default, false);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> KeywordsInTableBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ KeywordsInTableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("type_", &self.type_());
- ds.field("default", &self.default());
- ds.finish()
- }
+ 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());
+ ds.field("type_", &self.type_());
+ ds.field("default", &self.default());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct KeywordsInTableT {
- pub is: ABC,
- pub private: public,
- pub type_: i32,
- pub default: bool,
+ pub is: ABC,
+ pub private: public,
+ pub type_: i32,
+ pub default: bool,
}
impl Default for KeywordsInTableT {
- fn default() -> Self {
- Self {
- is: ABC::void,
- private: public::NONE,
- type_: 0,
- default: false,
+ fn default() -> Self {
+ Self {
+ is: ABC::void,
+ private: public::NONE,
+ type_: 0,
+ default: false,
+ }
}
- }
}
impl KeywordsInTableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<KeywordsInTable<'b>> {
- let is = self.is;
- let private = self.private;
- let type_ = self.type_;
- let default = self.default;
- KeywordsInTable::create(_fbb, &KeywordsInTableArgs{
- is,
- private,
- type_,
- default,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<KeywordsInTable<'b>> {
+ let is = self.is;
+ let private = self.private;
+ let type_ = self.type_;
+ let default = self.default;
+ KeywordsInTable::create(_fbb, &KeywordsInTableArgs{
+ is,
+ private,
+ type_,
+ default,
+ })
+ }
}
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 fe31141..5ac7f3e 100644
--- a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_KEYWORDS_IN_UNION: [KeywordsInUnion; 3] = [
- KeywordsInUnion::NONE,
- KeywordsInUnion::static_,
- KeywordsInUnion::internal,
+ KeywordsInUnion::NONE,
+ KeywordsInUnion::static_,
+ KeywordsInUnion::internal,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl KeywordsInUnion {
- pub const NONE: Self = Self(0);
- pub const static_: Self = Self(1);
- pub const internal: Self = Self(2);
+ pub const NONE: Self = Self(0);
+ pub const static_: Self = Self(1);
+ pub const internal: Self = Self(2);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::static_,
- Self::internal,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::static_,
+ Self::internal,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::static_ => Some("static_"),
- Self::internal => Some("internal"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::static_ => Some("static_"),
+ Self::internal => Some("internal"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for KeywordsInUnion {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for KeywordsInUnion {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for KeywordsInUnion {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {}
@@ -108,80 +108,80 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum KeywordsInUnionT {
- NONE,
- Static_(alloc::boxed::Box<KeywordsInTableT>),
- Internal(alloc::boxed::Box<KeywordsInTableT>),
+ NONE,
+ Static_(alloc::boxed::Box<KeywordsInTableT>),
+ Internal(alloc::boxed::Box<KeywordsInTableT>),
}
impl Default for KeywordsInUnionT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl KeywordsInUnionT {
- pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
- match self {
- Self::NONE => KeywordsInUnion::NONE,
- Self::Static_(_) => KeywordsInUnion::static_,
- Self::Internal(_) => KeywordsInUnion::internal,
+ pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
+ match self {
+ Self::NONE => KeywordsInUnion::NONE,
+ Self::Static_(_) => KeywordsInUnion::static_,
+ Self::Internal(_) => KeywordsInUnion::internal,
+ }
}
- }
- 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()),
- Self::Internal(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::Internal(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
- pub fn take_static_(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
- if let Self::Static_(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Static_(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned KeywordsInTableT, setting the union to NONE.
+ pub fn take_static_(&mut self) -> Option<alloc::boxed::Box<KeywordsInTableT>> {
+ if let Self::Static_(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Static_(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the KeywordsInTableT.
- pub fn as_static_(&self) -> Option<&KeywordsInTableT> {
- if let Self::Static_(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the KeywordsInTableT.
- pub fn as_static__mut(&mut self) -> Option<&mut KeywordsInTableT> {
- 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<alloc::boxed::Box<KeywordsInTableT>> {
- if let Self::Internal(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Internal(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the KeywordsInTableT.
+ pub fn as_static_(&self) -> Option<&KeywordsInTableT> {
+ if let Self::Static_(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the KeywordsInTableT.
- pub fn as_internal(&self) -> Option<&KeywordsInTableT> {
- if let Self::Internal(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return a mutable reference to the KeywordsInTableT.
+ pub fn as_static__mut(&mut self) -> Option<&mut KeywordsInTableT> {
+ if let Self::Static_(v) = self { Some(v.as_mut()) } else { None }
+ }
- /// If the union variant matches, return a mutable reference to the KeywordsInTableT.
- pub fn as_internal_mut(&mut self) -> Option<&mut KeywordsInTableT> {
- if let Self::Internal(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<alloc::boxed::Box<KeywordsInTableT>> {
+ if let Self::Internal(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Internal(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the KeywordsInTableT.
+ pub fn as_internal(&self) -> Option<&KeywordsInTableT> {
+ if let Self::Internal(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the KeywordsInTableT.
+ pub fn as_internal_mut(&mut self) -> Option<&mut KeywordsInTableT> {
+ if let Self::Internal(v) = self { Some(v.as_mut()) } else { None }
+ }
}
diff --git a/tests/keyword_test/keyword_test/public_generated.rs b/tests/keyword_test/keyword_test/public_generated.rs
index a4a449e..0799d68 100644
--- a/tests/keyword_test/keyword_test/public_generated.rs
+++ b/tests/keyword_test/keyword_test/public_generated.rs
@@ -12,7 +12,7 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_PUBLIC: [public; 1] = [
- public::NONE,
+ public::NONE,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -21,41 +21,41 @@
#[allow(non_upper_case_globals)]
impl public {
- pub const NONE: Self = Self(0);
+ pub const NONE: Self = Self(0);
- pub const ENUM_MIN: i32 = 0;
- pub const ENUM_MAX: i32 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- ];
+ pub const ENUM_MIN: i32 = 0;
+ pub const ENUM_MAX: i32 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for public {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for public {
@@ -68,28 +68,28 @@
}
impl ::flatbuffers::EndianScalar for public {
- type Scalar = i32;
+ type Scalar = i32;
- #[inline]
- fn to_little_endian(self) -> i32 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i32 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i32) -> Self {
- let b = i32::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i32) -> Self {
+ let b = i32::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for public {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i32::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i32::run_verifier(v, pos)
+ }
}
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 4436a0f..219ba40 100644
--- a/tests/keyword_test/keyword_test/table_2_generated.rs
+++ b/tests/keyword_test/keyword_test/table_2_generated.rs
@@ -7,125 +7,125 @@
#[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> {
- type Inner = Table2<'a>;
+ type Inner = Table2<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args Table2Args
- ) -> ::flatbuffers::WIPOffset<Table2<'bldr>> {
- let mut builder = Table2Builder::new(_fbb);
- if let Some(x) = args.type_ { builder.add_type_(x); }
- builder.add_type_type(args.type_type);
- builder.finish()
- }
-
- pub fn unpack(&self) -> Table2T {
- let type_ = match self.type_type() {
- KeywordsInUnion::NONE => KeywordsInUnionT::NONE,
- KeywordsInUnion::static_ => KeywordsInUnionT::Static_(alloc::boxed::Box::new(
- self.type__as_static_()
- .expect("Invalid union table, expected `KeywordsInUnion::static_`.")
- .unpack()
- )),
- KeywordsInUnion::internal => KeywordsInUnionT::Internal(alloc::boxed::Box::new(
- self.type__as_internal()
- .expect("Invalid union table, expected `KeywordsInUnion::internal`.")
- .unpack()
- )),
- _ => KeywordsInUnionT::NONE,
- };
- Table2T {
- type_,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "KeywordTest.Table2"
}
- }
- #[inline]
- pub fn type_type(&self) -> KeywordsInUnion {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn type__as_static_(&self) -> Option<KeywordsInTable<'a>> {
- if self.type_type() == KeywordsInUnion::static_ {
- self.type_().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { KeywordsInTable::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Table2 { _tab: table }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn type__as_internal(&self) -> Option<KeywordsInTable<'a>> {
- if self.type_type() == KeywordsInUnion::internal {
- self.type_().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { KeywordsInTable::init_from_table(t) }
- })
- } else {
- None
+ #[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>,
+ args: &'args Table2Args
+ ) -> ::flatbuffers::WIPOffset<Table2<'bldr>> {
+ let mut builder = Table2Builder::new(_fbb);
+ if let Some(x) = args.type_ { builder.add_type_(x); }
+ builder.add_type_type(args.type_type);
+ builder.finish()
}
- }
+
+ pub fn unpack(&self) -> Table2T {
+ let type_ = match self.type_type() {
+ KeywordsInUnion::NONE => KeywordsInUnionT::NONE,
+ KeywordsInUnion::static_ => KeywordsInUnionT::Static_(alloc::boxed::Box::new(
+ self.type__as_static_()
+ .expect("Invalid union table, expected `KeywordsInUnion::static_`.")
+ .unpack()
+ )),
+ KeywordsInUnion::internal => KeywordsInUnionT::Internal(alloc::boxed::Box::new(
+ self.type__as_internal()
+ .expect("Invalid union table, expected `KeywordsInUnion::internal`.")
+ .unpack()
+ )),
+ _ => KeywordsInUnionT::NONE,
+ };
+ Table2T {
+ type_,
+ }
+ }
+
+ #[inline]
+ pub fn type_type(&self) -> KeywordsInUnion {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, Some(KeywordsInUnion::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Table2::VT_TYPE_, None)}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn type__as_static_(&self) -> Option<KeywordsInTable<'a>> {
+ if self.type_type() == KeywordsInUnion::static_ {
+ self.type_().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { KeywordsInTable::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn type__as_internal(&self) -> Option<KeywordsInTable<'a>> {
+ if self.type_type() == KeywordsInUnion::internal {
+ self.type_().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { KeywordsInTable::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for Table2<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_union::<KeywordsInUnion, _>("type_type", Self::VT_TYPE_TYPE, "type_", Self::VT_TYPE_, false, |key, v, pos| {
- match key {
- KeywordsInUnion::static_ => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<KeywordsInTable>>("KeywordsInUnion::static_", pos),
- KeywordsInUnion::internal => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<KeywordsInTable>>("KeywordsInUnion::internal", pos),
- _ => Ok(()),
- }
- })?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_union::<KeywordsInUnion, _>("type_type", Self::VT_TYPE_TYPE, "type_", Self::VT_TYPE_, false, |key, v, pos| {
+ match key {
+ KeywordsInUnion::static_ => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<KeywordsInTable>>("KeywordsInUnion::static_", pos),
+ KeywordsInUnion::internal => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<KeywordsInTable>>("KeywordsInUnion::internal", pos),
+ _ => Ok(()),
+ }
+ })?
+ .finish();
+ Ok(())
+ }
}
pub struct Table2Args {
@@ -134,99 +134,99 @@
}
impl<'a> Default for Table2Args {
- #[inline]
- fn default() -> Self {
- Table2Args {
- type_type: KeywordsInUnion::NONE,
- type_: None,
+ #[inline]
+ fn default() -> Self {
+ Table2Args {
+ type_type: KeywordsInUnion::NONE,
+ type_: None,
+ }
}
- }
}
pub struct Table2Builder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE);
- }
-
- #[inline]
- 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> {
- let start = _fbb.start_table();
- Table2Builder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_type_type(&mut self, type_type: KeywordsInUnion) {
+ self.fbb_.push_slot::<KeywordsInUnion>(Table2::VT_TYPE_TYPE, type_type, KeywordsInUnion::NONE);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ 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> {
+ let start = _fbb.start_table();
+ Table2Builder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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() {
- KeywordsInUnion::static_ => {
- if let Some(x) = self.type__as_static_() {
- ds.field("type_", &x)
- } else {
- ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- KeywordsInUnion::internal => {
- if let Some(x) = self.type__as_internal() {
- ds.field("type_", &x)
- } else {
- ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("type_", &x)
- },
- };
- ds.finish()
- }
+ 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() {
+ KeywordsInUnion::static_ => {
+ if let Some(x) = self.type__as_static_() {
+ ds.field("type_", &x)
+ } else {
+ ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ KeywordsInUnion::internal => {
+ if let Some(x) = self.type__as_internal() {
+ ds.field("type_", &x)
+ } else {
+ ds.field("type_", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("type_", &x)
+ },
+ };
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct Table2T {
- pub type_: KeywordsInUnionT,
+ pub type_: KeywordsInUnionT,
}
impl Default for Table2T {
- fn default() -> Self {
- Self {
- type_: KeywordsInUnionT::NONE,
+ fn default() -> Self {
+ Self {
+ type_: KeywordsInUnionT::NONE,
+ }
}
- }
}
impl Table2T {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Table2<'b>> {
- let type_type = self.type_.keywords_in_union_type();
- let type_ = self.type_.pack(_fbb);
- Table2::create(_fbb, &Table2Args{
- type_type,
- type_,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Table2<'b>> {
+ let type_type = self.type_.keywords_in_union_type();
+ let type_ = self.type_.pack(_fbb);
+ Table2::create(_fbb, &Table2Args{
+ type_type,
+ type_,
+ })
+ }
}
diff --git a/tests/keyword_test/mod.rs b/tests/keyword_test/mod.rs
index 56f68c4..b0b522e 100644
--- a/tests/keyword_test/mod.rs
+++ b/tests/keyword_test/mod.rs
@@ -1,15 +1,15 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod keyword_test {
- use super::*;
- mod abc_generated;
- pub use self::abc_generated::*;
- mod public_generated;
- pub use self::public_generated::*;
- mod keywords_in_union_generated;
- pub use self::keywords_in_union_generated::*;
- mod keywords_in_table_generated;
- pub use self::keywords_in_table_generated::*;
- mod table_2_generated;
- pub use self::table_2_generated::*;
+ use super::*;
+ mod abc_generated;
+ pub use self::abc_generated::*;
+ mod public_generated;
+ pub use self::public_generated::*;
+ mod keywords_in_union_generated;
+ pub use self::keywords_in_union_generated::*;
+ mod keywords_in_table_generated;
+ pub use self::keywords_in_table_generated::*;
+ mod table_2_generated;
+ pub use self::table_2_generated::*;
} // keyword_test
diff --git a/tests/monster_test/mod.rs b/tests/monster_test/mod.rs
index 7f1fab1..27af0f2 100644
--- a/tests/monster_test/mod.rs
+++ b/tests/monster_test/mod.rs
@@ -1,58 +1,58 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod example {
use super::*;
- mod color_generated;
- pub use self::color_generated::*;
- mod race_generated;
- pub use self::race_generated::*;
- mod long_enum_generated;
- pub use self::long_enum_generated::*;
- mod any_generated;
- pub use self::any_generated::*;
- mod any_unique_aliases_generated;
- pub use self::any_unique_aliases_generated::*;
- mod any_ambiguous_aliases_generated;
- pub use self::any_ambiguous_aliases_generated::*;
- mod test_generated;
- pub use self::test_generated::*;
- mod test_simple_table_with_enum_generated;
- pub use self::test_simple_table_with_enum_generated::*;
- mod vec_3_generated;
- pub use self::vec_3_generated::*;
- mod ability_generated;
- pub use self::ability_generated::*;
- mod struct_of_structs_generated;
- pub use self::struct_of_structs_generated::*;
- mod struct_of_structs_of_structs_generated;
- pub use self::struct_of_structs_of_structs_generated::*;
- mod stat_generated;
- pub use self::stat_generated::*;
- mod referrable_generated;
- pub use self::referrable_generated::*;
- mod monster_generated;
- pub use self::monster_generated::*;
- mod type_aliases_generated;
- pub use self::type_aliases_generated::*;
- } // example
- pub mod example_2 {
- use super::*;
- mod monster_generated;
- pub use self::monster_generated::*;
- } // example_2
- pub mod other_name_space {
- use super::*;
- mod from_include_generated;
- pub use self::from_include_generated::*;
- mod unused_generated;
- pub use self::unused_generated::*;
- mod table_b_generated;
- pub use self::table_b_generated::*;
- } // other_name_space
- mod in_parent_namespace_generated;
- pub use self::in_parent_namespace_generated::*;
+ pub mod example {
+ use super::*;
+ mod color_generated;
+ pub use self::color_generated::*;
+ mod race_generated;
+ pub use self::race_generated::*;
+ mod long_enum_generated;
+ pub use self::long_enum_generated::*;
+ mod any_generated;
+ pub use self::any_generated::*;
+ mod any_unique_aliases_generated;
+ pub use self::any_unique_aliases_generated::*;
+ mod any_ambiguous_aliases_generated;
+ pub use self::any_ambiguous_aliases_generated::*;
+ mod test_generated;
+ pub use self::test_generated::*;
+ mod test_simple_table_with_enum_generated;
+ pub use self::test_simple_table_with_enum_generated::*;
+ mod vec_3_generated;
+ pub use self::vec_3_generated::*;
+ mod ability_generated;
+ pub use self::ability_generated::*;
+ mod struct_of_structs_generated;
+ pub use self::struct_of_structs_generated::*;
+ mod struct_of_structs_of_structs_generated;
+ pub use self::struct_of_structs_of_structs_generated::*;
+ mod stat_generated;
+ pub use self::stat_generated::*;
+ mod referrable_generated;
+ pub use self::referrable_generated::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ mod type_aliases_generated;
+ pub use self::type_aliases_generated::*;
+ } // example
+ pub mod example_2 {
+ use super::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ } // example_2
+ pub mod other_name_space {
+ use super::*;
+ mod from_include_generated;
+ pub use self::from_include_generated::*;
+ mod unused_generated;
+ pub use self::unused_generated::*;
+ mod table_b_generated;
+ pub use self::table_b_generated::*;
+ } // other_name_space
+ mod in_parent_namespace_generated;
+ pub use self::in_parent_namespace_generated::*;
} // my_game
mod table_a_generated;
pub use self::table_a_generated::*;
diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs
index 6cd6f90..7dd3849 100644
--- a/tests/monster_test/my_game/example/ability_generated.rs
+++ b/tests/monster_test/my_game/example/ability_generated.rs
@@ -8,39 +8,39 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Ability(pub [u8; 8]);
-impl Default for Ability {
- fn default() -> Self {
- Self([0; 8])
- }
+impl Default for Ability {
+ fn default() -> Self {
+ Self([0; 8])
+ }
}
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())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Ability")
+ .field("id", &self.id())
+ .field("distance", &self.distance())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
impl<'a> ::flatbuffers::Follow<'a> for Ability {
- type Inner = &'a Ability;
+ type Inner = &'a Ability;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Ability>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Ability>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Ability {
- type Inner = &'a Ability;
+ type Inner = &'a Ability;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Ability {
@@ -59,118 +59,118 @@
}
impl<'a> ::flatbuffers::Verifiable for Ability {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Ability {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- id: u32,
- distance: u32,
- ) -> Self {
- let mut s = Self([0; 8]);
- s.set_id(id);
- s.set_distance(distance);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Ability"
- }
-
- pub fn id(&self) -> u32 {
- let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_id(&mut self, x: u32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ id: u32,
+ distance: u32,
+ ) -> Self {
+ let mut s = Self([0; 8]);
+ s.set_id(id);
+ s.set_distance(distance);
+ s
}
- }
-
- #[inline]
- pub fn key_compare_less_than(&self, o: &Ability) -> bool {
- self.id() < o.id()
- }
-
- #[inline]
- pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
- let key = self.id();
- key.cmp(&val)
- }
- pub fn distance(&self) -> u32 {
- let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_distance(&mut self, x: u32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Ability"
}
- }
- pub fn unpack(&self) -> AbilityT {
- AbilityT {
- id: self.id(),
- distance: self.distance(),
+ pub fn id(&self) -> u32 {
+ let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_id(&mut self, x: u32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Ability) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
+ pub fn distance(&self) -> u32 {
+ let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_distance(&mut self, x: u32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> AbilityT {
+ AbilityT {
+ id: self.id(),
+ distance: self.distance(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct AbilityT {
- pub id: u32,
- pub distance: u32,
+ pub id: u32,
+ pub distance: u32,
}
impl AbilityT {
- pub fn pack(&self) -> Ability {
- Ability::new(
- self.id,
- self.distance,
- )
- }
+ pub fn pack(&self) -> Ability {
+ Ability::new(
+ self.id,
+ self.distance,
+ )
+ }
}
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 1363d0e..0501ade 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
@@ -12,10 +12,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
- AnyAmbiguousAliases::NONE,
- AnyAmbiguousAliases::M1,
- AnyAmbiguousAliases::M2,
- AnyAmbiguousAliases::M3,
+ AnyAmbiguousAliases::NONE,
+ AnyAmbiguousAliases::M1,
+ AnyAmbiguousAliases::M2,
+ AnyAmbiguousAliases::M3,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -24,50 +24,50 @@
#[allow(non_upper_case_globals)]
impl AnyAmbiguousAliases {
- pub const NONE: Self = Self(0);
- pub const M1: Self = Self(1);
- pub const M2: Self = Self(2);
- pub const M3: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const M1: Self = Self(1);
+ pub const M2: Self = Self(2);
+ pub const M3: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::M1,
- Self::M2,
- Self::M3,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M1,
+ Self::M2,
+ Self::M3,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::M1 => Some("M1"),
- Self::M2 => Some("M2"),
- Self::M3 => Some("M3"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M1 => Some("M1"),
+ Self::M2 => Some("M2"),
+ Self::M3 => Some("M3"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for AnyAmbiguousAliases {
@@ -80,28 +80,28 @@
}
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for AnyAmbiguousAliases {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
@@ -112,107 +112,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyAmbiguousAliasesT {
- NONE,
- M1(alloc::boxed::Box<MonsterT>),
- M2(alloc::boxed::Box<MonsterT>),
- M3(alloc::boxed::Box<MonsterT>),
+ NONE,
+ M1(alloc::boxed::Box<MonsterT>),
+ M2(alloc::boxed::Box<MonsterT>),
+ M3(alloc::boxed::Box<MonsterT>),
}
impl Default for AnyAmbiguousAliasesT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyAmbiguousAliasesT {
- pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
- match self {
- Self::NONE => AnyAmbiguousAliases::NONE,
- Self::M1(_) => AnyAmbiguousAliases::M1,
- Self::M2(_) => AnyAmbiguousAliases::M2,
- Self::M3(_) => AnyAmbiguousAliases::M3,
+ pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
+ match self {
+ Self::NONE => AnyAmbiguousAliases::NONE,
+ Self::M1(_) => AnyAmbiguousAliases::M1,
+ Self::M2(_) => AnyAmbiguousAliases::M2,
+ Self::M3(_) => AnyAmbiguousAliases::M3,
+ }
}
- }
- pub fn pack<'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()),
- Self::M2(v) => Some(v.pack(fbb).as_union_value()),
- Self::M3(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M3(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M1(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M1(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M1(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M1(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m1(&self) -> Option<&MonsterT> {
- if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M2(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M2(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m1(&self) -> Option<&MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m2(&self) -> Option<&MonsterT> {
- if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M3(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M3(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m3(&self) -> Option<&MonsterT> {
- if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m2(&self) -> Option<&MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M3(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M3(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m3(&self) -> Option<&MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
+ }
}
diff --git a/tests/monster_test/my_game/example/any_generated.rs b/tests/monster_test/my_game/example/any_generated.rs
index 268d316..106b029 100644
--- a/tests/monster_test/my_game/example/any_generated.rs
+++ b/tests/monster_test/my_game/example/any_generated.rs
@@ -12,10 +12,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY: [Any; 4] = [
- Any::NONE,
- Any::Monster,
- Any::TestSimpleTableWithEnum,
- Any::MyGame_Example2_Monster,
+ Any::NONE,
+ Any::Monster,
+ Any::TestSimpleTableWithEnum,
+ Any::MyGame_Example2_Monster,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -24,50 +24,50 @@
#[allow(non_upper_case_globals)]
impl Any {
- pub const NONE: Self = Self(0);
- pub const Monster: Self = Self(1);
- pub const TestSimpleTableWithEnum: Self = Self(2);
- pub const MyGame_Example2_Monster: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const Monster: Self = Self(1);
+ pub const TestSimpleTableWithEnum: Self = Self(2);
+ pub const MyGame_Example2_Monster: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::Monster,
- Self::TestSimpleTableWithEnum,
- Self::MyGame_Example2_Monster,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Monster,
+ Self::TestSimpleTableWithEnum,
+ Self::MyGame_Example2_Monster,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::Monster => Some("Monster"),
- Self::TestSimpleTableWithEnum => Some("TestSimpleTableWithEnum"),
- Self::MyGame_Example2_Monster => Some("MyGame_Example2_Monster"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Monster => Some("Monster"),
+ Self::TestSimpleTableWithEnum => Some("TestSimpleTableWithEnum"),
+ Self::MyGame_Example2_Monster => Some("MyGame_Example2_Monster"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for Any {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Any {
@@ -80,28 +80,28 @@
}
impl ::flatbuffers::EndianScalar for Any {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Any {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
@@ -112,107 +112,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyT {
- NONE,
- Monster(alloc::boxed::Box<MonsterT>),
- TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
- MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
+ NONE,
+ Monster(alloc::boxed::Box<MonsterT>),
+ TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
+ MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
}
impl Default for AnyT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyT {
- pub fn any_type(&self) -> Any {
- match self {
- Self::NONE => Any::NONE,
- Self::Monster(_) => Any::Monster,
- Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum,
- Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
+ pub fn any_type(&self) -> Any {
+ match self {
+ Self::NONE => Any::NONE,
+ Self::Monster(_) => Any::Monster,
+ Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum,
+ Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
+ }
}
- }
- pub fn pack<'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()),
- Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()),
- Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()),
+ Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_monster(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::Monster(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Monster(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_monster(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::Monster(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_monster(&self) -> Option<&MonsterT> {
- if let Self::Monster(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
- pub fn take_test_simple_table_with_enum(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
- if let Self::TestSimpleTableWithEnum(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::TestSimpleTableWithEnum(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_monster(&self) -> Option<&MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
- pub fn as_test_simple_table_with_enum(&self) -> Option<&TestSimpleTableWithEnumT> {
- if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
- pub fn as_test_simple_table_with_enum_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
- if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
- pub fn take_my_game_example_2_monster(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
- if let Self::MyGameExample2Monster(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::MyGameExample2Monster(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the super::example_2::MonsterT.
- pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> {
- if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_test_simple_table_with_enum(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
+ if let Self::TestSimpleTableWithEnum(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::TestSimpleTableWithEnum(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
- pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
- if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
+ pub fn as_test_simple_table_with_enum(&self) -> Option<&TestSimpleTableWithEnumT> {
+ if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
+ pub fn as_test_simple_table_with_enum_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
+ if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
+ pub fn take_my_game_example_2_monster(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
+ if let Self::MyGameExample2Monster(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::MyGameExample2Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 f4d8592..8abf5c6 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
@@ -12,10 +12,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY_UNIQUE_ALIASES: [AnyUniqueAliases; 4] = [
- AnyUniqueAliases::NONE,
- AnyUniqueAliases::M,
- AnyUniqueAliases::TS,
- AnyUniqueAliases::M2,
+ AnyUniqueAliases::NONE,
+ AnyUniqueAliases::M,
+ AnyUniqueAliases::TS,
+ AnyUniqueAliases::M2,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -24,50 +24,50 @@
#[allow(non_upper_case_globals)]
impl AnyUniqueAliases {
- pub const NONE: Self = Self(0);
- pub const M: Self = Self(1);
- pub const TS: Self = Self(2);
- pub const M2: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const M: Self = Self(1);
+ pub const TS: Self = Self(2);
+ pub const M2: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::M,
- Self::TS,
- Self::M2,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M,
+ Self::TS,
+ Self::M2,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::M => Some("M"),
- Self::TS => Some("TS"),
- Self::M2 => Some("M2"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M => Some("M"),
+ Self::TS => Some("TS"),
+ Self::M2 => Some("M2"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for AnyUniqueAliases {
@@ -80,28 +80,28 @@
}
impl ::flatbuffers::EndianScalar for AnyUniqueAliases {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for AnyUniqueAliases {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {}
@@ -112,107 +112,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyUniqueAliasesT {
- NONE,
- M(alloc::boxed::Box<MonsterT>),
- TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
- M2(alloc::boxed::Box<super::example_2::MonsterT>),
+ NONE,
+ M(alloc::boxed::Box<MonsterT>),
+ TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
+ M2(alloc::boxed::Box<super::example_2::MonsterT>),
}
impl Default for AnyUniqueAliasesT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyUniqueAliasesT {
- pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
- match self {
- Self::NONE => AnyUniqueAliases::NONE,
- Self::M(_) => AnyUniqueAliases::M,
- Self::TS(_) => AnyUniqueAliases::TS,
- Self::M2(_) => AnyUniqueAliases::M2,
+ pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
+ match self {
+ Self::NONE => AnyUniqueAliases::NONE,
+ Self::M(_) => AnyUniqueAliases::M,
+ Self::TS(_) => AnyUniqueAliases::TS,
+ Self::M2(_) => AnyUniqueAliases::M2,
+ }
}
- }
- pub fn pack<'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()),
- Self::TS(v) => Some(v.pack(fbb).as_union_value()),
- Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::TS(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m(&self) -> Option<&MonsterT> {
- if let Self::M(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
- pub fn take_ts(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
- if let Self::TS(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::TS(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m(&self) -> Option<&MonsterT> {
+ if let Self::M(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
- pub fn as_ts(&self) -> Option<&TestSimpleTableWithEnumT> {
- if let Self::TS(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
- pub fn as_ts_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
- if let Self::TS(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
- pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
- if let Self::M2(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M2(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the super::example_2::MonsterT.
- pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> {
- if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_ts(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
+ if let Self::TS(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::TS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
- pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
- if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
+ pub fn as_ts(&self) -> Option<&TestSimpleTableWithEnumT> {
+ if let Self::TS(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
+ pub fn as_ts_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
+ if let Self::TS(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
+ pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
+ }
}
diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs
index c4b5842..ca3886b 100644
--- a/tests/monster_test/my_game/example/color_generated.rs
+++ b/tests/monster_test/my_game/example/color_generated.rs
@@ -5,30 +5,30 @@
#[allow(non_upper_case_globals)]
mod bitflags_color {
- ::flatbuffers::bitflags::bitflags! {
- /// Composite components of Monster color.
- #[derive(Default, Debug, Clone, Copy, PartialEq)]
- pub struct Color: u8 {
- const Red = 1;
- /// \brief color Green
- /// Green is bit_flag with value (1u << 1)
- const Green = 2;
- /// \brief color Blue (1u << 3)
- const Blue = 8;
+ ::flatbuffers::bitflags::bitflags! {
+ /// Composite components of Monster color.
+ #[derive(Default, Debug, Clone, Copy, PartialEq)]
+ pub struct Color: u8 {
+ const Red = 1;
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ const Green = 2;
+ /// \brief color Blue (1u << 3)
+ const Blue = 8;
+ }
}
- }
}
pub use self::bitflags_color::Color;
impl<'a> ::flatbuffers::Follow<'a> for Color {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self::from_bits_retain(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self::from_bits_retain(b)
+ }
}
impl ::flatbuffers::Push for Color {
@@ -41,28 +41,28 @@
}
impl ::flatbuffers::EndianScalar for Color {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.bits().to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.bits().to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self::from_bits_retain(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self::from_bits_retain(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Color {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
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 b690f44..7cac770 100644
--- a/tests/monster_test/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test/my_game/example/long_enum_generated.rs
@@ -5,26 +5,26 @@
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
- ::flatbuffers::bitflags::bitflags! {
- #[derive(Default, Debug, Clone, Copy, PartialEq)]
- pub struct LongEnum: u64 {
- const LongOne = 2;
- const LongTwo = 4;
- const LongBig = 1099511627776;
+ ::flatbuffers::bitflags::bitflags! {
+ #[derive(Default, Debug, Clone, Copy, PartialEq)]
+ pub struct LongEnum: u64 {
+ const LongOne = 2;
+ const LongTwo = 4;
+ const LongBig = 1099511627776;
+ }
}
- }
}
pub use self::bitflags_long_enum::LongEnum;
impl<'a> ::flatbuffers::Follow<'a> for LongEnum {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
- Self::from_bits_retain(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
+ Self::from_bits_retain(b)
+ }
}
impl ::flatbuffers::Push for LongEnum {
@@ -37,28 +37,28 @@
}
impl ::flatbuffers::EndianScalar for LongEnum {
- type Scalar = u64;
+ type Scalar = u64;
- #[inline]
- fn to_little_endian(self) -> u64 {
- self.bits().to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u64 {
+ self.bits().to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u64) -> Self {
- let b = u64::from_le(v);
- Self::from_bits_retain(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u64) -> Self {
+ let b = u64::from_le(v);
+ Self::from_bits_retain(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for LongEnum {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u64::run_verifier(v, pos)
+ }
}
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 34aaac6..d860e06 100644
--- a/tests/monster_test/my_game/example/monster_generated.rs
+++ b/tests/monster_test/my_game/example/monster_generated.rs
@@ -8,1133 +8,1133 @@
/// an example documentation comment: "monster object"
#[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> {
- type Inner = Monster<'a>;
+ type Inner = Monster<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Monster<'a> {
- pub const VT_POS: ::flatbuffers::VOffsetT = 4;
- pub const VT_MANA: ::flatbuffers::VOffsetT = 6;
- pub const VT_HP: ::flatbuffers::VOffsetT = 8;
- pub const VT_NAME: ::flatbuffers::VOffsetT = 10;
- pub const VT_INVENTORY: ::flatbuffers::VOffsetT = 14;
- pub const VT_COLOR: ::flatbuffers::VOffsetT = 16;
- pub const VT_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 {
- 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>,
- args: &'args MonsterArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
- 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);
- builder.add_long_enum_non_enum_default(args.long_enum_non_enum_default);
- builder.add_non_owning_reference(args.non_owning_reference);
- builder.add_co_owning_reference(args.co_owning_reference);
- builder.add_single_weak_reference(args.single_weak_reference);
- builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
- builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
- builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
- builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
- builder.add_negative_infinity_default(args.negative_infinity_default);
- builder.add_negative_inf_default(args.negative_inf_default);
- builder.add_positive_infinity_default(args.positive_infinity_default);
- builder.add_infinity_default(args.infinity_default);
- builder.add_positive_inf_default(args.positive_inf_default);
- builder.add_inf_default(args.inf_default);
- builder.add_nan_default(args.nan_default);
- if let Some(x) = args.native_inline { builder.add_native_inline(x); }
- if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
- if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
- if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
- if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
- if let Some(x) = args.any_unique { builder.add_any_unique(x); }
- if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
- if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
- if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
- if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
- if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
- if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
- if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
- if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
- if let Some(x) = args.test5 { builder.add_test5(x); }
- if let Some(x) = args.flex { builder.add_flex(x); }
- if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
- if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
- builder.add_testf3(args.testf3);
- builder.add_testf2(args.testf2);
- builder.add_testf(args.testf);
- if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
- builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
- builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
- builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
- builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
- if let Some(x) = args.testempty { builder.add_testempty(x); }
- if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
- if let Some(x) = args.enemy { builder.add_enemy(x); }
- if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
- if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
- if let Some(x) = args.test4 { builder.add_test4(x); }
- if let Some(x) = args.test { builder.add_test(x); }
- if let Some(x) = args.inventory { builder.add_inventory(x); }
- if let Some(x) = args.name { builder.add_name(x); }
- if let Some(x) = args.pos { builder.add_pos(x); }
- builder.add_hp(args.hp);
- builder.add_mana(args.mana);
- builder.add_signed_enum(args.signed_enum);
- builder.add_any_ambiguous_type(args.any_ambiguous_type);
- builder.add_any_unique_type(args.any_unique_type);
- builder.add_testbool(args.testbool);
- builder.add_test_type(args.test_type);
- builder.add_color(args.color);
- builder.finish()
- }
-
- pub fn unpack(&self) -> MonsterT {
- let pos = self.pos().map(|x| {
- x.unpack()
- });
- let mana = self.mana();
- let hp = self.hp();
- let name = {
- let x = self.name();
- alloc::string::ToString::to_string(x)
- };
- let inventory = self.inventory().map(|x| {
- x.into_iter().collect()
- });
- let color = self.color();
- let test = match self.test_type() {
- Any::NONE => AnyT::NONE,
- Any::Monster => AnyT::Monster(alloc::boxed::Box::new(
- self.test_as_monster()
- .expect("Invalid union table, expected `Any::Monster`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.test_as_my_game_example_2_monster()
- .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.")
- .unpack()
- )),
- _ => AnyT::NONE,
- };
- let test4 = self.test4().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let testarrayofstring = self.testarrayofstring().map(|x| {
- x.iter().map(|s| 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| {
- alloc::boxed::Box::new(x.unpack())
- });
- let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| {
- x.into_iter().collect()
- });
- let testempty = self.testempty().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- let testbool = self.testbool();
- let testhashs32_fnv1 = self.testhashs32_fnv1();
- let testhashu32_fnv1 = self.testhashu32_fnv1();
- let testhashs64_fnv1 = self.testhashs64_fnv1();
- let testhashu64_fnv1 = self.testhashu64_fnv1();
- let testhashs32_fnv1a = self.testhashs32_fnv1a();
- let testhashu32_fnv1a = self.testhashu32_fnv1a();
- let testhashs64_fnv1a = self.testhashs64_fnv1a();
- let testhashu64_fnv1a = self.testhashu64_fnv1a();
- let testarrayofbools = self.testarrayofbools().map(|x| {
- x.into_iter().collect()
- });
- let testf = self.testf();
- let testf2 = self.testf2();
- let testf3 = self.testf3();
- let testarrayofstring2 = self.testarrayofstring2().map(|x| {
- x.iter().map(|s| alloc::string::ToString::to_string(s)).collect()
- });
- let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let flex = self.flex().map(|x| {
- x.into_iter().collect()
- });
- let test5 = self.test5().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let vector_of_longs = self.vector_of_longs().map(|x| {
- x.into_iter().collect()
- });
- let vector_of_doubles = self.vector_of_doubles().map(|x| {
- x.into_iter().collect()
- });
- let parent_namespace_test = self.parent_namespace_test().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- let vector_of_referrables = self.vector_of_referrables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let single_weak_reference = self.single_weak_reference();
- let vector_of_weak_references = self.vector_of_weak_references().map(|x| {
- x.into_iter().collect()
- });
- let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let co_owning_reference = self.co_owning_reference();
- let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| {
- x.into_iter().collect()
- });
- let non_owning_reference = self.non_owning_reference();
- let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| {
- x.into_iter().collect()
- });
- let any_unique = match self.any_unique_type() {
- AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE,
- AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new(
- self.any_unique_as_m()
- .expect("Invalid union table, expected `AnyUniqueAliases::M`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.any_unique_as_m2()
- .expect("Invalid union table, expected `AnyUniqueAliases::M2`.")
- .unpack()
- )),
- _ => AnyUniqueAliasesT::NONE,
- };
- let any_ambiguous = match self.any_ambiguous_type() {
- AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE,
- AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new(
- self.any_ambiguous_as_m1()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.any_ambiguous_as_m3()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.")
- .unpack()
- )),
- _ => AnyAmbiguousAliasesT::NONE,
- };
- let vector_of_enums = self.vector_of_enums().map(|x| {
- x.into_iter().collect()
- });
- let signed_enum = self.signed_enum();
- let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| {
- x.into_iter().collect()
- });
- let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let native_inline = self.native_inline().map(|x| {
- x.unpack()
- });
- let long_enum_non_enum_default = self.long_enum_non_enum_default();
- let long_enum_normal_default = self.long_enum_normal_default();
- let nan_default = self.nan_default();
- let inf_default = self.inf_default();
- let positive_inf_default = self.positive_inf_default();
- let infinity_default = self.infinity_default();
- let positive_infinity_default = self.positive_infinity_default();
- let negative_inf_default = self.negative_inf_default();
- let negative_infinity_default = self.negative_infinity_default();
- let double_inf_default = self.double_inf_default();
- MonsterT {
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- test,
- test4,
- testarrayofstring,
- testarrayoftables,
- enemy,
- testnestedflatbuffer,
- testempty,
- testbool,
- testhashs32_fnv1,
- testhashu32_fnv1,
- testhashs64_fnv1,
- testhashu64_fnv1,
- testhashs32_fnv1a,
- testhashu32_fnv1a,
- testhashs64_fnv1a,
- testhashu64_fnv1a,
- testarrayofbools,
- testf,
- testf2,
- testf3,
- testarrayofstring2,
- testarrayofsortedstruct,
- flex,
- test5,
- vector_of_longs,
- vector_of_doubles,
- parent_namespace_test,
- vector_of_referrables,
- single_weak_reference,
- vector_of_weak_references,
- vector_of_strong_referrables,
- co_owning_reference,
- vector_of_co_owning_references,
- non_owning_reference,
- vector_of_non_owning_references,
- any_unique,
- any_ambiguous,
- vector_of_enums,
- signed_enum,
- testrequirednestedflatbuffer,
- scalar_key_sorted_tables,
- native_inline,
- long_enum_non_enum_default,
- long_enum_normal_default,
- nan_default,
- inf_default,
- positive_inf_default,
- infinity_default,
- positive_infinity_default,
- negative_inf_default,
- negative_infinity_default,
- double_inf_default,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Monster"
}
- }
- #[inline]
- pub fn pos(&self) -> Option<&'a Vec3> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
- }
-
- #[inline]
- pub fn mana(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
- }
-
- #[inline]
- pub fn hp(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
- }
-
- #[inline]
- pub fn name(&self) -> &'a str {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()}
- }
-
- #[inline]
- pub fn key_compare_less_than(&self, o: &Monster) -> bool {
- self.name() < o.name()
- }
-
- #[inline]
- pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
- let key = self.name();
- key.cmp(val)
- }
-
- #[inline]
- pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
- }
-
- #[inline]
- pub fn color(&self) -> Color {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
- }
-
- #[inline]
- pub fn test_type(&self) -> Any {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Any>(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)}
- }
-
- #[inline]
- 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::<::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<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster>>>>(Monster::VT_TESTARRAYOFTABLES, None)}
- }
-
- #[inline]
- pub fn enemy(&self) -> Option<Monster<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Monster>>(Monster::VT_ENEMY, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)}
- }
-
- pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
- self.testnestedflatbuffer().map(|data| {
- use ::flatbuffers::Follow;
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid flatbuffer in this slot
- unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
- })
- }
-
- #[inline]
- pub fn testempty(&self) -> Option<Stat<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Stat>>(Monster::VT_TESTEMPTY, None)}
- }
-
- #[inline]
- pub fn testbool(&self) -> bool {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(Monster::VT_TESTBOOL, Some(false)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs32_fnv1(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu32_fnv1(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs64_fnv1(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu64_fnv1(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs32_fnv1a(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu32_fnv1a(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs64_fnv1a(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu64_fnv1a(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)}
- }
-
- #[inline]
- pub fn testf(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF, Some(3.14159)).unwrap()}
- }
-
- #[inline]
- pub fn testf2(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF2, Some(3.0)).unwrap()}
- }
-
- #[inline]
- pub fn testf3(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF3, Some(0.0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)}
- }
-
- #[inline]
- pub fn parent_namespace_test(&self) -> Option<super::InParentNamespace<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, None)}
- }
-
- #[inline]
- pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)}
- }
-
- #[inline]
- pub fn single_weak_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)}
- }
-
- #[inline]
- pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)}
- }
-
- #[inline]
- pub fn co_owning_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)}
- }
-
- #[inline]
- pub fn non_owning_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)}
- }
-
- #[inline]
- pub fn any_unique_type(&self) -> AnyUniqueAliases {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)}
- }
-
- #[inline]
- pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)}
- }
-
- #[inline]
- pub fn signed_enum(&self) -> Race {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Race>(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)}
- }
-
- pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
- self.testrequirednestedflatbuffer().map(|data| {
- use ::flatbuffers::Follow;
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid flatbuffer in this slot
- unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
- })
- }
-
- #[inline]
- pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat>>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)}
- }
-
- #[inline]
- pub fn native_inline(&self) -> Option<&'a Test> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Test>(Monster::VT_NATIVE_INLINE, None)}
- }
-
- #[inline]
- pub fn long_enum_non_enum_default(&self) -> LongEnum {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, Some(Default::default())).unwrap()}
- }
-
- #[inline]
- pub fn long_enum_normal_default(&self) -> LongEnum {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, Some(LongEnum::LongOne)).unwrap()}
- }
-
- #[inline]
- pub fn nan_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NAN_DEFAULT, Some(f32::NAN)).unwrap()}
- }
-
- #[inline]
- pub fn inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn positive_inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn positive_infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn negative_inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn negative_infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn double_inf_default(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(Monster::VT_DOUBLE_INF_DEFAULT, Some(f64::INFINITY)).unwrap()}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_monster(&self) -> Option<Monster<'a>> {
- if self.test_type() == Any::Monster {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Monster { _tab: table }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
- if self.test_type() == Any::TestSimpleTableWithEnum {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { TestSimpleTableWithEnum::init_from_table(t) }
- })
- } else {
- None
+ #[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>,
+ args: &'args MonsterArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
+ 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);
+ builder.add_long_enum_non_enum_default(args.long_enum_non_enum_default);
+ builder.add_non_owning_reference(args.non_owning_reference);
+ builder.add_co_owning_reference(args.co_owning_reference);
+ builder.add_single_weak_reference(args.single_weak_reference);
+ builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
+ builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
+ builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
+ builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
+ builder.add_negative_infinity_default(args.negative_infinity_default);
+ builder.add_negative_inf_default(args.negative_inf_default);
+ builder.add_positive_infinity_default(args.positive_infinity_default);
+ builder.add_infinity_default(args.infinity_default);
+ builder.add_positive_inf_default(args.positive_inf_default);
+ builder.add_inf_default(args.inf_default);
+ builder.add_nan_default(args.nan_default);
+ if let Some(x) = args.native_inline { builder.add_native_inline(x); }
+ if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
+ if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
+ if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
+ if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
+ if let Some(x) = args.any_unique { builder.add_any_unique(x); }
+ if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
+ if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
+ if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
+ if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
+ if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
+ if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
+ if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
+ if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
+ if let Some(x) = args.test5 { builder.add_test5(x); }
+ if let Some(x) = args.flex { builder.add_flex(x); }
+ if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
+ if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
+ builder.add_testf3(args.testf3);
+ builder.add_testf2(args.testf2);
+ builder.add_testf(args.testf);
+ if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
+ builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
+ builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
+ builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
+ builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
+ if let Some(x) = args.testempty { builder.add_testempty(x); }
+ if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
+ if let Some(x) = args.enemy { builder.add_enemy(x); }
+ if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
+ if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
+ if let Some(x) = args.test4 { builder.add_test4(x); }
+ if let Some(x) = args.test { builder.add_test(x); }
+ if let Some(x) = args.inventory { builder.add_inventory(x); }
+ if let Some(x) = args.name { builder.add_name(x); }
+ if let Some(x) = args.pos { builder.add_pos(x); }
+ builder.add_hp(args.hp);
+ builder.add_mana(args.mana);
+ builder.add_signed_enum(args.signed_enum);
+ builder.add_any_ambiguous_type(args.any_ambiguous_type);
+ builder.add_any_unique_type(args.any_unique_type);
+ builder.add_testbool(args.testbool);
+ builder.add_test_type(args.test_type);
+ builder.add_color(args.color);
+ builder.finish()
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
- if self.test_type() == Any::MyGame_Example2_Monster {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { super::example_2::Monster::init_from_table(t) }
- })
- } else {
- None
+ pub fn unpack(&self) -> MonsterT {
+ let pos = self.pos().map(|x| {
+ x.unpack()
+ });
+ let mana = self.mana();
+ let hp = self.hp();
+ let name = {
+ let x = self.name();
+ alloc::string::ToString::to_string(x)
+ };
+ let inventory = self.inventory().map(|x| {
+ x.into_iter().collect()
+ });
+ let color = self.color();
+ let test = match self.test_type() {
+ Any::NONE => AnyT::NONE,
+ Any::Monster => AnyT::Monster(alloc::boxed::Box::new(
+ self.test_as_monster()
+ .expect("Invalid union table, expected `Any::Monster`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.test_as_my_game_example_2_monster()
+ .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.")
+ .unpack()
+ )),
+ _ => AnyT::NONE,
+ };
+ let test4 = self.test4().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let testarrayofstring = self.testarrayofstring().map(|x| {
+ x.iter().map(|s| 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| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| {
+ x.into_iter().collect()
+ });
+ let testempty = self.testempty().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let testbool = self.testbool();
+ let testhashs32_fnv1 = self.testhashs32_fnv1();
+ let testhashu32_fnv1 = self.testhashu32_fnv1();
+ let testhashs64_fnv1 = self.testhashs64_fnv1();
+ let testhashu64_fnv1 = self.testhashu64_fnv1();
+ let testhashs32_fnv1a = self.testhashs32_fnv1a();
+ let testhashu32_fnv1a = self.testhashu32_fnv1a();
+ let testhashs64_fnv1a = self.testhashs64_fnv1a();
+ let testhashu64_fnv1a = self.testhashu64_fnv1a();
+ let testarrayofbools = self.testarrayofbools().map(|x| {
+ x.into_iter().collect()
+ });
+ let testf = self.testf();
+ let testf2 = self.testf2();
+ let testf3 = self.testf3();
+ let testarrayofstring2 = self.testarrayofstring2().map(|x| {
+ x.iter().map(|s| alloc::string::ToString::to_string(s)).collect()
+ });
+ let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let flex = self.flex().map(|x| {
+ x.into_iter().collect()
+ });
+ let test5 = self.test5().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let vector_of_longs = self.vector_of_longs().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_doubles = self.vector_of_doubles().map(|x| {
+ x.into_iter().collect()
+ });
+ let parent_namespace_test = self.parent_namespace_test().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let vector_of_referrables = self.vector_of_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let single_weak_reference = self.single_weak_reference();
+ let vector_of_weak_references = self.vector_of_weak_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let co_owning_reference = self.co_owning_reference();
+ let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let non_owning_reference = self.non_owning_reference();
+ let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let any_unique = match self.any_unique_type() {
+ AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE,
+ AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new(
+ self.any_unique_as_m()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.any_unique_as_m2()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M2`.")
+ .unpack()
+ )),
+ _ => AnyUniqueAliasesT::NONE,
+ };
+ let any_ambiguous = match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE,
+ AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new(
+ self.any_ambiguous_as_m1()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.any_ambiguous_as_m3()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.")
+ .unpack()
+ )),
+ _ => AnyAmbiguousAliasesT::NONE,
+ };
+ let vector_of_enums = self.vector_of_enums().map(|x| {
+ x.into_iter().collect()
+ });
+ let signed_enum = self.signed_enum();
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| {
+ x.into_iter().collect()
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let native_inline = self.native_inline().map(|x| {
+ x.unpack()
+ });
+ let long_enum_non_enum_default = self.long_enum_non_enum_default();
+ let long_enum_normal_default = self.long_enum_normal_default();
+ let nan_default = self.nan_default();
+ let inf_default = self.inf_default();
+ let positive_inf_default = self.positive_inf_default();
+ let infinity_default = self.infinity_default();
+ let positive_infinity_default = self.positive_infinity_default();
+ let negative_inf_default = self.negative_inf_default();
+ let negative_infinity_default = self.negative_infinity_default();
+ let double_inf_default = self.double_inf_default();
+ MonsterT {
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ nan_default,
+ inf_default,
+ positive_inf_default,
+ infinity_default,
+ positive_infinity_default,
+ negative_inf_default,
+ negative_infinity_default,
+ double_inf_default,
+ }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::M {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn pos(&self) -> Option<&'a Vec3> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_ts(&self) -> Option<TestSimpleTableWithEnum<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::TS {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { TestSimpleTableWithEnum::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn mana(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::M2 {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { super::example_2::Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn hp(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn name(&self) -> &'a str {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Monster) -> bool {
+ self.name() < o.name()
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
+ let key = self.name();
+ key.cmp(val)
}
- }
+
+ #[inline]
+ pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
+ }
+
+ #[inline]
+ pub fn test_type(&self) -> Any {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Any>(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)}
+ }
+
+ #[inline]
+ 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::<::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<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster>>>>(Monster::VT_TESTARRAYOFTABLES, None)}
+ }
+
+ #[inline]
+ pub fn enemy(&self) -> Option<Monster<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Monster>>(Monster::VT_ENEMY, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)}
+ }
+
+ pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testnestedflatbuffer().map(|data| {
+ use ::flatbuffers::Follow;
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid flatbuffer in this slot
+ unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
+ })
+ }
+
+ #[inline]
+ pub fn testempty(&self) -> Option<Stat<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Stat>>(Monster::VT_TESTEMPTY, None)}
+ }
+
+ #[inline]
+ pub fn testbool(&self) -> bool {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(Monster::VT_TESTBOOL, Some(false)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs32_fnv1(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu32_fnv1(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs64_fnv1(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu64_fnv1(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs32_fnv1a(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu32_fnv1a(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs64_fnv1a(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu64_fnv1a(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)}
+ }
+
+ #[inline]
+ pub fn testf(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF, Some(3.14159)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testf2(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF2, Some(3.0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testf3(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF3, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)}
+ }
+
+ #[inline]
+ pub fn parent_namespace_test(&self) -> Option<super::InParentNamespace<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, None)}
+ }
+
+ #[inline]
+ pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)}
+ }
+
+ #[inline]
+ pub fn single_weak_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)}
+ }
+
+ #[inline]
+ pub fn co_owning_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn non_owning_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn any_unique_type(&self) -> AnyUniqueAliases {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)}
+ }
+
+ #[inline]
+ pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)}
+ }
+
+ #[inline]
+ pub fn signed_enum(&self) -> Race {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Race>(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)}
+ }
+
+ pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testrequirednestedflatbuffer().map(|data| {
+ use ::flatbuffers::Follow;
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid flatbuffer in this slot
+ unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
+ })
+ }
+
+ #[inline]
+ pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat>>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)}
+ }
+
+ #[inline]
+ pub fn native_inline(&self) -> Option<&'a Test> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Test>(Monster::VT_NATIVE_INLINE, None)}
+ }
+
+ #[inline]
+ pub fn long_enum_non_enum_default(&self) -> LongEnum {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, Some(Default::default())).unwrap()}
+ }
+
+ #[inline]
+ pub fn long_enum_normal_default(&self) -> LongEnum {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, Some(LongEnum::LongOne)).unwrap()}
+ }
+
+ #[inline]
+ pub fn nan_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NAN_DEFAULT, Some(f32::NAN)).unwrap()}
+ }
+
+ #[inline]
+ pub fn inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn positive_inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn positive_infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn negative_inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn negative_infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn double_inf_default(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(Monster::VT_DOUBLE_INF_DEFAULT, Some(f64::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_monster(&self) -> Option<Monster<'a>> {
+ if self.test_type() == Any::Monster {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.test_type() == Any::TestSimpleTableWithEnum {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { TestSimpleTableWithEnum::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.test_type() == Any::MyGame_Example2_Monster {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { super::example_2::Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_ts(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::TS {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { TestSimpleTableWithEnum::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M2 {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { super::example_2::Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for Monster<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<Vec3>("pos", Self::VT_POS, false)?
- .visit_field::<i16>("mana", Self::VT_MANA, false)?
- .visit_field::<i16>("hp", Self::VT_HP, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
- .visit_field::<Color>("color", Self::VT_COLOR, false)?
- .visit_union::<Any, _>("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| {
- match key {
- Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("Any::Monster", pos),
- Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("Any::TestSimpleTableWithEnum", pos),
- Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("Any::MyGame_Example2_Monster", pos),
- _ => Ok(()),
- }
- })?
- .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<Monster>>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<Monster>>("enemy", Self::VT_ENEMY, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<Stat>>("testempty", Self::VT_TESTEMPTY, false)?
- .visit_field::<bool>("testbool", Self::VT_TESTBOOL, false)?
- .visit_field::<i32>("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)?
- .visit_field::<u32>("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)?
- .visit_field::<i64>("testhashs64_fnv1", Self::VT_TESTHASHS64_FNV1, false)?
- .visit_field::<u64>("testhashu64_fnv1", Self::VT_TESTHASHU64_FNV1, false)?
- .visit_field::<i32>("testhashs32_fnv1a", Self::VT_TESTHASHS32_FNV1A, false)?
- .visit_field::<u32>("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)?
- .visit_field::<i64>("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)?
- .visit_field::<u64>("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)?
- .visit_field::<f32>("testf", Self::VT_TESTF, false)?
- .visit_field::<f32>("testf2", Self::VT_TESTF2, false)?
- .visit_field::<f32>("testf3", Self::VT_TESTF3, 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<super::InParentNamespace>>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)?
- .visit_field::<u64>("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, 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<Referrable>>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)?
- .visit_field::<u64>("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)?
- .visit_field::<u64>("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)?
- .visit_union::<AnyUniqueAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyUniqueAliases::M", pos),
- AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("AnyUniqueAliases::TS", pos),
- AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("AnyUniqueAliases::M2", pos),
- _ => Ok(()),
- }
- })?
- .visit_union::<AnyAmbiguousAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M1", pos),
- AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M2", pos),
- AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M3", pos),
- _ => Ok(()),
- }
- })?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)?
- .visit_field::<Race>("signed_enum", Self::VT_SIGNED_ENUM, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Stat>>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)?
- .visit_field::<Test>("native_inline", Self::VT_NATIVE_INLINE, false)?
- .visit_field::<LongEnum>("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)?
- .visit_field::<LongEnum>("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)?
- .visit_field::<f32>("nan_default", Self::VT_NAN_DEFAULT, false)?
- .visit_field::<f32>("inf_default", Self::VT_INF_DEFAULT, false)?
- .visit_field::<f32>("positive_inf_default", Self::VT_POSITIVE_INF_DEFAULT, false)?
- .visit_field::<f32>("infinity_default", Self::VT_INFINITY_DEFAULT, false)?
- .visit_field::<f32>("positive_infinity_default", Self::VT_POSITIVE_INFINITY_DEFAULT, false)?
- .visit_field::<f32>("negative_inf_default", Self::VT_NEGATIVE_INF_DEFAULT, false)?
- .visit_field::<f32>("negative_infinity_default", Self::VT_NEGATIVE_INFINITY_DEFAULT, false)?
- .visit_field::<f64>("double_inf_default", Self::VT_DOUBLE_INF_DEFAULT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<Vec3>("pos", Self::VT_POS, false)?
+ .visit_field::<i16>("mana", Self::VT_MANA, false)?
+ .visit_field::<i16>("hp", Self::VT_HP, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .visit_union::<Any, _>("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| {
+ match key {
+ Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("Any::Monster", pos),
+ Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("Any::TestSimpleTableWithEnum", pos),
+ Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("Any::MyGame_Example2_Monster", pos),
+ _ => Ok(()),
+ }
+ })?
+ .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<Monster>>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<Monster>>("enemy", Self::VT_ENEMY, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<Stat>>("testempty", Self::VT_TESTEMPTY, false)?
+ .visit_field::<bool>("testbool", Self::VT_TESTBOOL, false)?
+ .visit_field::<i32>("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)?
+ .visit_field::<u32>("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)?
+ .visit_field::<i64>("testhashs64_fnv1", Self::VT_TESTHASHS64_FNV1, false)?
+ .visit_field::<u64>("testhashu64_fnv1", Self::VT_TESTHASHU64_FNV1, false)?
+ .visit_field::<i32>("testhashs32_fnv1a", Self::VT_TESTHASHS32_FNV1A, false)?
+ .visit_field::<u32>("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)?
+ .visit_field::<i64>("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)?
+ .visit_field::<u64>("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)?
+ .visit_field::<f32>("testf", Self::VT_TESTF, false)?
+ .visit_field::<f32>("testf2", Self::VT_TESTF2, false)?
+ .visit_field::<f32>("testf3", Self::VT_TESTF3, 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<super::InParentNamespace>>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)?
+ .visit_field::<u64>("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, 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<Referrable>>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)?
+ .visit_field::<u64>("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)?
+ .visit_field::<u64>("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)?
+ .visit_union::<AnyUniqueAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyUniqueAliases::M", pos),
+ AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("AnyUniqueAliases::TS", pos),
+ AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("AnyUniqueAliases::M2", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_union::<AnyAmbiguousAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M1", pos),
+ AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M2", pos),
+ AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M3", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)?
+ .visit_field::<Race>("signed_enum", Self::VT_SIGNED_ENUM, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Stat>>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)?
+ .visit_field::<Test>("native_inline", Self::VT_NATIVE_INLINE, false)?
+ .visit_field::<LongEnum>("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)?
+ .visit_field::<LongEnum>("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)?
+ .visit_field::<f32>("nan_default", Self::VT_NAN_DEFAULT, false)?
+ .visit_field::<f32>("inf_default", Self::VT_INF_DEFAULT, false)?
+ .visit_field::<f32>("positive_inf_default", Self::VT_POSITIVE_INF_DEFAULT, false)?
+ .visit_field::<f32>("infinity_default", Self::VT_INFINITY_DEFAULT, false)?
+ .visit_field::<f32>("positive_infinity_default", Self::VT_POSITIVE_INFINITY_DEFAULT, false)?
+ .visit_field::<f32>("negative_inf_default", Self::VT_NEGATIVE_INF_DEFAULT, false)?
+ .visit_field::<f32>("negative_infinity_default", Self::VT_NEGATIVE_INFINITY_DEFAULT, false)?
+ .visit_field::<f64>("double_inf_default", Self::VT_DOUBLE_INF_DEFAULT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct MonsterArgs<'a> {
@@ -1202,857 +1202,857 @@
}
impl<'a> Default for MonsterArgs<'a> {
- #[inline]
- fn default() -> Self {
- MonsterArgs {
- pos: None,
- mana: 150,
- hp: 100,
- name: None, // required field
- inventory: None,
- color: Color::Blue,
- test_type: Any::NONE,
- test: None,
- test4: None,
- testarrayofstring: None,
- testarrayoftables: None,
- enemy: None,
- testnestedflatbuffer: None,
- testempty: None,
- testbool: false,
- testhashs32_fnv1: 0,
- testhashu32_fnv1: 0,
- testhashs64_fnv1: 0,
- testhashu64_fnv1: 0,
- testhashs32_fnv1a: 0,
- testhashu32_fnv1a: 0,
- testhashs64_fnv1a: 0,
- testhashu64_fnv1a: 0,
- testarrayofbools: None,
- testf: 3.14159,
- testf2: 3.0,
- testf3: 0.0,
- testarrayofstring2: None,
- testarrayofsortedstruct: None,
- flex: None,
- test5: None,
- vector_of_longs: None,
- vector_of_doubles: None,
- parent_namespace_test: None,
- vector_of_referrables: None,
- single_weak_reference: 0,
- vector_of_weak_references: None,
- vector_of_strong_referrables: None,
- co_owning_reference: 0,
- vector_of_co_owning_references: None,
- non_owning_reference: 0,
- vector_of_non_owning_references: None,
- any_unique_type: AnyUniqueAliases::NONE,
- any_unique: None,
- any_ambiguous_type: AnyAmbiguousAliases::NONE,
- any_ambiguous: None,
- vector_of_enums: None,
- signed_enum: Race::None,
- testrequirednestedflatbuffer: None,
- scalar_key_sorted_tables: None,
- native_inline: None,
- long_enum_non_enum_default: Default::default(),
- long_enum_normal_default: LongEnum::LongOne,
- nan_default: f32::NAN,
- inf_default: f32::INFINITY,
- positive_inf_default: f32::INFINITY,
- infinity_default: f32::INFINITY,
- positive_infinity_default: f32::INFINITY,
- negative_inf_default: f32::NEG_INFINITY,
- negative_infinity_default: f32::NEG_INFINITY,
- double_inf_default: f64::INFINITY,
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: None, // required field
+ inventory: None,
+ color: Color::Blue,
+ test_type: Any::NONE,
+ test: None,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique_type: AnyUniqueAliases::NONE,
+ any_unique: None,
+ any_ambiguous_type: AnyAmbiguousAliases::NONE,
+ any_ambiguous: None,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ nan_default: f32::NAN,
+ inf_default: f32::INFINITY,
+ positive_inf_default: f32::INFINITY,
+ infinity_default: f32::INFINITY,
+ positive_infinity_default: f32::INFINITY,
+ negative_inf_default: f32::NEG_INFINITY,
+ negative_infinity_default: f32::NEG_INFINITY,
+ double_inf_default: f64::INFINITY,
+ }
}
- }
}
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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);
- }
-
- #[inline]
- pub fn add_mana(&mut self, mana: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
- }
-
- #[inline]
- pub fn add_hp(&mut self, hp: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
- }
-
- #[inline]
- pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
- }
-
- #[inline]
- pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
- }
-
- #[inline]
- pub fn add_color(&mut self, color: Color) {
- self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
- }
-
- #[inline]
- pub fn add_test_type(&mut self, test_type: Any) {
- self.fbb_.push_slot::<Any>(Monster::VT_TEST_TYPE, test_type, Any::NONE);
- }
-
- #[inline]
- 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<::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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Monster<'b >>>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
- }
-
- #[inline]
- pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset<Monster<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Monster>>(Monster::VT_ENEMY, enemy);
- }
-
- #[inline]
- 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<Stat<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Stat>>(Monster::VT_TESTEMPTY, testempty);
- }
-
- #[inline]
- pub fn add_testbool(&mut self, testbool: bool) {
- self.fbb_.push_slot::<bool>(Monster::VT_TESTBOOL, testbool, false);
- }
-
- #[inline]
- pub fn add_testhashs32_fnv1(&mut self, testhashs32_fnv1: i32) {
- self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashu32_fnv1(&mut self, testhashu32_fnv1: u32) {
- self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashs64_fnv1(&mut self, testhashs64_fnv1: i64) {
- self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashu64_fnv1(&mut self, testhashu64_fnv1: u64) {
- self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashs32_fnv1a(&mut self, testhashs32_fnv1a: i32) {
- self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashu32_fnv1a(&mut self, testhashu32_fnv1a: u32) {
- self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashs64_fnv1a(&mut self, testhashs64_fnv1a: i64) {
- self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashu64_fnv1a(&mut self, testhashu64_fnv1a: u64) {
- self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
- }
-
- #[inline]
- 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) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF, testf, 3.14159);
- }
-
- #[inline]
- pub fn add_testf2(&mut self, testf2: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF2, testf2, 3.0);
- }
-
- #[inline]
- pub fn add_testf3(&mut self, testf3: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF3, testf3, 0.0);
- }
-
- #[inline]
- 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<::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<::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<::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<::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<::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<super::InParentNamespace<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
- }
-
- #[inline]
- pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
- 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::<u64>(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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
- 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::<u64>(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<::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::<u64>(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<::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::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE);
- }
-
- #[inline]
- 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::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE);
- }
-
- #[inline]
- 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<::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::<Race>(Monster::VT_SIGNED_ENUM, signed_enum, Race::None);
- }
-
- #[inline]
- 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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Stat<'b >>>>) {
- 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) {
- self.fbb_.push_slot_always::<&Test>(Monster::VT_NATIVE_INLINE, native_inline);
- }
-
- #[inline]
- pub fn add_long_enum_non_enum_default(&mut self, long_enum_non_enum_default: LongEnum) {
- self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, long_enum_non_enum_default, Default::default());
- }
-
- #[inline]
- pub fn add_long_enum_normal_default(&mut self, long_enum_normal_default: LongEnum) {
- self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, long_enum_normal_default, LongEnum::LongOne);
- }
-
- #[inline]
- pub fn add_nan_default(&mut self, nan_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NAN_DEFAULT, nan_default, f32::NAN);
- }
-
- #[inline]
- pub fn add_inf_default(&mut self, inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_INF_DEFAULT, inf_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_positive_inf_default(&mut self, positive_inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, positive_inf_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_infinity_default(&mut self, infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_INFINITY_DEFAULT, infinity_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_positive_infinity_default(&mut self, positive_infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, positive_infinity_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_negative_inf_default(&mut self, negative_inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, negative_inf_default, f32::NEG_INFINITY);
- }
-
- #[inline]
- pub fn add_negative_infinity_default(&mut self, negative_infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, negative_infinity_default, f32::NEG_INFINITY);
- }
-
- #[inline]
- pub fn add_double_inf_default(&mut self, double_inf_default: f64) {
- self.fbb_.push_slot::<f64>(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> {
- let start = _fbb.start_table();
- MonsterBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_pos(&mut self, pos: &Vec3) {
+ self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
- let o = self.fbb_.end_table(self.start_);
- self.fbb_.required(o, Monster::VT_NAME,"name");
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_mana(&mut self, mana: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
+ }
+
+ #[inline]
+ pub fn add_hp(&mut self, hp: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
+ }
+
+ #[inline]
+ pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
+ }
+
+ #[inline]
+ pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
+ }
+
+ #[inline]
+ pub fn add_color(&mut self, color: Color) {
+ self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
+ }
+
+ #[inline]
+ pub fn add_test_type(&mut self, test_type: Any) {
+ self.fbb_.push_slot::<Any>(Monster::VT_TEST_TYPE, test_type, Any::NONE);
+ }
+
+ #[inline]
+ 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<::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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Monster<'b >>>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
+ }
+
+ #[inline]
+ pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset<Monster<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Monster>>(Monster::VT_ENEMY, enemy);
+ }
+
+ #[inline]
+ 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<Stat<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Stat>>(Monster::VT_TESTEMPTY, testempty);
+ }
+
+ #[inline]
+ pub fn add_testbool(&mut self, testbool: bool) {
+ self.fbb_.push_slot::<bool>(Monster::VT_TESTBOOL, testbool, false);
+ }
+
+ #[inline]
+ pub fn add_testhashs32_fnv1(&mut self, testhashs32_fnv1: i32) {
+ self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu32_fnv1(&mut self, testhashu32_fnv1: u32) {
+ self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs64_fnv1(&mut self, testhashs64_fnv1: i64) {
+ self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu64_fnv1(&mut self, testhashu64_fnv1: u64) {
+ self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs32_fnv1a(&mut self, testhashs32_fnv1a: i32) {
+ self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu32_fnv1a(&mut self, testhashu32_fnv1a: u32) {
+ self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs64_fnv1a(&mut self, testhashs64_fnv1a: i64) {
+ self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu64_fnv1a(&mut self, testhashu64_fnv1a: u64) {
+ self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
+ }
+
+ #[inline]
+ 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) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF, testf, 3.14159);
+ }
+
+ #[inline]
+ pub fn add_testf2(&mut self, testf2: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF2, testf2, 3.0);
+ }
+
+ #[inline]
+ pub fn add_testf3(&mut self, testf3: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF3, testf3, 0.0);
+ }
+
+ #[inline]
+ 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<::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<::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<::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<::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<::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<super::InParentNamespace<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
+ }
+
+ #[inline]
+ pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
+ 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::<u64>(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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
+ 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::<u64>(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<::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::<u64>(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<::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::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE);
+ }
+
+ #[inline]
+ 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::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE);
+ }
+
+ #[inline]
+ 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<::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::<Race>(Monster::VT_SIGNED_ENUM, signed_enum, Race::None);
+ }
+
+ #[inline]
+ 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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Stat<'b >>>>) {
+ 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) {
+ self.fbb_.push_slot_always::<&Test>(Monster::VT_NATIVE_INLINE, native_inline);
+ }
+
+ #[inline]
+ pub fn add_long_enum_non_enum_default(&mut self, long_enum_non_enum_default: LongEnum) {
+ self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, long_enum_non_enum_default, Default::default());
+ }
+
+ #[inline]
+ pub fn add_long_enum_normal_default(&mut self, long_enum_normal_default: LongEnum) {
+ self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, long_enum_normal_default, LongEnum::LongOne);
+ }
+
+ #[inline]
+ pub fn add_nan_default(&mut self, nan_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NAN_DEFAULT, nan_default, f32::NAN);
+ }
+
+ #[inline]
+ pub fn add_inf_default(&mut self, inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_INF_DEFAULT, inf_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_positive_inf_default(&mut self, positive_inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, positive_inf_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_infinity_default(&mut self, infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_INFINITY_DEFAULT, infinity_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_positive_infinity_default(&mut self, positive_infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, positive_infinity_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_negative_inf_default(&mut self, negative_inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, negative_inf_default, f32::NEG_INFINITY);
+ }
+
+ #[inline]
+ pub fn add_negative_infinity_default(&mut self, negative_infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, negative_infinity_default, f32::NEG_INFINITY);
+ }
+
+ #[inline]
+ pub fn add_double_inf_default(&mut self, double_inf_default: f64) {
+ self.fbb_.push_slot::<f64>(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> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ self.fbb_.required(o, Monster::VT_NAME,"name");
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("hp", &self.hp());
- ds.field("name", &self.name());
- ds.field("inventory", &self.inventory());
- ds.field("color", &self.color());
- ds.field("test_type", &self.test_type());
- match self.test_type() {
- Any::Monster => {
- if let Some(x) = self.test_as_monster() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- Any::TestSimpleTableWithEnum => {
- if let Some(x) = self.test_as_test_simple_table_with_enum() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- Any::MyGame_Example2_Monster => {
- if let Some(x) = self.test_as_my_game_example_2_monster() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("test", &x)
- },
- };
- ds.field("test4", &self.test4());
- ds.field("testarrayofstring", &self.testarrayofstring());
- ds.field("testarrayoftables", &self.testarrayoftables());
- ds.field("enemy", &self.enemy());
- ds.field("testnestedflatbuffer", &self.testnestedflatbuffer());
- ds.field("testempty", &self.testempty());
- ds.field("testbool", &self.testbool());
- ds.field("testhashs32_fnv1", &self.testhashs32_fnv1());
- ds.field("testhashu32_fnv1", &self.testhashu32_fnv1());
- ds.field("testhashs64_fnv1", &self.testhashs64_fnv1());
- ds.field("testhashu64_fnv1", &self.testhashu64_fnv1());
- ds.field("testhashs32_fnv1a", &self.testhashs32_fnv1a());
- ds.field("testhashu32_fnv1a", &self.testhashu32_fnv1a());
- ds.field("testhashs64_fnv1a", &self.testhashs64_fnv1a());
- ds.field("testhashu64_fnv1a", &self.testhashu64_fnv1a());
- ds.field("testarrayofbools", &self.testarrayofbools());
- ds.field("testf", &self.testf());
- ds.field("testf2", &self.testf2());
- ds.field("testf3", &self.testf3());
- ds.field("testarrayofstring2", &self.testarrayofstring2());
- ds.field("testarrayofsortedstruct", &self.testarrayofsortedstruct());
- ds.field("flex", &self.flex());
- ds.field("test5", &self.test5());
- ds.field("vector_of_longs", &self.vector_of_longs());
- ds.field("vector_of_doubles", &self.vector_of_doubles());
- ds.field("parent_namespace_test", &self.parent_namespace_test());
- ds.field("vector_of_referrables", &self.vector_of_referrables());
- ds.field("single_weak_reference", &self.single_weak_reference());
- ds.field("vector_of_weak_references", &self.vector_of_weak_references());
- ds.field("vector_of_strong_referrables", &self.vector_of_strong_referrables());
- ds.field("co_owning_reference", &self.co_owning_reference());
- ds.field("vector_of_co_owning_references", &self.vector_of_co_owning_references());
- ds.field("non_owning_reference", &self.non_owning_reference());
- ds.field("vector_of_non_owning_references", &self.vector_of_non_owning_references());
- ds.field("any_unique_type", &self.any_unique_type());
- match self.any_unique_type() {
- AnyUniqueAliases::M => {
- if let Some(x) = self.any_unique_as_m() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyUniqueAliases::TS => {
- if let Some(x) = self.any_unique_as_ts() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyUniqueAliases::M2 => {
- if let Some(x) = self.any_unique_as_m2() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("any_unique", &x)
- },
- };
- ds.field("any_ambiguous_type", &self.any_ambiguous_type());
- match self.any_ambiguous_type() {
- AnyAmbiguousAliases::M1 => {
- if let Some(x) = self.any_ambiguous_as_m1() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyAmbiguousAliases::M2 => {
- if let Some(x) = self.any_ambiguous_as_m2() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyAmbiguousAliases::M3 => {
- if let Some(x) = self.any_ambiguous_as_m3() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("any_ambiguous", &x)
- },
- };
- ds.field("vector_of_enums", &self.vector_of_enums());
- ds.field("signed_enum", &self.signed_enum());
- ds.field("testrequirednestedflatbuffer", &self.testrequirednestedflatbuffer());
- ds.field("scalar_key_sorted_tables", &self.scalar_key_sorted_tables());
- ds.field("native_inline", &self.native_inline());
- ds.field("long_enum_non_enum_default", &self.long_enum_non_enum_default());
- ds.field("long_enum_normal_default", &self.long_enum_normal_default());
- ds.field("nan_default", &self.nan_default());
- ds.field("inf_default", &self.inf_default());
- ds.field("positive_inf_default", &self.positive_inf_default());
- ds.field("infinity_default", &self.infinity_default());
- ds.field("positive_infinity_default", &self.positive_infinity_default());
- ds.field("negative_inf_default", &self.negative_inf_default());
- ds.field("negative_infinity_default", &self.negative_infinity_default());
- ds.field("double_inf_default", &self.double_inf_default());
- ds.finish()
- }
+ 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());
+ ds.field("hp", &self.hp());
+ ds.field("name", &self.name());
+ ds.field("inventory", &self.inventory());
+ ds.field("color", &self.color());
+ ds.field("test_type", &self.test_type());
+ match self.test_type() {
+ Any::Monster => {
+ if let Some(x) = self.test_as_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::TestSimpleTableWithEnum => {
+ if let Some(x) = self.test_as_test_simple_table_with_enum() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::MyGame_Example2_Monster => {
+ if let Some(x) = self.test_as_my_game_example_2_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("test", &x)
+ },
+ };
+ ds.field("test4", &self.test4());
+ ds.field("testarrayofstring", &self.testarrayofstring());
+ ds.field("testarrayoftables", &self.testarrayoftables());
+ ds.field("enemy", &self.enemy());
+ ds.field("testnestedflatbuffer", &self.testnestedflatbuffer());
+ ds.field("testempty", &self.testempty());
+ ds.field("testbool", &self.testbool());
+ ds.field("testhashs32_fnv1", &self.testhashs32_fnv1());
+ ds.field("testhashu32_fnv1", &self.testhashu32_fnv1());
+ ds.field("testhashs64_fnv1", &self.testhashs64_fnv1());
+ ds.field("testhashu64_fnv1", &self.testhashu64_fnv1());
+ ds.field("testhashs32_fnv1a", &self.testhashs32_fnv1a());
+ ds.field("testhashu32_fnv1a", &self.testhashu32_fnv1a());
+ ds.field("testhashs64_fnv1a", &self.testhashs64_fnv1a());
+ ds.field("testhashu64_fnv1a", &self.testhashu64_fnv1a());
+ ds.field("testarrayofbools", &self.testarrayofbools());
+ ds.field("testf", &self.testf());
+ ds.field("testf2", &self.testf2());
+ ds.field("testf3", &self.testf3());
+ ds.field("testarrayofstring2", &self.testarrayofstring2());
+ ds.field("testarrayofsortedstruct", &self.testarrayofsortedstruct());
+ ds.field("flex", &self.flex());
+ ds.field("test5", &self.test5());
+ ds.field("vector_of_longs", &self.vector_of_longs());
+ ds.field("vector_of_doubles", &self.vector_of_doubles());
+ ds.field("parent_namespace_test", &self.parent_namespace_test());
+ ds.field("vector_of_referrables", &self.vector_of_referrables());
+ ds.field("single_weak_reference", &self.single_weak_reference());
+ ds.field("vector_of_weak_references", &self.vector_of_weak_references());
+ ds.field("vector_of_strong_referrables", &self.vector_of_strong_referrables());
+ ds.field("co_owning_reference", &self.co_owning_reference());
+ ds.field("vector_of_co_owning_references", &self.vector_of_co_owning_references());
+ ds.field("non_owning_reference", &self.non_owning_reference());
+ ds.field("vector_of_non_owning_references", &self.vector_of_non_owning_references());
+ ds.field("any_unique_type", &self.any_unique_type());
+ match self.any_unique_type() {
+ AnyUniqueAliases::M => {
+ if let Some(x) = self.any_unique_as_m() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::TS => {
+ if let Some(x) = self.any_unique_as_ts() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::M2 => {
+ if let Some(x) = self.any_unique_as_m2() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_unique", &x)
+ },
+ };
+ ds.field("any_ambiguous_type", &self.any_ambiguous_type());
+ match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::M1 => {
+ if let Some(x) = self.any_ambiguous_as_m1() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M2 => {
+ if let Some(x) = self.any_ambiguous_as_m2() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M3 => {
+ if let Some(x) = self.any_ambiguous_as_m3() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_ambiguous", &x)
+ },
+ };
+ ds.field("vector_of_enums", &self.vector_of_enums());
+ ds.field("signed_enum", &self.signed_enum());
+ ds.field("testrequirednestedflatbuffer", &self.testrequirednestedflatbuffer());
+ ds.field("scalar_key_sorted_tables", &self.scalar_key_sorted_tables());
+ ds.field("native_inline", &self.native_inline());
+ ds.field("long_enum_non_enum_default", &self.long_enum_non_enum_default());
+ ds.field("long_enum_normal_default", &self.long_enum_normal_default());
+ ds.field("nan_default", &self.nan_default());
+ ds.field("inf_default", &self.inf_default());
+ ds.field("positive_inf_default", &self.positive_inf_default());
+ ds.field("infinity_default", &self.infinity_default());
+ ds.field("positive_infinity_default", &self.positive_infinity_default());
+ ds.field("negative_inf_default", &self.negative_inf_default());
+ ds.field("negative_infinity_default", &self.negative_infinity_default());
+ ds.field("double_inf_default", &self.double_inf_default());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
- pub pos: Option<Vec3T>,
- pub mana: i16,
- pub hp: i16,
- pub name: alloc::string::String,
- pub inventory: Option<alloc::vec::Vec<u8>>,
- pub color: Color,
- pub test: AnyT,
- pub test4: Option<alloc::vec::Vec<TestT>>,
- pub testarrayofstring: Option<alloc::vec::Vec<alloc::string::String>>,
- pub testarrayoftables: Option<alloc::vec::Vec<MonsterT>>,
- pub enemy: Option<alloc::boxed::Box<MonsterT>>,
- pub testnestedflatbuffer: Option<alloc::vec::Vec<u8>>,
- pub testempty: Option<alloc::boxed::Box<StatT>>,
- pub testbool: bool,
- pub testhashs32_fnv1: i32,
- pub testhashu32_fnv1: u32,
- pub testhashs64_fnv1: i64,
- pub testhashu64_fnv1: u64,
- pub testhashs32_fnv1a: i32,
- pub testhashu32_fnv1a: u32,
- pub testhashs64_fnv1a: i64,
- pub testhashu64_fnv1a: u64,
- pub testarrayofbools: Option<alloc::vec::Vec<bool>>,
- pub testf: f32,
- pub testf2: f32,
- pub testf3: f32,
- pub testarrayofstring2: Option<alloc::vec::Vec<alloc::string::String>>,
- pub testarrayofsortedstruct: Option<alloc::vec::Vec<AbilityT>>,
- pub flex: Option<alloc::vec::Vec<u8>>,
- pub test5: Option<alloc::vec::Vec<TestT>>,
- pub vector_of_longs: Option<alloc::vec::Vec<i64>>,
- pub vector_of_doubles: Option<alloc::vec::Vec<f64>>,
- pub parent_namespace_test: Option<alloc::boxed::Box<super::InParentNamespaceT>>,
- pub vector_of_referrables: Option<alloc::vec::Vec<ReferrableT>>,
- pub single_weak_reference: u64,
- pub vector_of_weak_references: Option<alloc::vec::Vec<u64>>,
- pub vector_of_strong_referrables: Option<alloc::vec::Vec<ReferrableT>>,
- pub co_owning_reference: u64,
- pub vector_of_co_owning_references: Option<alloc::vec::Vec<u64>>,
- pub non_owning_reference: u64,
- pub vector_of_non_owning_references: Option<alloc::vec::Vec<u64>>,
- pub any_unique: AnyUniqueAliasesT,
- pub any_ambiguous: AnyAmbiguousAliasesT,
- pub vector_of_enums: Option<alloc::vec::Vec<Color>>,
- pub signed_enum: Race,
- pub testrequirednestedflatbuffer: Option<alloc::vec::Vec<u8>>,
- pub scalar_key_sorted_tables: Option<alloc::vec::Vec<StatT>>,
- pub native_inline: Option<TestT>,
- pub long_enum_non_enum_default: LongEnum,
- pub long_enum_normal_default: LongEnum,
- pub nan_default: f32,
- pub inf_default: f32,
- pub positive_inf_default: f32,
- pub infinity_default: f32,
- pub positive_infinity_default: f32,
- pub negative_inf_default: f32,
- pub negative_infinity_default: f32,
- pub double_inf_default: f64,
+ pub pos: Option<Vec3T>,
+ pub mana: i16,
+ pub hp: i16,
+ pub name: alloc::string::String,
+ pub inventory: Option<alloc::vec::Vec<u8>>,
+ pub color: Color,
+ pub test: AnyT,
+ pub test4: Option<alloc::vec::Vec<TestT>>,
+ pub testarrayofstring: Option<alloc::vec::Vec<alloc::string::String>>,
+ pub testarrayoftables: Option<alloc::vec::Vec<MonsterT>>,
+ pub enemy: Option<alloc::boxed::Box<MonsterT>>,
+ pub testnestedflatbuffer: Option<alloc::vec::Vec<u8>>,
+ pub testempty: Option<alloc::boxed::Box<StatT>>,
+ pub testbool: bool,
+ pub testhashs32_fnv1: i32,
+ pub testhashu32_fnv1: u32,
+ pub testhashs64_fnv1: i64,
+ pub testhashu64_fnv1: u64,
+ pub testhashs32_fnv1a: i32,
+ pub testhashu32_fnv1a: u32,
+ pub testhashs64_fnv1a: i64,
+ pub testhashu64_fnv1a: u64,
+ pub testarrayofbools: Option<alloc::vec::Vec<bool>>,
+ pub testf: f32,
+ pub testf2: f32,
+ pub testf3: f32,
+ pub testarrayofstring2: Option<alloc::vec::Vec<alloc::string::String>>,
+ pub testarrayofsortedstruct: Option<alloc::vec::Vec<AbilityT>>,
+ pub flex: Option<alloc::vec::Vec<u8>>,
+ pub test5: Option<alloc::vec::Vec<TestT>>,
+ pub vector_of_longs: Option<alloc::vec::Vec<i64>>,
+ pub vector_of_doubles: Option<alloc::vec::Vec<f64>>,
+ pub parent_namespace_test: Option<alloc::boxed::Box<super::InParentNamespaceT>>,
+ pub vector_of_referrables: Option<alloc::vec::Vec<ReferrableT>>,
+ pub single_weak_reference: u64,
+ pub vector_of_weak_references: Option<alloc::vec::Vec<u64>>,
+ pub vector_of_strong_referrables: Option<alloc::vec::Vec<ReferrableT>>,
+ pub co_owning_reference: u64,
+ pub vector_of_co_owning_references: Option<alloc::vec::Vec<u64>>,
+ pub non_owning_reference: u64,
+ pub vector_of_non_owning_references: Option<alloc::vec::Vec<u64>>,
+ pub any_unique: AnyUniqueAliasesT,
+ pub any_ambiguous: AnyAmbiguousAliasesT,
+ pub vector_of_enums: Option<alloc::vec::Vec<Color>>,
+ pub signed_enum: Race,
+ pub testrequirednestedflatbuffer: Option<alloc::vec::Vec<u8>>,
+ pub scalar_key_sorted_tables: Option<alloc::vec::Vec<StatT>>,
+ pub native_inline: Option<TestT>,
+ pub long_enum_non_enum_default: LongEnum,
+ pub long_enum_normal_default: LongEnum,
+ pub nan_default: f32,
+ pub inf_default: f32,
+ pub positive_inf_default: f32,
+ pub infinity_default: f32,
+ pub positive_infinity_default: f32,
+ pub negative_inf_default: f32,
+ pub negative_infinity_default: f32,
+ pub double_inf_default: f64,
}
impl Default for MonsterT {
- fn default() -> Self {
- Self {
- pos: None,
- mana: 150,
- hp: 100,
- name: alloc::string::ToString::to_string(""),
- inventory: None,
- color: Color::Blue,
- test: AnyT::NONE,
- test4: None,
- testarrayofstring: None,
- testarrayoftables: None,
- enemy: None,
- testnestedflatbuffer: None,
- testempty: None,
- testbool: false,
- testhashs32_fnv1: 0,
- testhashu32_fnv1: 0,
- testhashs64_fnv1: 0,
- testhashu64_fnv1: 0,
- testhashs32_fnv1a: 0,
- testhashu32_fnv1a: 0,
- testhashs64_fnv1a: 0,
- testhashu64_fnv1a: 0,
- testarrayofbools: None,
- testf: 3.14159,
- testf2: 3.0,
- testf3: 0.0,
- testarrayofstring2: None,
- testarrayofsortedstruct: None,
- flex: None,
- test5: None,
- vector_of_longs: None,
- vector_of_doubles: None,
- parent_namespace_test: None,
- vector_of_referrables: None,
- single_weak_reference: 0,
- vector_of_weak_references: None,
- vector_of_strong_referrables: None,
- co_owning_reference: 0,
- vector_of_co_owning_references: None,
- non_owning_reference: 0,
- vector_of_non_owning_references: None,
- any_unique: AnyUniqueAliasesT::NONE,
- any_ambiguous: AnyAmbiguousAliasesT::NONE,
- vector_of_enums: None,
- signed_enum: Race::None,
- testrequirednestedflatbuffer: None,
- scalar_key_sorted_tables: None,
- native_inline: None,
- long_enum_non_enum_default: Default::default(),
- long_enum_normal_default: LongEnum::LongOne,
- nan_default: f32::NAN,
- inf_default: f32::INFINITY,
- positive_inf_default: f32::INFINITY,
- infinity_default: f32::INFINITY,
- positive_infinity_default: f32::INFINITY,
- negative_inf_default: f32::NEG_INFINITY,
- negative_infinity_default: f32::NEG_INFINITY,
- double_inf_default: f64::INFINITY,
+ fn default() -> Self {
+ Self {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: alloc::string::ToString::to_string(""),
+ inventory: None,
+ color: Color::Blue,
+ test: AnyT::NONE,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique: AnyUniqueAliasesT::NONE,
+ any_ambiguous: AnyAmbiguousAliasesT::NONE,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ nan_default: f32::NAN,
+ inf_default: f32::INFINITY,
+ positive_inf_default: f32::INFINITY,
+ infinity_default: f32::INFINITY,
+ positive_infinity_default: f32::INFINITY,
+ negative_inf_default: f32::NEG_INFINITY,
+ negative_infinity_default: f32::NEG_INFINITY,
+ double_inf_default: f64::INFINITY,
+ }
}
- }
}
impl MonsterT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
- let pos_tmp = self.pos.as_ref().map(|x| x.pack());
- let pos = pos_tmp.as_ref();
- let mana = self.mana;
- let hp = self.hp;
- let name = Some({
- let x = &self.name;
- _fbb.create_string(x)
- });
- let inventory = self.inventory.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let color = self.color;
- let test_type = self.test.any_type();
- let test = self.test.pack(_fbb);
- let test4 = self.test4.as_ref().map(|x|{
- let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
- });
- let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{
- 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: 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)
- });
- let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let testempty = self.testempty.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let testbool = self.testbool;
- let testhashs32_fnv1 = self.testhashs32_fnv1;
- let testhashu32_fnv1 = self.testhashu32_fnv1;
- let testhashs64_fnv1 = self.testhashs64_fnv1;
- let testhashu64_fnv1 = self.testhashu64_fnv1;
- let testhashs32_fnv1a = self.testhashs32_fnv1a;
- let testhashu32_fnv1a = self.testhashu32_fnv1a;
- let testhashs64_fnv1a = self.testhashs64_fnv1a;
- let testhashu64_fnv1a = self.testhashu64_fnv1a;
- let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let testf = self.testf;
- let testf2 = self.testf2;
- let testf3 = self.testf3;
- let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{
- let w: 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: 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: 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)
- });
- let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{
- let w: 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: 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|{
- _fbb.create_vector(x)
- });
- let non_owning_reference = self.non_owning_reference;
- let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let any_unique_type = self.any_unique.any_unique_aliases_type();
- let any_unique = self.any_unique.pack(_fbb);
- let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type();
- let any_ambiguous = self.any_ambiguous.pack(_fbb);
- let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let signed_enum = self.signed_enum;
- let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{
- let w: 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();
- let long_enum_non_enum_default = self.long_enum_non_enum_default;
- let long_enum_normal_default = self.long_enum_normal_default;
- let nan_default = self.nan_default;
- let inf_default = self.inf_default;
- let positive_inf_default = self.positive_inf_default;
- let infinity_default = self.infinity_default;
- let positive_infinity_default = self.positive_infinity_default;
- let negative_inf_default = self.negative_inf_default;
- let negative_infinity_default = self.negative_infinity_default;
- let double_inf_default = self.double_inf_default;
- Monster::create(_fbb, &MonsterArgs{
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- test_type,
- test,
- test4,
- testarrayofstring,
- testarrayoftables,
- enemy,
- testnestedflatbuffer,
- testempty,
- testbool,
- testhashs32_fnv1,
- testhashu32_fnv1,
- testhashs64_fnv1,
- testhashu64_fnv1,
- testhashs32_fnv1a,
- testhashu32_fnv1a,
- testhashs64_fnv1a,
- testhashu64_fnv1a,
- testarrayofbools,
- testf,
- testf2,
- testf3,
- testarrayofstring2,
- testarrayofsortedstruct,
- flex,
- test5,
- vector_of_longs,
- vector_of_doubles,
- parent_namespace_test,
- vector_of_referrables,
- single_weak_reference,
- vector_of_weak_references,
- vector_of_strong_referrables,
- co_owning_reference,
- vector_of_co_owning_references,
- non_owning_reference,
- vector_of_non_owning_references,
- any_unique_type,
- any_unique,
- any_ambiguous_type,
- any_ambiguous,
- vector_of_enums,
- signed_enum,
- testrequirednestedflatbuffer,
- scalar_key_sorted_tables,
- native_inline,
- long_enum_non_enum_default,
- long_enum_normal_default,
- nan_default,
- inf_default,
- positive_inf_default,
- infinity_default,
- positive_infinity_default,
- negative_inf_default,
- negative_infinity_default,
- double_inf_default,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
+ let pos_tmp = self.pos.as_ref().map(|x| x.pack());
+ let pos = pos_tmp.as_ref();
+ let mana = self.mana;
+ let hp = self.hp;
+ let name = Some({
+ let x = &self.name;
+ _fbb.create_string(x)
+ });
+ let inventory = self.inventory.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let color = self.color;
+ let test_type = self.test.any_type();
+ let test = self.test.pack(_fbb);
+ let test4 = self.test4.as_ref().map(|x|{
+ let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{
+ 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: 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)
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testempty = self.testempty.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let testbool = self.testbool;
+ let testhashs32_fnv1 = self.testhashs32_fnv1;
+ let testhashu32_fnv1 = self.testhashu32_fnv1;
+ let testhashs64_fnv1 = self.testhashs64_fnv1;
+ let testhashu64_fnv1 = self.testhashu64_fnv1;
+ let testhashs32_fnv1a = self.testhashs32_fnv1a;
+ let testhashu32_fnv1a = self.testhashu32_fnv1a;
+ let testhashs64_fnv1a = self.testhashs64_fnv1a;
+ let testhashu64_fnv1a = self.testhashu64_fnv1a;
+ let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testf = self.testf;
+ let testf2 = self.testf2;
+ let testf3 = self.testf3;
+ let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{
+ let w: 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: 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: 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)
+ });
+ let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{
+ let w: 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: 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|{
+ _fbb.create_vector(x)
+ });
+ let non_owning_reference = self.non_owning_reference;
+ let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let any_unique_type = self.any_unique.any_unique_aliases_type();
+ let any_unique = self.any_unique.pack(_fbb);
+ let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type();
+ let any_ambiguous = self.any_ambiguous.pack(_fbb);
+ let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let signed_enum = self.signed_enum;
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{
+ let w: 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();
+ let long_enum_non_enum_default = self.long_enum_non_enum_default;
+ let long_enum_normal_default = self.long_enum_normal_default;
+ let nan_default = self.nan_default;
+ let inf_default = self.inf_default;
+ let positive_inf_default = self.positive_inf_default;
+ let infinity_default = self.infinity_default;
+ let positive_infinity_default = self.positive_infinity_default;
+ let negative_inf_default = self.negative_inf_default;
+ let negative_infinity_default = self.negative_infinity_default;
+ let double_inf_default = self.double_inf_default;
+ Monster::create(_fbb, &MonsterArgs{
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test_type,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ nan_default,
+ inf_default,
+ positive_inf_default,
+ infinity_default,
+ positive_infinity_default,
+ negative_inf_default,
+ negative_infinity_default,
+ double_inf_default,
+ })
+ }
}
/// Verifies that a buffer of bytes contains a `Monster`
@@ -2063,7 +2063,7 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<Monster>(buf)
+ ::flatbuffers::root::<Monster>(buf)
}
/// Verifies that a buffer of bytes contains a size prefixed
@@ -2074,7 +2074,7 @@
/// `size_prefixed_root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<Monster>(buf)
+ ::flatbuffers::size_prefixed_root::<Monster>(buf)
}
/// Verifies, with the given options, that a buffer of bytes
@@ -2085,10 +2085,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
/// Verifies, with the given verifier options, that a buffer of
@@ -2099,10 +2099,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
@@ -2110,7 +2110,7 @@
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
@@ -2118,19 +2118,19 @@
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
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";
@@ -2138,11 +2138,15 @@
#[inline]
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<Monster<'a>>) {
- fbb.finish(root, Some(MONSTER_IDENTIFIER));
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ 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<Monster<'a>>) {
- fbb.finish_size_prefixed(root, Some(MONSTER_IDENTIFIER));
+pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ fbb.finish_size_prefixed(root, 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 013ceb3..1851654 100644
--- a/tests/monster_test/my_game/example/race_generated.rs
+++ b/tests/monster_test/my_game/example/race_generated.rs
@@ -12,10 +12,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_RACE: [Race; 4] = [
- Race::None,
- Race::Human,
- Race::Dwarf,
- Race::Elf,
+ Race::None,
+ Race::Human,
+ Race::Dwarf,
+ Race::Elf,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -24,50 +24,50 @@
#[allow(non_upper_case_globals)]
impl Race {
- pub const None: Self = Self(-1);
- pub const Human: Self = Self(0);
- pub const Dwarf: Self = Self(1);
- pub const Elf: Self = Self(2);
+ pub const None: Self = Self(-1);
+ pub const Human: Self = Self(0);
+ pub const Dwarf: Self = Self(1);
+ pub const Elf: Self = Self(2);
- pub const ENUM_MIN: i8 = -1;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::None,
- Self::Human,
- Self::Dwarf,
- Self::Elf,
- ];
+ pub const ENUM_MIN: i8 = -1;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::None,
+ Self::Human,
+ Self::Dwarf,
+ Self::Elf,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::None => Some("None"),
- Self::Human => Some("Human"),
- Self::Dwarf => Some("Dwarf"),
- Self::Elf => Some("Elf"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::None => Some("None"),
+ Self::Human => Some("Human"),
+ Self::Dwarf => Some("Dwarf"),
+ Self::Elf => Some("Elf"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for Race {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Race {
@@ -80,28 +80,28 @@
}
impl ::flatbuffers::EndianScalar for Race {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Race {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
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 09832db..38e259a 100644
--- a/tests/monster_test/my_game/example/referrable_generated.rs
+++ b/tests/monster_test/my_game/example/referrable_generated.rs
@@ -7,77 +7,77 @@
#[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> {
- type Inner = Referrable<'a>;
+ type Inner = Referrable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args ReferrableArgs
- ) -> ::flatbuffers::WIPOffset<Referrable<'bldr>> {
- let mut builder = ReferrableBuilder::new(_fbb);
- builder.add_id(args.id);
- builder.finish()
- }
-
- pub fn unpack(&self) -> ReferrableT {
- let id = self.id();
- ReferrableT {
- id,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Referrable"
}
- }
- #[inline]
- pub fn id(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Referrable { _tab: table }
+ }
- #[inline]
- pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
- self.id() < o.id()
- }
+ #[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>,
+ args: &'args ReferrableArgs
+ ) -> ::flatbuffers::WIPOffset<Referrable<'bldr>> {
+ let mut builder = ReferrableBuilder::new(_fbb);
+ builder.add_id(args.id);
+ builder.finish()
+ }
- #[inline]
- pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
- let key = self.id();
- key.cmp(&val)
- }
+ pub fn unpack(&self) -> ReferrableT {
+ let id = self.id();
+ ReferrableT {
+ id,
+ }
+ }
+
+ #[inline]
+ pub fn id(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
}
impl ::flatbuffers::Verifiable for Referrable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<u64>("id", Self::VT_ID, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<u64>("id", Self::VT_ID, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct ReferrableArgs {
@@ -85,71 +85,71 @@
}
impl<'a> Default for ReferrableArgs {
- #[inline]
- fn default() -> Self {
- ReferrableArgs {
- id: 0,
+ #[inline]
+ fn default() -> Self {
+ ReferrableArgs {
+ id: 0,
+ }
}
- }
}
pub struct ReferrableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<u64>(Referrable::VT_ID, id, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- ReferrableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_id(&mut self, id: u64) {
+ self.fbb_.push_slot::<u64>(Referrable::VT_ID, id, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ ReferrableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ReferrableT {
- pub id: u64,
+ pub id: u64,
}
impl Default for ReferrableT {
- fn default() -> Self {
- Self {
- id: 0,
+ fn default() -> Self {
+ Self {
+ id: 0,
+ }
}
- }
}
impl ReferrableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Referrable<'b>> {
- let id = self.id;
- Referrable::create(_fbb, &ReferrableArgs{
- id,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Referrable<'b>> {
+ 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 223631b..9394613 100644
--- a/tests/monster_test/my_game/example/stat_generated.rs
+++ b/tests/monster_test/my_game/example/stat_generated.rs
@@ -7,105 +7,105 @@
#[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> {
- type Inner = Stat<'a>;
+ type Inner = Stat<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args StatArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Stat<'bldr>> {
- let mut builder = StatBuilder::new(_fbb);
- builder.add_val(args.val);
- if let Some(x) = args.id { builder.add_id(x); }
- builder.add_count(args.count);
- builder.finish()
- }
-
- pub fn unpack(&self) -> StatT {
- let id = self.id().map(|x| {
- alloc::string::ToString::to_string(x)
- });
- let val = self.val();
- let count = self.count();
- StatT {
- id,
- val,
- count,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Stat"
}
- }
- #[inline]
- pub fn id(&self) -> Option<&'a str> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Stat { _tab: table }
+ }
- #[inline]
- pub fn val(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()}
- }
+ #[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>,
+ args: &'args StatArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Stat<'bldr>> {
+ let mut builder = StatBuilder::new(_fbb);
+ builder.add_val(args.val);
+ if let Some(x) = args.id { builder.add_id(x); }
+ builder.add_count(args.count);
+ builder.finish()
+ }
- #[inline]
- pub fn count(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()}
- }
+ pub fn unpack(&self) -> StatT {
+ let id = self.id().map(|x| {
+ alloc::string::ToString::to_string(x)
+ });
+ let val = self.val();
+ let count = self.count();
+ StatT {
+ id,
+ val,
+ count,
+ }
+ }
- #[inline]
- pub fn key_compare_less_than(&self, o: &Stat) -> bool {
- self.count() < o.count()
- }
+ #[inline]
+ pub fn id(&self) -> Option<&'a str> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
+ }
- #[inline]
- pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
- let key = self.count();
- key.cmp(&val)
- }
+ #[inline]
+ pub fn val(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn count(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Stat) -> bool {
+ self.count() < o.count()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
+ let key = self.count();
+ key.cmp(&val)
+ }
}
impl ::flatbuffers::Verifiable for Stat<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
- .visit_field::<i64>("val", Self::VT_VAL, false)?
- .visit_field::<u16>("count", Self::VT_COUNT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
+ .visit_field::<i64>("val", Self::VT_VAL, false)?
+ .visit_field::<u16>("count", Self::VT_COUNT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct StatArgs<'a> {
@@ -115,95 +115,95 @@
}
impl<'a> Default for StatArgs<'a> {
- #[inline]
- fn default() -> Self {
- StatArgs {
- id: None,
- val: 0,
- count: 0,
+ #[inline]
+ fn default() -> Self {
+ StatArgs {
+ id: None,
+ val: 0,
+ count: 0,
+ }
}
- }
}
pub struct StatBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<::flatbuffers::WIPOffset<_>>(Stat::VT_ID, id);
- }
-
- #[inline]
- pub fn add_val(&mut self, val: i64) {
- self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0);
- }
-
- #[inline]
- pub fn add_count(&mut self, count: u16) {
- self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- StatBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ 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 finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_val(&mut self, val: i64) {
+ self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0);
+ }
+
+ #[inline]
+ pub fn add_count(&mut self, count: u16) {
+ self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ StatBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("count", &self.count());
- ds.finish()
- }
+ 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());
+ ds.field("count", &self.count());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct StatT {
- pub id: Option<alloc::string::String>,
- pub val: i64,
- pub count: u16,
+ pub id: Option<alloc::string::String>,
+ pub val: i64,
+ pub count: u16,
}
impl Default for StatT {
- fn default() -> Self {
- Self {
- id: None,
- val: 0,
- count: 0,
+ fn default() -> Self {
+ Self {
+ id: None,
+ val: 0,
+ count: 0,
+ }
}
- }
}
impl StatT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Stat<'b>> {
- let id = self.id.as_ref().map(|x|{
- _fbb.create_string(x)
- });
- let val = self.val;
- let count = self.count;
- Stat::create(_fbb, &StatArgs{
- id,
- val,
- count,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Stat<'b>> {
+ let id = self.id.as_ref().map(|x|{
+ _fbb.create_string(x)
+ });
+ let val = self.val;
+ let count = self.count;
+ Stat::create(_fbb, &StatArgs{
+ id,
+ val,
+ count,
+ })
+ }
}
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 b957d26..f0d803f 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
@@ -8,40 +8,40 @@
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructs(pub [u8; 20]);
-impl Default for StructOfStructs {
- fn default() -> Self {
- Self([0; 20])
- }
+impl Default for StructOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
}
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())
- .field("c", &self.c())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("StructOfStructs")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .field("c", &self.c())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs {
- type Inner = &'a StructOfStructs;
+ type Inner = &'a StructOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a StructOfStructs>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a StructOfStructs>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructs {
- type Inner = &'a StructOfStructs;
+ type Inner = &'a StructOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for StructOfStructs {
@@ -60,90 +60,90 @@
}
impl<'a> ::flatbuffers::Verifiable for StructOfStructs {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> StructOfStructs {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: &Ability,
- b: &Test,
- c: &Ability,
- ) -> Self {
- let mut s = Self([0; 20]);
- s.set_a(a);
- s.set_b(b);
- s.set_c(c);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.StructOfStructs"
- }
-
- pub fn a(&self) -> &Ability {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_a(&mut self, x: &Ability) {
- self.0[0..0 + 8].copy_from_slice(&x.0)
- }
-
- pub fn b(&self) -> &Test {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[8..].as_ptr() as *const Test) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_b(&mut self, x: &Test) {
- self.0[8..8 + 4].copy_from_slice(&x.0)
- }
-
- pub fn c(&self) -> &Ability {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_c(&mut self, x: &Ability) {
- self.0[12..12 + 8].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> StructOfStructsT {
- StructOfStructsT {
- a: self.a().unpack(),
- b: self.b().unpack(),
- c: self.c().unpack(),
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &Ability,
+ b: &Test,
+ c: &Ability,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s.set_b(b);
+ s.set_c(c);
+ s
}
- }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructs"
+ }
+
+ pub fn a(&self) -> &Ability {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &Ability) {
+ self.0[0..0 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn b(&self) -> &Test {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[8..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_b(&mut self, x: &Test) {
+ self.0[8..8 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn c(&self) -> &Ability {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_c(&mut self, x: &Ability) {
+ self.0[12..12 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsT {
+ StructOfStructsT {
+ a: self.a().unpack(),
+ b: self.b().unpack(),
+ c: self.c().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StructOfStructsT {
- pub a: AbilityT,
- pub b: TestT,
- pub c: AbilityT,
+ pub a: AbilityT,
+ pub b: TestT,
+ pub c: AbilityT,
}
impl StructOfStructsT {
- pub fn pack(&self) -> StructOfStructs {
- StructOfStructs::new(
- &self.a.pack(),
- &self.b.pack(),
- &self.c.pack(),
- )
- }
+ pub fn pack(&self) -> StructOfStructs {
+ StructOfStructs::new(
+ &self.a.pack(),
+ &self.b.pack(),
+ &self.c.pack(),
+ )
+ }
}
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 34a4832..1d88878 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
@@ -8,38 +8,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructsOfStructs(pub [u8; 20]);
-impl Default for StructOfStructsOfStructs {
- fn default() -> Self {
- Self([0; 20])
- }
+impl Default for StructOfStructsOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a StructOfStructsOfStructs;
+ type Inner = &'a StructOfStructsOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs {
- type Inner = &'a StructOfStructsOfStructs;
+ type Inner = &'a StructOfStructsOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs {
@@ -58,56 +58,56 @@
}
impl<'a> ::flatbuffers::Verifiable for StructOfStructsOfStructs {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> StructOfStructsOfStructs {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: &StructOfStructs,
- ) -> Self {
- let mut s = Self([0; 20]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.StructOfStructsOfStructs"
- }
-
- pub fn a(&self) -> &StructOfStructs {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_a(&mut self, x: &StructOfStructs) {
- self.0[0..0 + 20].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> StructOfStructsOfStructsT {
- StructOfStructsOfStructsT {
- a: self.a().unpack(),
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &StructOfStructs,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s
}
- }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructsOfStructs"
+ }
+
+ pub fn a(&self) -> &StructOfStructs {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &StructOfStructs) {
+ self.0[0..0 + 20].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsOfStructsT {
+ StructOfStructsOfStructsT {
+ a: self.a().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StructOfStructsOfStructsT {
- pub a: StructOfStructsT,
+ pub a: StructOfStructsT,
}
impl StructOfStructsOfStructsT {
- pub fn pack(&self) -> StructOfStructsOfStructs {
- StructOfStructsOfStructs::new(
- &self.a.pack(),
- )
- }
+ pub fn pack(&self) -> StructOfStructsOfStructs {
+ StructOfStructsOfStructs::new(
+ &self.a.pack(),
+ )
+ }
}
diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs
index a5984a9..b713764 100644
--- a/tests/monster_test/my_game/example/test_generated.rs
+++ b/tests/monster_test/my_game/example/test_generated.rs
@@ -8,39 +8,39 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Test(pub [u8; 4]);
-impl Default for Test {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Test {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Test")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Test {}
impl<'a> ::flatbuffers::Follow<'a> for Test {
- type Inner = &'a Test;
+ type Inner = &'a Test;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Test>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Test>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Test {
- type Inner = &'a Test;
+ type Inner = &'a Test;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Test>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Test>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Test {
@@ -59,107 +59,107 @@
}
impl<'a> ::flatbuffers::Verifiable for Test {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Test {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i16,
- b: i8,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s.set_b(b);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Test"
- }
-
- pub fn a(&self) -> i16 {
- let mut mem = ::core::mem::MaybeUninit::<<i16 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i16) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i16,
+ b: i8,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s.set_b(b);
+ s
}
- }
- pub fn b(&self) -> i8 {
- let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_b(&mut self, x: i8) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[2..].as_mut_ptr(),
- ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Test"
}
- }
- pub fn unpack(&self) -> TestT {
- TestT {
- a: self.a(),
- b: self.b(),
+ pub fn a(&self) -> i16 {
+ let mut mem = ::core::mem::MaybeUninit::<<i16 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_a(&mut self, x: i16) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn b(&self) -> i8 {
+ let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_b(&mut self, x: i8) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[2..].as_mut_ptr(),
+ ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> TestT {
+ TestT {
+ a: self.a(),
+ b: self.b(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestT {
- pub a: i16,
- pub b: i8,
+ pub a: i16,
+ pub b: i8,
}
impl TestT {
- pub fn pack(&self) -> Test {
- Test::new(
- self.a,
- self.b,
- )
- }
+ pub fn pack(&self) -> Test {
+ Test::new(
+ self.a,
+ self.b,
+ )
+ }
}
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 d00ad65..bbb18ac 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
@@ -7,66 +7,66 @@
#[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> {
- type Inner = TestSimpleTableWithEnum<'a>;
+ type Inner = TestSimpleTableWithEnum<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TestSimpleTableWithEnumArgs
- ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
- let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
- builder.add_color(args.color);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TestSimpleTableWithEnumT {
- let color = self.color();
- TestSimpleTableWithEnumT {
- color,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TestSimpleTableWithEnum"
}
- }
- #[inline]
- pub fn color(&self) -> Color {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Color>(TestSimpleTableWithEnum::VT_COLOR, Some(Color::Green)).unwrap()}
- }
+ #[inline]
+ 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>,
+ args: &'args TestSimpleTableWithEnumArgs
+ ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
+ let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
+ builder.add_color(args.color);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TestSimpleTableWithEnumT {
+ let color = self.color();
+ TestSimpleTableWithEnumT {
+ color,
+ }
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(TestSimpleTableWithEnum::VT_COLOR, Some(Color::Green)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<Color>("color", Self::VT_COLOR, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TestSimpleTableWithEnumArgs {
@@ -74,71 +74,71 @@
}
impl<'a> Default for TestSimpleTableWithEnumArgs {
- #[inline]
- fn default() -> Self {
- TestSimpleTableWithEnumArgs {
- color: Color::Green,
+ #[inline]
+ fn default() -> Self {
+ TestSimpleTableWithEnumArgs {
+ color: Color::Green,
+ }
}
- }
}
pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<Color>(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TestSimpleTableWithEnumBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_color(&mut self, color: Color) {
+ self.fbb_.push_slot::<Color>(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TestSimpleTableWithEnumBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TestSimpleTableWithEnumT {
- pub color: Color,
+ pub color: Color,
}
impl Default for TestSimpleTableWithEnumT {
- fn default() -> Self {
- Self {
- color: Color::Green,
+ fn default() -> Self {
+ Self {
+ color: Color::Green,
+ }
}
- }
}
impl TestSimpleTableWithEnumT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> {
- let color = self.color;
- TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{
- color,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> {
+ 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 9ef6c10..35d064d 100644
--- a/tests/monster_test/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/type_aliases_generated.rs
@@ -7,213 +7,213 @@
#[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> {
- type Inner = TypeAliases<'a>;
+ type Inner = TypeAliases<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TypeAliasesArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TypeAliases<'bldr>> {
- let mut builder = TypeAliasesBuilder::new(_fbb);
- builder.add_f64_(args.f64_);
- builder.add_u64_(args.u64_);
- builder.add_i64_(args.i64_);
- if let Some(x) = args.vf64 { builder.add_vf64(x); }
- if let Some(x) = args.v8 { builder.add_v8(x); }
- builder.add_f32_(args.f32_);
- builder.add_u32_(args.u32_);
- builder.add_i32_(args.i32_);
- builder.add_u16_(args.u16_);
- builder.add_i16_(args.i16_);
- builder.add_u8_(args.u8_);
- builder.add_i8_(args.i8_);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TypeAliasesT {
- let i8_ = self.i8_();
- let u8_ = self.u8_();
- let i16_ = self.i16_();
- let u16_ = self.u16_();
- let i32_ = self.i32_();
- let u32_ = self.u32_();
- let i64_ = self.i64_();
- let u64_ = self.u64_();
- let f32_ = self.f32_();
- let f64_ = self.f64_();
- let v8 = self.v8().map(|x| {
- x.into_iter().collect()
- });
- let vf64 = self.vf64().map(|x| {
- x.into_iter().collect()
- });
- TypeAliasesT {
- i8_,
- u8_,
- i16_,
- u16_,
- i32_,
- u32_,
- i64_,
- u64_,
- f32_,
- f64_,
- v8,
- vf64,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TypeAliases"
}
- }
- #[inline]
- pub fn i8_(&self) -> i8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ TypeAliases { _tab: table }
+ }
- #[inline]
- pub fn u8_(&self) -> u8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
- }
+ #[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>,
+ args: &'args TypeAliasesArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TypeAliases<'bldr>> {
+ let mut builder = TypeAliasesBuilder::new(_fbb);
+ builder.add_f64_(args.f64_);
+ builder.add_u64_(args.u64_);
+ builder.add_i64_(args.i64_);
+ if let Some(x) = args.vf64 { builder.add_vf64(x); }
+ if let Some(x) = args.v8 { builder.add_v8(x); }
+ builder.add_f32_(args.f32_);
+ builder.add_u32_(args.u32_);
+ builder.add_i32_(args.i32_);
+ builder.add_u16_(args.u16_);
+ builder.add_i16_(args.i16_);
+ builder.add_u8_(args.u8_);
+ builder.add_i8_(args.i8_);
+ builder.finish()
+ }
- #[inline]
- pub fn i16_(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
- }
+ pub fn unpack(&self) -> TypeAliasesT {
+ let i8_ = self.i8_();
+ let u8_ = self.u8_();
+ let i16_ = self.i16_();
+ let u16_ = self.u16_();
+ let i32_ = self.i32_();
+ let u32_ = self.u32_();
+ let i64_ = self.i64_();
+ let u64_ = self.u64_();
+ let f32_ = self.f32_();
+ let f64_ = self.f64_();
+ let v8 = self.v8().map(|x| {
+ x.into_iter().collect()
+ });
+ let vf64 = self.vf64().map(|x| {
+ x.into_iter().collect()
+ });
+ TypeAliasesT {
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ }
+ }
- #[inline]
- pub fn u16_(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i8_(&self) -> i8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn i32_(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn u8_(&self) -> u8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn u32_(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i16_(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn i64_(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn u16_(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn u64_(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i32_(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn f32_(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(TypeAliases::VT_F32_, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn u32_(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn f64_(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(TypeAliases::VT_F64_, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn i64_(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)}
- }
+ #[inline]
+ pub fn u64_(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)}
- }
+ #[inline]
+ pub fn f32_(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(TypeAliases::VT_F32_, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn f64_(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(TypeAliases::VT_F64_, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)}
+ }
}
impl ::flatbuffers::Verifiable for TypeAliases<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i8>("i8_", Self::VT_I8_, false)?
- .visit_field::<u8>("u8_", Self::VT_U8_, false)?
- .visit_field::<i16>("i16_", Self::VT_I16_, false)?
- .visit_field::<u16>("u16_", Self::VT_U16_, false)?
- .visit_field::<i32>("i32_", Self::VT_I32_, false)?
- .visit_field::<u32>("u32_", Self::VT_U32_, false)?
- .visit_field::<i64>("i64_", Self::VT_I64_, false)?
- .visit_field::<u64>("u64_", Self::VT_U64_, false)?
- .visit_field::<f32>("f32_", Self::VT_F32_, false)?
- .visit_field::<f64>("f64_", Self::VT_F64_, 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(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i8>("i8_", Self::VT_I8_, false)?
+ .visit_field::<u8>("u8_", Self::VT_U8_, false)?
+ .visit_field::<i16>("i16_", Self::VT_I16_, false)?
+ .visit_field::<u16>("u16_", Self::VT_U16_, false)?
+ .visit_field::<i32>("i32_", Self::VT_I32_, false)?
+ .visit_field::<u32>("u32_", Self::VT_U32_, false)?
+ .visit_field::<i64>("i64_", Self::VT_I64_, false)?
+ .visit_field::<u64>("u64_", Self::VT_U64_, false)?
+ .visit_field::<f32>("f32_", Self::VT_F32_, false)?
+ .visit_field::<f64>("f64_", Self::VT_F64_, 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(())
+ }
}
pub struct TypeAliasesArgs<'a> {
@@ -232,196 +232,196 @@
}
impl<'a> Default for TypeAliasesArgs<'a> {
- #[inline]
- fn default() -> Self {
- TypeAliasesArgs {
- i8_: 0,
- u8_: 0,
- i16_: 0,
- u16_: 0,
- i32_: 0,
- u32_: 0,
- i64_: 0,
- u64_: 0,
- f32_: 0.0,
- f64_: 0.0,
- v8: None,
- vf64: None,
+ #[inline]
+ fn default() -> Self {
+ TypeAliasesArgs {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
}
- }
}
pub struct TypeAliasesBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i8>(TypeAliases::VT_I8_, i8_, 0);
- }
-
- #[inline]
- pub fn add_u8_(&mut self, u8_: u8) {
- self.fbb_.push_slot::<u8>(TypeAliases::VT_U8_, u8_, 0);
- }
-
- #[inline]
- pub fn add_i16_(&mut self, i16_: i16) {
- self.fbb_.push_slot::<i16>(TypeAliases::VT_I16_, i16_, 0);
- }
-
- #[inline]
- pub fn add_u16_(&mut self, u16_: u16) {
- self.fbb_.push_slot::<u16>(TypeAliases::VT_U16_, u16_, 0);
- }
-
- #[inline]
- pub fn add_i32_(&mut self, i32_: i32) {
- self.fbb_.push_slot::<i32>(TypeAliases::VT_I32_, i32_, 0);
- }
-
- #[inline]
- pub fn add_u32_(&mut self, u32_: u32) {
- self.fbb_.push_slot::<u32>(TypeAliases::VT_U32_, u32_, 0);
- }
-
- #[inline]
- pub fn add_i64_(&mut self, i64_: i64) {
- self.fbb_.push_slot::<i64>(TypeAliases::VT_I64_, i64_, 0);
- }
-
- #[inline]
- pub fn add_u64_(&mut self, u64_: u64) {
- self.fbb_.push_slot::<u64>(TypeAliases::VT_U64_, u64_, 0);
- }
-
- #[inline]
- pub fn add_f32_(&mut self, f32_: f32) {
- self.fbb_.push_slot::<f32>(TypeAliases::VT_F32_, f32_, 0.0);
- }
-
- #[inline]
- pub fn add_f64_(&mut self, f64_: f64) {
- self.fbb_.push_slot::<f64>(TypeAliases::VT_F64_, f64_, 0.0);
- }
-
- #[inline]
- 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<::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> {
- let start = _fbb.start_table();
- TypeAliasesBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_i8_(&mut self, i8_: i8) {
+ self.fbb_.push_slot::<i8>(TypeAliases::VT_I8_, i8_, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_u8_(&mut self, u8_: u8) {
+ self.fbb_.push_slot::<u8>(TypeAliases::VT_U8_, u8_, 0);
+ }
+
+ #[inline]
+ pub fn add_i16_(&mut self, i16_: i16) {
+ self.fbb_.push_slot::<i16>(TypeAliases::VT_I16_, i16_, 0);
+ }
+
+ #[inline]
+ pub fn add_u16_(&mut self, u16_: u16) {
+ self.fbb_.push_slot::<u16>(TypeAliases::VT_U16_, u16_, 0);
+ }
+
+ #[inline]
+ pub fn add_i32_(&mut self, i32_: i32) {
+ self.fbb_.push_slot::<i32>(TypeAliases::VT_I32_, i32_, 0);
+ }
+
+ #[inline]
+ pub fn add_u32_(&mut self, u32_: u32) {
+ self.fbb_.push_slot::<u32>(TypeAliases::VT_U32_, u32_, 0);
+ }
+
+ #[inline]
+ pub fn add_i64_(&mut self, i64_: i64) {
+ self.fbb_.push_slot::<i64>(TypeAliases::VT_I64_, i64_, 0);
+ }
+
+ #[inline]
+ pub fn add_u64_(&mut self, u64_: u64) {
+ self.fbb_.push_slot::<u64>(TypeAliases::VT_U64_, u64_, 0);
+ }
+
+ #[inline]
+ pub fn add_f32_(&mut self, f32_: f32) {
+ self.fbb_.push_slot::<f32>(TypeAliases::VT_F32_, f32_, 0.0);
+ }
+
+ #[inline]
+ pub fn add_f64_(&mut self, f64_: f64) {
+ self.fbb_.push_slot::<f64>(TypeAliases::VT_F64_, f64_, 0.0);
+ }
+
+ #[inline]
+ 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<::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> {
+ let start = _fbb.start_table();
+ TypeAliasesBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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_());
- ds.field("i16_", &self.i16_());
- ds.field("u16_", &self.u16_());
- ds.field("i32_", &self.i32_());
- ds.field("u32_", &self.u32_());
- ds.field("i64_", &self.i64_());
- ds.field("u64_", &self.u64_());
- ds.field("f32_", &self.f32_());
- ds.field("f64_", &self.f64_());
- ds.field("v8", &self.v8());
- ds.field("vf64", &self.vf64());
- ds.finish()
- }
+ 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_());
+ ds.field("i16_", &self.i16_());
+ ds.field("u16_", &self.u16_());
+ ds.field("i32_", &self.i32_());
+ ds.field("u32_", &self.u32_());
+ ds.field("i64_", &self.i64_());
+ ds.field("u64_", &self.u64_());
+ ds.field("f32_", &self.f32_());
+ ds.field("f64_", &self.f64_());
+ ds.field("v8", &self.v8());
+ ds.field("vf64", &self.vf64());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TypeAliasesT {
- pub i8_: i8,
- pub u8_: u8,
- pub i16_: i16,
- pub u16_: u16,
- pub i32_: i32,
- pub u32_: u32,
- pub i64_: i64,
- pub u64_: u64,
- pub f32_: f32,
- pub f64_: f64,
- pub v8: Option<alloc::vec::Vec<i8>>,
- pub vf64: Option<alloc::vec::Vec<f64>>,
+ pub i8_: i8,
+ pub u8_: u8,
+ pub i16_: i16,
+ pub u16_: u16,
+ pub i32_: i32,
+ pub u32_: u32,
+ pub i64_: i64,
+ pub u64_: u64,
+ pub f32_: f32,
+ pub f64_: f64,
+ pub v8: Option<alloc::vec::Vec<i8>>,
+ pub vf64: Option<alloc::vec::Vec<f64>>,
}
impl Default for TypeAliasesT {
- fn default() -> Self {
- Self {
- i8_: 0,
- u8_: 0,
- i16_: 0,
- u16_: 0,
- i32_: 0,
- u32_: 0,
- i64_: 0,
- u64_: 0,
- f32_: 0.0,
- f64_: 0.0,
- v8: None,
- vf64: None,
+ fn default() -> Self {
+ Self {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
}
- }
}
impl TypeAliasesT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TypeAliases<'b>> {
- let i8_ = self.i8_;
- let u8_ = self.u8_;
- let i16_ = self.i16_;
- let u16_ = self.u16_;
- let i32_ = self.i32_;
- let u32_ = self.u32_;
- let i64_ = self.i64_;
- let u64_ = self.u64_;
- let f32_ = self.f32_;
- let f64_ = self.f64_;
- let v8 = self.v8.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let vf64 = self.vf64.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- TypeAliases::create(_fbb, &TypeAliasesArgs{
- i8_,
- u8_,
- i16_,
- u16_,
- i32_,
- u32_,
- i64_,
- u64_,
- f32_,
- f64_,
- v8,
- vf64,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TypeAliases<'b>> {
+ let i8_ = self.i8_;
+ let u8_ = self.u8_;
+ let i16_ = self.i16_;
+ let u16_ = self.u16_;
+ let i32_ = self.i32_;
+ let u32_ = self.u32_;
+ let i64_ = self.i64_;
+ let u64_ = self.u64_;
+ let f32_ = self.f32_;
+ let f64_ = self.f64_;
+ let v8 = self.v8.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let vf64 = self.vf64.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ TypeAliases::create(_fbb, &TypeAliasesArgs{
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ })
+ }
}
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 1a2c4cd..23ed771 100644
--- a/tests/monster_test/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test/my_game/example/vec_3_generated.rs
@@ -8,43 +8,43 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 32]);
-impl Default for Vec3 {
- fn default() -> Self {
- Self([0; 32])
- }
+impl Default for Vec3 {
+ fn default() -> Self {
+ Self([0; 32])
+ }
}
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())
- .field("z", &self.z())
- .field("test1", &self.test1())
- .field("test2", &self.test2())
- .field("test3", &self.test3())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Vec3")
+ .field("x", &self.x())
+ .field("y", &self.y())
+ .field("z", &self.z())
+ .field("test1", &self.test1())
+ .field("test2", &self.test2())
+ .field("test3", &self.test3())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Vec3>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Vec3>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Vec3 {
@@ -63,226 +63,226 @@
}
impl<'a> ::flatbuffers::Verifiable for Vec3 {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Vec3 {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- x: f32,
- y: f32,
- z: f32,
- test1: f64,
- test2: Color,
- test3: &Test,
- ) -> Self {
- let mut s = Self([0; 32]);
- s.set_x(x);
- s.set_y(y);
- s.set_z(z);
- s.set_test1(test1);
- s.set_test2(test2);
- s.set_test3(test3);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Vec3"
- }
-
- pub fn x(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[0..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_x(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ x: f32,
+ y: f32,
+ z: f32,
+ test1: f64,
+ test2: Color,
+ test3: &Test,
+ ) -> Self {
+ let mut s = Self([0; 32]);
+ s.set_x(x);
+ s.set_y(y);
+ s.set_z(z);
+ s.set_test1(test1);
+ s.set_test2(test2);
+ s.set_test3(test3);
+ s
}
- }
- pub fn y(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[4..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_y(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Vec3"
}
- }
- pub fn z(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[8..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_z(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[8..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn x(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn test1(&self) -> f64 {
- let mut mem = ::core::mem::MaybeUninit::<<f64 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_test1(&mut self, x: f64) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[16..].as_mut_ptr(),
- ::core::mem::size_of::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn set_x(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
- pub fn test2(&self) -> Color {
- let mut mem = ::core::mem::MaybeUninit::<<Color as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_test2(&mut self, x: Color) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[24..].as_mut_ptr(),
- ::core::mem::size_of::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn y(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn test3(&self) -> &Test {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[26..].as_ptr() as *const Test) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_test3(&mut self, x: &Test) {
- self.0[26..26 + 4].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> Vec3T {
- Vec3T {
- x: self.x(),
- y: self.y(),
- z: self.z(),
- test1: self.test1(),
- test2: self.test2(),
- test3: self.test3().unpack(),
+ pub fn set_y(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
+
+ pub fn z(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[8..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_z(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[8..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test1(&self) -> f64 {
+ let mut mem = ::core::mem::MaybeUninit::<<f64 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_test1(&mut self, x: f64) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[16..].as_mut_ptr(),
+ ::core::mem::size_of::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test2(&self) -> Color {
+ let mut mem = ::core::mem::MaybeUninit::<<Color as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_test2(&mut self, x: Color) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[24..].as_mut_ptr(),
+ ::core::mem::size_of::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test3(&self) -> &Test {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[26..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_test3(&mut self, x: &Test) {
+ self.0[26..26 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> Vec3T {
+ Vec3T {
+ x: self.x(),
+ y: self.y(),
+ z: self.z(),
+ test1: self.test1(),
+ test2: self.test2(),
+ test3: self.test3().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Vec3T {
- pub x: f32,
- pub y: f32,
- pub z: f32,
- pub test1: f64,
- pub test2: Color,
- pub test3: TestT,
+ pub x: f32,
+ pub y: f32,
+ pub z: f32,
+ pub test1: f64,
+ pub test2: Color,
+ pub test3: TestT,
}
impl Vec3T {
- pub fn pack(&self) -> Vec3 {
- Vec3::new(
- self.x,
- self.y,
- self.z,
- self.test1,
- self.test2,
- &self.test3.pack(),
- )
- }
+ pub fn pack(&self) -> Vec3 {
+ Vec3::new(
+ self.x,
+ self.y,
+ self.z,
+ self.test1,
+ self.test2,
+ &self.test3.pack(),
+ )
+ }
}
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 6e142f1..c908f0a 100644
--- a/tests/monster_test/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test/my_game/example_2/monster_generated.rs
@@ -7,92 +7,92 @@
#[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> {
- type Inner = Monster<'a>;
+ type Inner = Monster<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Monster<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example2.Monster"
- }
-
- #[inline]
- 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>,
- _args: &'args MonsterArgs
- ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
- let mut builder = MonsterBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> MonsterT {
- MonsterT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example2.Monster"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args MonsterArgs
+ ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
+ let mut builder = MonsterBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> MonsterT {
+ MonsterT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for Monster<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct MonsterArgs {
}
impl<'a> Default for MonsterArgs {
- #[inline]
- fn default() -> Self {
- MonsterArgs {
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ }
}
- }
}
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- MonsterBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("Monster");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for MonsterT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl MonsterT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
- Monster::create(_fbb, &MonsterArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
+ 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 9911d3d..72c1ed5 100644
--- a/tests/monster_test/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs
@@ -7,92 +7,92 @@
#[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> {
- type Inner = InParentNamespace<'a>;
+ type Inner = InParentNamespace<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> InParentNamespace<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.InParentNamespace"
- }
-
- #[inline]
- 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>,
- _args: &'args InParentNamespaceArgs
- ) -> ::flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
- let mut builder = InParentNamespaceBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> InParentNamespaceT {
- InParentNamespaceT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.InParentNamespace"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args InParentNamespaceArgs
+ ) -> ::flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
+ let mut builder = InParentNamespaceBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> InParentNamespaceT {
+ InParentNamespaceT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for InParentNamespace<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct InParentNamespaceArgs {
}
impl<'a> Default for InParentNamespaceArgs {
- #[inline]
- fn default() -> Self {
- InParentNamespaceArgs {
+ #[inline]
+ fn default() -> Self {
+ InParentNamespaceArgs {
+ }
}
- }
}
pub struct InParentNamespaceBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- InParentNamespaceBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ InParentNamespaceBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("InParentNamespace");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for InParentNamespaceT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl InParentNamespaceT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<InParentNamespace<'b>> {
- InParentNamespace::create(_fbb, &InParentNamespaceArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<InParentNamespace<'b>> {
+ 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 4e03e2d..ada2947 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
@@ -12,7 +12,7 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
+ FromInclude::IncludeVal,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -21,41 +21,41 @@
#[allow(non_upper_case_globals)]
impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ pub const IncludeVal: Self = Self(0);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for FromInclude {
@@ -68,28 +68,28 @@
}
impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
+ type Scalar = i64;
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
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 5e969c2..5434e44 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
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableB<'a>;
+ type Inner = TableB<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.TableB"
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableBArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
}
- }
}
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
}
impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
}
- }
}
impl TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
}
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 e8639ac..12f7fa7 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
@@ -8,38 +8,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Unused(pub [u8; 4]);
-impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Unused {
@@ -58,73 +58,73 @@
}
impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
}
- }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct UnusedT {
- pub a: i32,
+ pub a: i32,
}
impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
}
diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs
index 2558b84..467c514 100644
--- a/tests/monster_test/table_a_generated.rs
+++ b/tests/monster_test/table_a_generated.rs
@@ -7,68 +7,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
diff --git a/tests/monster_test_serialize/mod.rs b/tests/monster_test_serialize/mod.rs
index 7f1fab1..27af0f2 100644
--- a/tests/monster_test_serialize/mod.rs
+++ b/tests/monster_test_serialize/mod.rs
@@ -1,58 +1,58 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod my_game {
- use super::*;
- pub mod example {
use super::*;
- mod color_generated;
- pub use self::color_generated::*;
- mod race_generated;
- pub use self::race_generated::*;
- mod long_enum_generated;
- pub use self::long_enum_generated::*;
- mod any_generated;
- pub use self::any_generated::*;
- mod any_unique_aliases_generated;
- pub use self::any_unique_aliases_generated::*;
- mod any_ambiguous_aliases_generated;
- pub use self::any_ambiguous_aliases_generated::*;
- mod test_generated;
- pub use self::test_generated::*;
- mod test_simple_table_with_enum_generated;
- pub use self::test_simple_table_with_enum_generated::*;
- mod vec_3_generated;
- pub use self::vec_3_generated::*;
- mod ability_generated;
- pub use self::ability_generated::*;
- mod struct_of_structs_generated;
- pub use self::struct_of_structs_generated::*;
- mod struct_of_structs_of_structs_generated;
- pub use self::struct_of_structs_of_structs_generated::*;
- mod stat_generated;
- pub use self::stat_generated::*;
- mod referrable_generated;
- pub use self::referrable_generated::*;
- mod monster_generated;
- pub use self::monster_generated::*;
- mod type_aliases_generated;
- pub use self::type_aliases_generated::*;
- } // example
- pub mod example_2 {
- use super::*;
- mod monster_generated;
- pub use self::monster_generated::*;
- } // example_2
- pub mod other_name_space {
- use super::*;
- mod from_include_generated;
- pub use self::from_include_generated::*;
- mod unused_generated;
- pub use self::unused_generated::*;
- mod table_b_generated;
- pub use self::table_b_generated::*;
- } // other_name_space
- mod in_parent_namespace_generated;
- pub use self::in_parent_namespace_generated::*;
+ pub mod example {
+ use super::*;
+ mod color_generated;
+ pub use self::color_generated::*;
+ mod race_generated;
+ pub use self::race_generated::*;
+ mod long_enum_generated;
+ pub use self::long_enum_generated::*;
+ mod any_generated;
+ pub use self::any_generated::*;
+ mod any_unique_aliases_generated;
+ pub use self::any_unique_aliases_generated::*;
+ mod any_ambiguous_aliases_generated;
+ pub use self::any_ambiguous_aliases_generated::*;
+ mod test_generated;
+ pub use self::test_generated::*;
+ mod test_simple_table_with_enum_generated;
+ pub use self::test_simple_table_with_enum_generated::*;
+ mod vec_3_generated;
+ pub use self::vec_3_generated::*;
+ mod ability_generated;
+ pub use self::ability_generated::*;
+ mod struct_of_structs_generated;
+ pub use self::struct_of_structs_generated::*;
+ mod struct_of_structs_of_structs_generated;
+ pub use self::struct_of_structs_of_structs_generated::*;
+ mod stat_generated;
+ pub use self::stat_generated::*;
+ mod referrable_generated;
+ pub use self::referrable_generated::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ mod type_aliases_generated;
+ pub use self::type_aliases_generated::*;
+ } // example
+ pub mod example_2 {
+ use super::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ } // example_2
+ pub mod other_name_space {
+ use super::*;
+ mod from_include_generated;
+ pub use self::from_include_generated::*;
+ mod unused_generated;
+ pub use self::unused_generated::*;
+ mod table_b_generated;
+ pub use self::table_b_generated::*;
+ } // other_name_space
+ mod in_parent_namespace_generated;
+ pub use self::in_parent_namespace_generated::*;
} // my_game
mod table_a_generated;
pub use self::table_a_generated::*;
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 1e1aebc..0c866a5 100644
--- a/tests/monster_test_serialize/my_game/example/ability_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/ability_generated.rs
@@ -10,39 +10,39 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Ability(pub [u8; 8]);
-impl Default for Ability {
- fn default() -> Self {
- Self([0; 8])
- }
+impl Default for Ability {
+ fn default() -> Self {
+ Self([0; 8])
+ }
}
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())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Ability")
+ .field("id", &self.id())
+ .field("distance", &self.distance())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
impl<'a> ::flatbuffers::Follow<'a> for Ability {
- type Inner = &'a Ability;
+ type Inner = &'a Ability;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Ability>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Ability>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Ability {
- type Inner = &'a Ability;
+ type Inner = &'a Ability;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Ability>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Ability {
@@ -61,130 +61,130 @@
}
impl<'a> ::flatbuffers::Verifiable for Ability {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for Ability {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("Ability", 2)?;
- s.serialize_field("id", &self.id())?;
- s.serialize_field("distance", &self.distance())?;
- s.end()
- }
+ s.serialize_field("id", &self.id())?;
+ s.serialize_field("distance", &self.distance())?;
+ s.end()
+ }
}
impl<'a> Ability {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- id: u32,
- distance: u32,
- ) -> Self {
- let mut s = Self([0; 8]);
- s.set_id(id);
- s.set_distance(distance);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Ability"
- }
-
- pub fn id(&self) -> u32 {
- let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_id(&mut self, x: u32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ id: u32,
+ distance: u32,
+ ) -> Self {
+ let mut s = Self([0; 8]);
+ s.set_id(id);
+ s.set_distance(distance);
+ s
}
- }
-
- #[inline]
- pub fn key_compare_less_than(&self, o: &Ability) -> bool {
- self.id() < o.id()
- }
-
- #[inline]
- pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
- let key = self.id();
- key.cmp(&val)
- }
- pub fn distance(&self) -> u32 {
- let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_distance(&mut self, x: u32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Ability"
}
- }
- pub fn unpack(&self) -> AbilityT {
- AbilityT {
- id: self.id(),
- distance: self.distance(),
+ pub fn id(&self) -> u32 {
+ let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_id(&mut self, x: u32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Ability) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u32) -> ::core::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
+ pub fn distance(&self) -> u32 {
+ let mut mem = ::core::mem::MaybeUninit::<<u32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_distance(&mut self, x: u32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<u32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> AbilityT {
+ AbilityT {
+ id: self.id(),
+ distance: self.distance(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct AbilityT {
- pub id: u32,
- pub distance: u32,
+ pub id: u32,
+ pub distance: u32,
}
impl AbilityT {
- pub fn pack(&self) -> Ability {
- Ability::new(
- self.id,
- self.distance,
- )
- }
+ pub fn pack(&self) -> Ability {
+ Ability::new(
+ self.id,
+ self.distance,
+ )
+ }
}
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 ec6c62c..415961c 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
@@ -14,10 +14,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY_AMBIGUOUS_ALIASES: [AnyAmbiguousAliases; 4] = [
- AnyAmbiguousAliases::NONE,
- AnyAmbiguousAliases::M1,
- AnyAmbiguousAliases::M2,
- AnyAmbiguousAliases::M3,
+ AnyAmbiguousAliases::NONE,
+ AnyAmbiguousAliases::M1,
+ AnyAmbiguousAliases::M2,
+ AnyAmbiguousAliases::M3,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -26,49 +26,49 @@
#[allow(non_upper_case_globals)]
impl AnyAmbiguousAliases {
- pub const NONE: Self = Self(0);
- pub const M1: Self = Self(1);
- pub const M2: Self = Self(2);
- pub const M3: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const M1: Self = Self(1);
+ pub const M2: Self = Self(2);
+ pub const M3: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::M1,
- Self::M2,
- Self::M3,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M1,
+ Self::M2,
+ Self::M3,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::M1 => Some("M1"),
- Self::M2 => Some("M2"),
- Self::M3 => Some("M3"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M1 => Some("M1"),
+ Self::M2 => Some("M2"),
+ Self::M3 => Some("M3"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl Serialize for AnyAmbiguousAliases {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_unit_variant("AnyAmbiguousAliases", self.0 as u32, self.variant_name().unwrap())
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant("AnyAmbiguousAliases", self.0 as u32, self.variant_name().unwrap())
+ }
}
impl<'de> serde::Deserialize<'de> for AnyAmbiguousAliases {
@@ -91,13 +91,13 @@
}
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for AnyAmbiguousAliases {
@@ -110,28 +110,28 @@
}
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for AnyAmbiguousAliases {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
@@ -142,107 +142,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyAmbiguousAliasesT {
- NONE,
- M1(alloc::boxed::Box<MonsterT>),
- M2(alloc::boxed::Box<MonsterT>),
- M3(alloc::boxed::Box<MonsterT>),
+ NONE,
+ M1(alloc::boxed::Box<MonsterT>),
+ M2(alloc::boxed::Box<MonsterT>),
+ M3(alloc::boxed::Box<MonsterT>),
}
impl Default for AnyAmbiguousAliasesT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyAmbiguousAliasesT {
- pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
- match self {
- Self::NONE => AnyAmbiguousAliases::NONE,
- Self::M1(_) => AnyAmbiguousAliases::M1,
- Self::M2(_) => AnyAmbiguousAliases::M2,
- Self::M3(_) => AnyAmbiguousAliases::M3,
+ pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
+ match self {
+ Self::NONE => AnyAmbiguousAliases::NONE,
+ Self::M1(_) => AnyAmbiguousAliases::M1,
+ Self::M2(_) => AnyAmbiguousAliases::M2,
+ Self::M3(_) => AnyAmbiguousAliases::M3,
+ }
}
- }
- pub fn pack<'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()),
- Self::M2(v) => Some(v.pack(fbb).as_union_value()),
- Self::M3(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M3(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M1(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M1(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m1(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M1(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M1(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m1(&self) -> Option<&MonsterT> {
- if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M2(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M2(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m1(&self) -> Option<&MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m2(&self) -> Option<&MonsterT> {
- if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M3(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M3(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m3(&self) -> Option<&MonsterT> {
- if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m2(&self) -> Option<&MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m2_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m3(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M3(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M3(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m3(&self) -> Option<&MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 0f5be1a..5f4ab10 100644
--- a/tests/monster_test_serialize/my_game/example/any_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_generated.rs
@@ -14,10 +14,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY: [Any; 4] = [
- Any::NONE,
- Any::Monster,
- Any::TestSimpleTableWithEnum,
- Any::MyGame_Example2_Monster,
+ Any::NONE,
+ Any::Monster,
+ Any::TestSimpleTableWithEnum,
+ Any::MyGame_Example2_Monster,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -26,49 +26,49 @@
#[allow(non_upper_case_globals)]
impl Any {
- pub const NONE: Self = Self(0);
- pub const Monster: Self = Self(1);
- pub const TestSimpleTableWithEnum: Self = Self(2);
- pub const MyGame_Example2_Monster: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const Monster: Self = Self(1);
+ pub const TestSimpleTableWithEnum: Self = Self(2);
+ pub const MyGame_Example2_Monster: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::Monster,
- Self::TestSimpleTableWithEnum,
- Self::MyGame_Example2_Monster,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Monster,
+ Self::TestSimpleTableWithEnum,
+ Self::MyGame_Example2_Monster,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::Monster => Some("Monster"),
- Self::TestSimpleTableWithEnum => Some("TestSimpleTableWithEnum"),
- Self::MyGame_Example2_Monster => Some("MyGame_Example2_Monster"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Monster => Some("Monster"),
+ Self::TestSimpleTableWithEnum => Some("TestSimpleTableWithEnum"),
+ Self::MyGame_Example2_Monster => Some("MyGame_Example2_Monster"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl Serialize for Any {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_unit_variant("Any", self.0 as u32, self.variant_name().unwrap())
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant("Any", self.0 as u32, self.variant_name().unwrap())
+ }
}
impl<'de> serde::Deserialize<'de> for Any {
@@ -91,13 +91,13 @@
}
impl<'a> ::flatbuffers::Follow<'a> for Any {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Any {
@@ -110,28 +110,28 @@
}
impl ::flatbuffers::EndianScalar for Any {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Any {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
@@ -142,107 +142,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyT {
- NONE,
- Monster(alloc::boxed::Box<MonsterT>),
- TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
- MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
+ NONE,
+ Monster(alloc::boxed::Box<MonsterT>),
+ TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
+ MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
}
impl Default for AnyT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyT {
- pub fn any_type(&self) -> Any {
- match self {
- Self::NONE => Any::NONE,
- Self::Monster(_) => Any::Monster,
- Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum,
- Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
+ pub fn any_type(&self) -> Any {
+ match self {
+ Self::NONE => Any::NONE,
+ Self::Monster(_) => Any::Monster,
+ Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum,
+ Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
+ }
}
- }
- pub fn pack<'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()),
- Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()),
- Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()),
+ Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_monster(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::Monster(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Monster(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_monster(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::Monster(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_monster(&self) -> Option<&MonsterT> {
- if let Self::Monster(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
- pub fn take_test_simple_table_with_enum(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
- if let Self::TestSimpleTableWithEnum(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::TestSimpleTableWithEnum(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_monster(&self) -> Option<&MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
- pub fn as_test_simple_table_with_enum(&self) -> Option<&TestSimpleTableWithEnumT> {
- if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
- pub fn as_test_simple_table_with_enum_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
- if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
- pub fn take_my_game_example_2_monster(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
- if let Self::MyGameExample2Monster(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::MyGameExample2Monster(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the super::example_2::MonsterT.
- pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> {
- if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_test_simple_table_with_enum(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
+ if let Self::TestSimpleTableWithEnum(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::TestSimpleTableWithEnum(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
- pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
- if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
+ pub fn as_test_simple_table_with_enum(&self) -> Option<&TestSimpleTableWithEnumT> {
+ if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
+ pub fn as_test_simple_table_with_enum_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
+ if let Self::TestSimpleTableWithEnum(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
+ pub fn take_my_game_example_2_monster(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
+ if let Self::MyGameExample2Monster(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::MyGameExample2Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 067f2f6..12286c6 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
@@ -14,10 +14,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY_UNIQUE_ALIASES: [AnyUniqueAliases; 4] = [
- AnyUniqueAliases::NONE,
- AnyUniqueAliases::M,
- AnyUniqueAliases::TS,
- AnyUniqueAliases::M2,
+ AnyUniqueAliases::NONE,
+ AnyUniqueAliases::M,
+ AnyUniqueAliases::TS,
+ AnyUniqueAliases::M2,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -26,49 +26,49 @@
#[allow(non_upper_case_globals)]
impl AnyUniqueAliases {
- pub const NONE: Self = Self(0);
- pub const M: Self = Self(1);
- pub const TS: Self = Self(2);
- pub const M2: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const M: Self = Self(1);
+ pub const TS: Self = Self(2);
+ pub const M2: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::M,
- Self::TS,
- Self::M2,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M,
+ Self::TS,
+ Self::M2,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::M => Some("M"),
- Self::TS => Some("TS"),
- Self::M2 => Some("M2"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M => Some("M"),
+ Self::TS => Some("TS"),
+ Self::M2 => Some("M2"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl Serialize for AnyUniqueAliases {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_unit_variant("AnyUniqueAliases", self.0 as u32, self.variant_name().unwrap())
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant("AnyUniqueAliases", self.0 as u32, self.variant_name().unwrap())
+ }
}
impl<'de> serde::Deserialize<'de> for AnyUniqueAliases {
@@ -91,13 +91,13 @@
}
impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for AnyUniqueAliases {
@@ -110,28 +110,28 @@
}
impl ::flatbuffers::EndianScalar for AnyUniqueAliases {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for AnyUniqueAliases {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {}
@@ -142,107 +142,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum AnyUniqueAliasesT {
- NONE,
- M(alloc::boxed::Box<MonsterT>),
- TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
- M2(alloc::boxed::Box<super::example_2::MonsterT>),
+ NONE,
+ M(alloc::boxed::Box<MonsterT>),
+ TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
+ M2(alloc::boxed::Box<super::example_2::MonsterT>),
}
impl Default for AnyUniqueAliasesT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyUniqueAliasesT {
- pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
- match self {
- Self::NONE => AnyUniqueAliases::NONE,
- Self::M(_) => AnyUniqueAliases::M,
- Self::TS(_) => AnyUniqueAliases::TS,
- Self::M2(_) => AnyUniqueAliases::M2,
+ pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
+ match self {
+ Self::NONE => AnyUniqueAliases::NONE,
+ Self::M(_) => AnyUniqueAliases::M,
+ Self::TS(_) => AnyUniqueAliases::TS,
+ Self::M2(_) => AnyUniqueAliases::M2,
+ }
}
- }
- pub fn pack<'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()),
- Self::TS(v) => Some(v.pack(fbb).as_union_value()),
- Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::TS(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
- pub fn take_m(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
- if let Self::M(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m(&mut self) -> Option<alloc::boxed::Box<MonsterT>> {
+ if let Self::M(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the MonsterT.
- pub fn as_m(&self) -> Option<&MonsterT> {
- if let Self::M(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the MonsterT.
- pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> {
- if let Self::M(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
- pub fn take_ts(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
- if let Self::TS(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::TS(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m(&self) -> Option<&MonsterT> {
+ if let Self::M(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
- pub fn as_ts(&self) -> Option<&TestSimpleTableWithEnumT> {
- if let Self::TS(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
- pub fn as_ts_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
- if let Self::TS(v) = self { Some(v.as_mut()) } else { None }
- }
-
- /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
- pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
- if let Self::M2(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::M2(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the super::example_2::MonsterT.
- pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> {
- if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_ts(&mut self) -> Option<alloc::boxed::Box<TestSimpleTableWithEnumT>> {
+ if let Self::TS(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::TS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
- pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
- if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the TestSimpleTableWithEnumT.
+ pub fn as_ts(&self) -> Option<&TestSimpleTableWithEnumT> {
+ if let Self::TS(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the TestSimpleTableWithEnumT.
+ pub fn as_ts_mut(&mut self) -> Option<&mut TestSimpleTableWithEnumT> {
+ if let Self::TS(v) = self { Some(v.as_mut()) } else { None }
+ }
+
+ /// If the union variant matches, return the owned super::example_2::MonsterT, setting the union to NONE.
+ pub fn take_m2(&mut self) -> Option<alloc::boxed::Box<super::example_2::MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 bfcfd83..12ea6d5 100644
--- a/tests/monster_test_serialize/my_game/example/color_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/color_generated.rs
@@ -7,39 +7,39 @@
#[allow(non_upper_case_globals)]
mod bitflags_color {
- ::flatbuffers::bitflags::bitflags! {
- /// Composite components of Monster color.
- #[derive(Default, Debug, Clone, Copy, PartialEq)]
- pub struct Color: u8 {
- const Red = 1;
- /// \brief color Green
- /// Green is bit_flag with value (1u << 1)
- const Green = 2;
- /// \brief color Blue (1u << 3)
- const Blue = 8;
+ ::flatbuffers::bitflags::bitflags! {
+ /// Composite components of Monster color.
+ #[derive(Default, Debug, Clone, Copy, PartialEq)]
+ pub struct Color: u8 {
+ const Red = 1;
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ const Green = 2;
+ /// \brief color Blue (1u << 3)
+ const Blue = 8;
+ }
}
- }
}
pub use self::bitflags_color::Color;
impl Serialize for Color {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_u32(self.bits() as u32)
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_u32(self.bits() as u32)
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for Color {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self::from_bits_retain(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self::from_bits_retain(b)
+ }
}
impl ::flatbuffers::Push for Color {
@@ -52,28 +52,28 @@
}
impl ::flatbuffers::EndianScalar for Color {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.bits().to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.bits().to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self::from_bits_retain(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self::from_bits_retain(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Color {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
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 0d00716..90ad8e4 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
@@ -7,35 +7,35 @@
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
- ::flatbuffers::bitflags::bitflags! {
- #[derive(Default, Debug, Clone, Copy, PartialEq)]
- pub struct LongEnum: u64 {
- const LongOne = 2;
- const LongTwo = 4;
- const LongBig = 1099511627776;
+ ::flatbuffers::bitflags::bitflags! {
+ #[derive(Default, Debug, Clone, Copy, PartialEq)]
+ pub struct LongEnum: u64 {
+ const LongOne = 2;
+ const LongTwo = 4;
+ const LongBig = 1099511627776;
+ }
}
- }
}
pub use self::bitflags_long_enum::LongEnum;
impl Serialize for LongEnum {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_u32(self.bits() as u32)
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_u32(self.bits() as u32)
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for LongEnum {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
- Self::from_bits_retain(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
+ Self::from_bits_retain(b)
+ }
}
impl ::flatbuffers::Push for LongEnum {
@@ -48,28 +48,28 @@
}
impl ::flatbuffers::EndianScalar for LongEnum {
- type Scalar = u64;
+ type Scalar = u64;
- #[inline]
- fn to_little_endian(self) -> u64 {
- self.bits().to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u64 {
+ self.bits().to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u64) -> Self {
- let b = u64::from_le(v);
- Self::from_bits_retain(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u64) -> Self {
+ let b = u64::from_le(v);
+ Self::from_bits_retain(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for LongEnum {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u64::run_verifier(v, pos)
+ }
}
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 1f8128c..26652e1 100644
--- a/tests/monster_test_serialize/my_game/example/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/monster_generated.rs
@@ -10,1133 +10,1133 @@
/// an example documentation comment: "monster object"
#[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> {
- type Inner = Monster<'a>;
+ type Inner = Monster<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Monster<'a> {
- pub const VT_POS: ::flatbuffers::VOffsetT = 4;
- pub const VT_MANA: ::flatbuffers::VOffsetT = 6;
- pub const VT_HP: ::flatbuffers::VOffsetT = 8;
- pub const VT_NAME: ::flatbuffers::VOffsetT = 10;
- pub const VT_INVENTORY: ::flatbuffers::VOffsetT = 14;
- pub const VT_COLOR: ::flatbuffers::VOffsetT = 16;
- pub const VT_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 {
- 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>,
- args: &'args MonsterArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
- 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);
- builder.add_long_enum_non_enum_default(args.long_enum_non_enum_default);
- builder.add_non_owning_reference(args.non_owning_reference);
- builder.add_co_owning_reference(args.co_owning_reference);
- builder.add_single_weak_reference(args.single_weak_reference);
- builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
- builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
- builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
- builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
- builder.add_negative_infinity_default(args.negative_infinity_default);
- builder.add_negative_inf_default(args.negative_inf_default);
- builder.add_positive_infinity_default(args.positive_infinity_default);
- builder.add_infinity_default(args.infinity_default);
- builder.add_positive_inf_default(args.positive_inf_default);
- builder.add_inf_default(args.inf_default);
- builder.add_nan_default(args.nan_default);
- if let Some(x) = args.native_inline { builder.add_native_inline(x); }
- if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
- if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
- if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
- if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
- if let Some(x) = args.any_unique { builder.add_any_unique(x); }
- if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
- if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
- if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
- if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
- if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
- if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
- if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
- if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
- if let Some(x) = args.test5 { builder.add_test5(x); }
- if let Some(x) = args.flex { builder.add_flex(x); }
- if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
- if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
- builder.add_testf3(args.testf3);
- builder.add_testf2(args.testf2);
- builder.add_testf(args.testf);
- if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
- builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
- builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
- builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
- builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
- if let Some(x) = args.testempty { builder.add_testempty(x); }
- if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
- if let Some(x) = args.enemy { builder.add_enemy(x); }
- if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
- if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
- if let Some(x) = args.test4 { builder.add_test4(x); }
- if let Some(x) = args.test { builder.add_test(x); }
- if let Some(x) = args.inventory { builder.add_inventory(x); }
- if let Some(x) = args.name { builder.add_name(x); }
- if let Some(x) = args.pos { builder.add_pos(x); }
- builder.add_hp(args.hp);
- builder.add_mana(args.mana);
- builder.add_signed_enum(args.signed_enum);
- builder.add_any_ambiguous_type(args.any_ambiguous_type);
- builder.add_any_unique_type(args.any_unique_type);
- builder.add_testbool(args.testbool);
- builder.add_test_type(args.test_type);
- builder.add_color(args.color);
- builder.finish()
- }
-
- pub fn unpack(&self) -> MonsterT {
- let pos = self.pos().map(|x| {
- x.unpack()
- });
- let mana = self.mana();
- let hp = self.hp();
- let name = {
- let x = self.name();
- alloc::string::ToString::to_string(x)
- };
- let inventory = self.inventory().map(|x| {
- x.into_iter().collect()
- });
- let color = self.color();
- let test = match self.test_type() {
- Any::NONE => AnyT::NONE,
- Any::Monster => AnyT::Monster(alloc::boxed::Box::new(
- self.test_as_monster()
- .expect("Invalid union table, expected `Any::Monster`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.test_as_my_game_example_2_monster()
- .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.")
- .unpack()
- )),
- _ => AnyT::NONE,
- };
- let test4 = self.test4().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let testarrayofstring = self.testarrayofstring().map(|x| {
- x.iter().map(|s| 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| {
- alloc::boxed::Box::new(x.unpack())
- });
- let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| {
- x.into_iter().collect()
- });
- let testempty = self.testempty().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- let testbool = self.testbool();
- let testhashs32_fnv1 = self.testhashs32_fnv1();
- let testhashu32_fnv1 = self.testhashu32_fnv1();
- let testhashs64_fnv1 = self.testhashs64_fnv1();
- let testhashu64_fnv1 = self.testhashu64_fnv1();
- let testhashs32_fnv1a = self.testhashs32_fnv1a();
- let testhashu32_fnv1a = self.testhashu32_fnv1a();
- let testhashs64_fnv1a = self.testhashs64_fnv1a();
- let testhashu64_fnv1a = self.testhashu64_fnv1a();
- let testarrayofbools = self.testarrayofbools().map(|x| {
- x.into_iter().collect()
- });
- let testf = self.testf();
- let testf2 = self.testf2();
- let testf3 = self.testf3();
- let testarrayofstring2 = self.testarrayofstring2().map(|x| {
- x.iter().map(|s| alloc::string::ToString::to_string(s)).collect()
- });
- let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let flex = self.flex().map(|x| {
- x.into_iter().collect()
- });
- let test5 = self.test5().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let vector_of_longs = self.vector_of_longs().map(|x| {
- x.into_iter().collect()
- });
- let vector_of_doubles = self.vector_of_doubles().map(|x| {
- x.into_iter().collect()
- });
- let parent_namespace_test = self.parent_namespace_test().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- let vector_of_referrables = self.vector_of_referrables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let single_weak_reference = self.single_weak_reference();
- let vector_of_weak_references = self.vector_of_weak_references().map(|x| {
- x.into_iter().collect()
- });
- let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let co_owning_reference = self.co_owning_reference();
- let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| {
- x.into_iter().collect()
- });
- let non_owning_reference = self.non_owning_reference();
- let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| {
- x.into_iter().collect()
- });
- let any_unique = match self.any_unique_type() {
- AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE,
- AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new(
- self.any_unique_as_m()
- .expect("Invalid union table, expected `AnyUniqueAliases::M`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.any_unique_as_m2()
- .expect("Invalid union table, expected `AnyUniqueAliases::M2`.")
- .unpack()
- )),
- _ => AnyUniqueAliasesT::NONE,
- };
- let any_ambiguous = match self.any_ambiguous_type() {
- AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE,
- AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new(
- self.any_ambiguous_as_m1()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.")
- .unpack()
- )),
- 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(alloc::boxed::Box::new(
- self.any_ambiguous_as_m3()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.")
- .unpack()
- )),
- _ => AnyAmbiguousAliasesT::NONE,
- };
- let vector_of_enums = self.vector_of_enums().map(|x| {
- x.into_iter().collect()
- });
- let signed_enum = self.signed_enum();
- let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| {
- x.into_iter().collect()
- });
- let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| {
- x.iter().map(|t| t.unpack()).collect()
- });
- let native_inline = self.native_inline().map(|x| {
- x.unpack()
- });
- let long_enum_non_enum_default = self.long_enum_non_enum_default();
- let long_enum_normal_default = self.long_enum_normal_default();
- let nan_default = self.nan_default();
- let inf_default = self.inf_default();
- let positive_inf_default = self.positive_inf_default();
- let infinity_default = self.infinity_default();
- let positive_infinity_default = self.positive_infinity_default();
- let negative_inf_default = self.negative_inf_default();
- let negative_infinity_default = self.negative_infinity_default();
- let double_inf_default = self.double_inf_default();
- MonsterT {
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- test,
- test4,
- testarrayofstring,
- testarrayoftables,
- enemy,
- testnestedflatbuffer,
- testempty,
- testbool,
- testhashs32_fnv1,
- testhashu32_fnv1,
- testhashs64_fnv1,
- testhashu64_fnv1,
- testhashs32_fnv1a,
- testhashu32_fnv1a,
- testhashs64_fnv1a,
- testhashu64_fnv1a,
- testarrayofbools,
- testf,
- testf2,
- testf3,
- testarrayofstring2,
- testarrayofsortedstruct,
- flex,
- test5,
- vector_of_longs,
- vector_of_doubles,
- parent_namespace_test,
- vector_of_referrables,
- single_weak_reference,
- vector_of_weak_references,
- vector_of_strong_referrables,
- co_owning_reference,
- vector_of_co_owning_references,
- non_owning_reference,
- vector_of_non_owning_references,
- any_unique,
- any_ambiguous,
- vector_of_enums,
- signed_enum,
- testrequirednestedflatbuffer,
- scalar_key_sorted_tables,
- native_inline,
- long_enum_non_enum_default,
- long_enum_normal_default,
- nan_default,
- inf_default,
- positive_inf_default,
- infinity_default,
- positive_infinity_default,
- negative_inf_default,
- negative_infinity_default,
- double_inf_default,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Monster"
}
- }
- #[inline]
- pub fn pos(&self) -> Option<&'a Vec3> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
- }
-
- #[inline]
- pub fn mana(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
- }
-
- #[inline]
- pub fn hp(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
- }
-
- #[inline]
- pub fn name(&self) -> &'a str {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()}
- }
-
- #[inline]
- pub fn key_compare_less_than(&self, o: &Monster) -> bool {
- self.name() < o.name()
- }
-
- #[inline]
- pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
- let key = self.name();
- key.cmp(val)
- }
-
- #[inline]
- pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
- }
-
- #[inline]
- pub fn color(&self) -> Color {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
- }
-
- #[inline]
- pub fn test_type(&self) -> Any {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Any>(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)}
- }
-
- #[inline]
- 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::<::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<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster>>>>(Monster::VT_TESTARRAYOFTABLES, None)}
- }
-
- #[inline]
- pub fn enemy(&self) -> Option<Monster<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Monster>>(Monster::VT_ENEMY, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)}
- }
-
- pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
- self.testnestedflatbuffer().map(|data| {
- use ::flatbuffers::Follow;
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid flatbuffer in this slot
- unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
- })
- }
-
- #[inline]
- pub fn testempty(&self) -> Option<Stat<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Stat>>(Monster::VT_TESTEMPTY, None)}
- }
-
- #[inline]
- pub fn testbool(&self) -> bool {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(Monster::VT_TESTBOOL, Some(false)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs32_fnv1(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu32_fnv1(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs64_fnv1(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu64_fnv1(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs32_fnv1a(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu32_fnv1a(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashs64_fnv1a(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- pub fn testhashu64_fnv1a(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)}
- }
-
- #[inline]
- pub fn testf(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF, Some(3.14159)).unwrap()}
- }
-
- #[inline]
- pub fn testf2(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF2, Some(3.0)).unwrap()}
- }
-
- #[inline]
- pub fn testf3(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_TESTF3, Some(0.0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)}
- }
-
- #[inline]
- pub fn parent_namespace_test(&self) -> Option<super::InParentNamespace<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, None)}
- }
-
- #[inline]
- pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)}
- }
-
- #[inline]
- pub fn single_weak_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)}
- }
-
- #[inline]
- pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)}
- }
-
- #[inline]
- pub fn co_owning_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)}
- }
-
- #[inline]
- pub fn non_owning_reference(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)}
- }
-
- #[inline]
- pub fn any_unique_type(&self) -> AnyUniqueAliases {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)}
- }
-
- #[inline]
- pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)}
- }
-
- #[inline]
- pub fn signed_enum(&self) -> Race {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Race>(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)}
- }
-
- pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
- self.testrequirednestedflatbuffer().map(|data| {
- use ::flatbuffers::Follow;
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid flatbuffer in this slot
- unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
- })
- }
-
- #[inline]
- pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat<'a>>>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat>>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)}
- }
-
- #[inline]
- pub fn native_inline(&self) -> Option<&'a Test> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Test>(Monster::VT_NATIVE_INLINE, None)}
- }
-
- #[inline]
- pub fn long_enum_non_enum_default(&self) -> LongEnum {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, Some(Default::default())).unwrap()}
- }
-
- #[inline]
- pub fn long_enum_normal_default(&self) -> LongEnum {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, Some(LongEnum::LongOne)).unwrap()}
- }
-
- #[inline]
- pub fn nan_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NAN_DEFAULT, Some(f32::NAN)).unwrap()}
- }
-
- #[inline]
- pub fn inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn positive_inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn positive_infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn negative_inf_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn negative_infinity_default(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
- }
-
- #[inline]
- pub fn double_inf_default(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(Monster::VT_DOUBLE_INF_DEFAULT, Some(f64::INFINITY)).unwrap()}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_monster(&self) -> Option<Monster<'a>> {
- if self.test_type() == Any::Monster {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Monster { _tab: table }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
- if self.test_type() == Any::TestSimpleTableWithEnum {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { TestSimpleTableWithEnum::init_from_table(t) }
- })
- } else {
- None
+ #[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>,
+ args: &'args MonsterArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
+ 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);
+ builder.add_long_enum_non_enum_default(args.long_enum_non_enum_default);
+ builder.add_non_owning_reference(args.non_owning_reference);
+ builder.add_co_owning_reference(args.co_owning_reference);
+ builder.add_single_weak_reference(args.single_weak_reference);
+ builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
+ builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
+ builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
+ builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
+ builder.add_negative_infinity_default(args.negative_infinity_default);
+ builder.add_negative_inf_default(args.negative_inf_default);
+ builder.add_positive_infinity_default(args.positive_infinity_default);
+ builder.add_infinity_default(args.infinity_default);
+ builder.add_positive_inf_default(args.positive_inf_default);
+ builder.add_inf_default(args.inf_default);
+ builder.add_nan_default(args.nan_default);
+ if let Some(x) = args.native_inline { builder.add_native_inline(x); }
+ if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
+ if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
+ if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
+ if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
+ if let Some(x) = args.any_unique { builder.add_any_unique(x); }
+ if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
+ if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
+ if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
+ if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
+ if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
+ if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
+ if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
+ if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
+ if let Some(x) = args.test5 { builder.add_test5(x); }
+ if let Some(x) = args.flex { builder.add_flex(x); }
+ if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
+ if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
+ builder.add_testf3(args.testf3);
+ builder.add_testf2(args.testf2);
+ builder.add_testf(args.testf);
+ if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
+ builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
+ builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
+ builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
+ builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
+ if let Some(x) = args.testempty { builder.add_testempty(x); }
+ if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
+ if let Some(x) = args.enemy { builder.add_enemy(x); }
+ if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
+ if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
+ if let Some(x) = args.test4 { builder.add_test4(x); }
+ if let Some(x) = args.test { builder.add_test(x); }
+ if let Some(x) = args.inventory { builder.add_inventory(x); }
+ if let Some(x) = args.name { builder.add_name(x); }
+ if let Some(x) = args.pos { builder.add_pos(x); }
+ builder.add_hp(args.hp);
+ builder.add_mana(args.mana);
+ builder.add_signed_enum(args.signed_enum);
+ builder.add_any_ambiguous_type(args.any_ambiguous_type);
+ builder.add_any_unique_type(args.any_unique_type);
+ builder.add_testbool(args.testbool);
+ builder.add_test_type(args.test_type);
+ builder.add_color(args.color);
+ builder.finish()
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
- if self.test_type() == Any::MyGame_Example2_Monster {
- self.test().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { super::example_2::Monster::init_from_table(t) }
- })
- } else {
- None
+ pub fn unpack(&self) -> MonsterT {
+ let pos = self.pos().map(|x| {
+ x.unpack()
+ });
+ let mana = self.mana();
+ let hp = self.hp();
+ let name = {
+ let x = self.name();
+ alloc::string::ToString::to_string(x)
+ };
+ let inventory = self.inventory().map(|x| {
+ x.into_iter().collect()
+ });
+ let color = self.color();
+ let test = match self.test_type() {
+ Any::NONE => AnyT::NONE,
+ Any::Monster => AnyT::Monster(alloc::boxed::Box::new(
+ self.test_as_monster()
+ .expect("Invalid union table, expected `Any::Monster`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.test_as_my_game_example_2_monster()
+ .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.")
+ .unpack()
+ )),
+ _ => AnyT::NONE,
+ };
+ let test4 = self.test4().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let testarrayofstring = self.testarrayofstring().map(|x| {
+ x.iter().map(|s| 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| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| {
+ x.into_iter().collect()
+ });
+ let testempty = self.testempty().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let testbool = self.testbool();
+ let testhashs32_fnv1 = self.testhashs32_fnv1();
+ let testhashu32_fnv1 = self.testhashu32_fnv1();
+ let testhashs64_fnv1 = self.testhashs64_fnv1();
+ let testhashu64_fnv1 = self.testhashu64_fnv1();
+ let testhashs32_fnv1a = self.testhashs32_fnv1a();
+ let testhashu32_fnv1a = self.testhashu32_fnv1a();
+ let testhashs64_fnv1a = self.testhashs64_fnv1a();
+ let testhashu64_fnv1a = self.testhashu64_fnv1a();
+ let testarrayofbools = self.testarrayofbools().map(|x| {
+ x.into_iter().collect()
+ });
+ let testf = self.testf();
+ let testf2 = self.testf2();
+ let testf3 = self.testf3();
+ let testarrayofstring2 = self.testarrayofstring2().map(|x| {
+ x.iter().map(|s| alloc::string::ToString::to_string(s)).collect()
+ });
+ let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let flex = self.flex().map(|x| {
+ x.into_iter().collect()
+ });
+ let test5 = self.test5().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let vector_of_longs = self.vector_of_longs().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_doubles = self.vector_of_doubles().map(|x| {
+ x.into_iter().collect()
+ });
+ let parent_namespace_test = self.parent_namespace_test().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let vector_of_referrables = self.vector_of_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let single_weak_reference = self.single_weak_reference();
+ let vector_of_weak_references = self.vector_of_weak_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let co_owning_reference = self.co_owning_reference();
+ let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let non_owning_reference = self.non_owning_reference();
+ let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let any_unique = match self.any_unique_type() {
+ AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE,
+ AnyUniqueAliases::M => AnyUniqueAliasesT::M(alloc::boxed::Box::new(
+ self.any_unique_as_m()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.any_unique_as_m2()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M2`.")
+ .unpack()
+ )),
+ _ => AnyUniqueAliasesT::NONE,
+ };
+ let any_ambiguous = match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE,
+ AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(alloc::boxed::Box::new(
+ self.any_ambiguous_as_m1()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.")
+ .unpack()
+ )),
+ 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(alloc::boxed::Box::new(
+ self.any_ambiguous_as_m3()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.")
+ .unpack()
+ )),
+ _ => AnyAmbiguousAliasesT::NONE,
+ };
+ let vector_of_enums = self.vector_of_enums().map(|x| {
+ x.into_iter().collect()
+ });
+ let signed_enum = self.signed_enum();
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| {
+ x.into_iter().collect()
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let native_inline = self.native_inline().map(|x| {
+ x.unpack()
+ });
+ let long_enum_non_enum_default = self.long_enum_non_enum_default();
+ let long_enum_normal_default = self.long_enum_normal_default();
+ let nan_default = self.nan_default();
+ let inf_default = self.inf_default();
+ let positive_inf_default = self.positive_inf_default();
+ let infinity_default = self.infinity_default();
+ let positive_infinity_default = self.positive_infinity_default();
+ let negative_inf_default = self.negative_inf_default();
+ let negative_infinity_default = self.negative_infinity_default();
+ let double_inf_default = self.double_inf_default();
+ MonsterT {
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ nan_default,
+ inf_default,
+ positive_inf_default,
+ infinity_default,
+ positive_infinity_default,
+ negative_inf_default,
+ negative_infinity_default,
+ double_inf_default,
+ }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::M {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn pos(&self) -> Option<&'a Vec3> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_ts(&self) -> Option<TestSimpleTableWithEnum<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::TS {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { TestSimpleTableWithEnum::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn mana(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
- if self.any_unique_type() == AnyUniqueAliases::M2 {
- self.any_unique().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { super::example_2::Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn hp(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn name(&self) -> &'a str {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()}
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Monster) -> bool {
+ self.name() < o.name()
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
- if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
- self.any_ambiguous().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { Monster::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub fn key_compare_with_value(&self, val: & str) -> ::core::cmp::Ordering {
+ let key = self.name();
+ key.cmp(val)
}
- }
+
+ #[inline]
+ pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None)}
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()}
+ }
+
+ #[inline]
+ pub fn test_type(&self) -> Any {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Any>(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_TEST, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None)}
+ }
+
+ #[inline]
+ 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::<::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<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Monster>>>>(Monster::VT_TESTARRAYOFTABLES, None)}
+ }
+
+ #[inline]
+ pub fn enemy(&self) -> Option<Monster<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Monster>>(Monster::VT_ENEMY, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None)}
+ }
+
+ pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testnestedflatbuffer().map(|data| {
+ use ::flatbuffers::Follow;
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid flatbuffer in this slot
+ unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
+ })
+ }
+
+ #[inline]
+ pub fn testempty(&self) -> Option<Stat<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<Stat>>(Monster::VT_TESTEMPTY, None)}
+ }
+
+ #[inline]
+ pub fn testbool(&self) -> bool {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(Monster::VT_TESTBOOL, Some(false)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs32_fnv1(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu32_fnv1(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs64_fnv1(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu64_fnv1(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs32_fnv1a(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu32_fnv1a(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashs64_fnv1a(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testhashu64_fnv1a(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None)}
+ }
+
+ #[inline]
+ pub fn testf(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF, Some(3.14159)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testf2(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF2, Some(3.0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn testf3(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_TESTF3, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i64>>>(Monster::VT_VECTOR_OF_LONGS, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(Monster::VT_VECTOR_OF_DOUBLES, None)}
+ }
+
+ #[inline]
+ pub fn parent_namespace_test(&self) -> Option<super::InParentNamespace<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, None)}
+ }
+
+ #[inline]
+ pub fn vector_of_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_REFERRABLES, None)}
+ }
+
+ #[inline]
+ pub fn single_weak_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_SINGLE_WEAK_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_WEAK_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn vector_of_strong_referrables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Referrable>>>>(Monster::VT_VECTOR_OF_STRONG_REFERRABLES, None)}
+ }
+
+ #[inline]
+ pub fn co_owning_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_CO_OWNING_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_CO_OWNING_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn non_owning_reference(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Monster::VT_NON_OWNING_REFERENCE, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u64>>>(Monster::VT_VECTOR_OF_NON_OWNING_REFERENCES, None)}
+ }
+
+ #[inline]
+ pub fn any_unique_type(&self) -> AnyUniqueAliases {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)}
+ }
+
+ #[inline]
+ pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(Monster::VT_ANY_AMBIGUOUS, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)}
+ }
+
+ #[inline]
+ pub fn signed_enum(&self) -> Race {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Race>(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None)}
+ }
+
+ pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testrequirednestedflatbuffer().map(|data| {
+ use ::flatbuffers::Follow;
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid flatbuffer in this slot
+ unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
+ })
+ }
+
+ #[inline]
+ pub fn scalar_key_sorted_tables(&self) -> Option<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat<'a>>>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Stat>>>>(Monster::VT_SCALAR_KEY_SORTED_TABLES, None)}
+ }
+
+ #[inline]
+ pub fn native_inline(&self) -> Option<&'a Test> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Test>(Monster::VT_NATIVE_INLINE, None)}
+ }
+
+ #[inline]
+ pub fn long_enum_non_enum_default(&self) -> LongEnum {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, Some(Default::default())).unwrap()}
+ }
+
+ #[inline]
+ pub fn long_enum_normal_default(&self) -> LongEnum {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, Some(LongEnum::LongOne)).unwrap()}
+ }
+
+ #[inline]
+ pub fn nan_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NAN_DEFAULT, Some(f32::NAN)).unwrap()}
+ }
+
+ #[inline]
+ pub fn inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn positive_inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn positive_infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, Some(f32::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn negative_inf_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn negative_infinity_default(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, Some(f32::NEG_INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ pub fn double_inf_default(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(Monster::VT_DOUBLE_INF_DEFAULT, Some(f64::INFINITY)).unwrap()}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_monster(&self) -> Option<Monster<'a>> {
+ if self.test_type() == Any::Monster {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.test_type() == Any::TestSimpleTableWithEnum {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { TestSimpleTableWithEnum::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.test_type() == Any::MyGame_Example2_Monster {
+ self.test().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { super::example_2::Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_ts(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::TS {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { TestSimpleTableWithEnum::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M2 {
+ self.any_unique().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { super::example_2::Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
+ self.any_ambiguous().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { Monster::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for Monster<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<Vec3>("pos", Self::VT_POS, false)?
- .visit_field::<i16>("mana", Self::VT_MANA, false)?
- .visit_field::<i16>("hp", Self::VT_HP, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
- .visit_field::<Color>("color", Self::VT_COLOR, false)?
- .visit_union::<Any, _>("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| {
- match key {
- Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("Any::Monster", pos),
- Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("Any::TestSimpleTableWithEnum", pos),
- Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("Any::MyGame_Example2_Monster", pos),
- _ => Ok(()),
- }
- })?
- .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<Monster>>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<Monster>>("enemy", Self::VT_ENEMY, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<Stat>>("testempty", Self::VT_TESTEMPTY, false)?
- .visit_field::<bool>("testbool", Self::VT_TESTBOOL, false)?
- .visit_field::<i32>("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)?
- .visit_field::<u32>("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)?
- .visit_field::<i64>("testhashs64_fnv1", Self::VT_TESTHASHS64_FNV1, false)?
- .visit_field::<u64>("testhashu64_fnv1", Self::VT_TESTHASHU64_FNV1, false)?
- .visit_field::<i32>("testhashs32_fnv1a", Self::VT_TESTHASHS32_FNV1A, false)?
- .visit_field::<u32>("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)?
- .visit_field::<i64>("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)?
- .visit_field::<u64>("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)?
- .visit_field::<f32>("testf", Self::VT_TESTF, false)?
- .visit_field::<f32>("testf2", Self::VT_TESTF2, false)?
- .visit_field::<f32>("testf3", Self::VT_TESTF3, 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<super::InParentNamespace>>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)?
- .visit_field::<u64>("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, 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<Referrable>>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)?
- .visit_field::<u64>("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)?
- .visit_field::<u64>("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)?
- .visit_union::<AnyUniqueAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyUniqueAliases::M", pos),
- AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("AnyUniqueAliases::TS", pos),
- AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("AnyUniqueAliases::M2", pos),
- _ => Ok(()),
- }
- })?
- .visit_union::<AnyAmbiguousAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M1", pos),
- AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M2", pos),
- AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M3", pos),
- _ => Ok(()),
- }
- })?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)?
- .visit_field::<Race>("signed_enum", Self::VT_SIGNED_ENUM, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Stat>>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)?
- .visit_field::<Test>("native_inline", Self::VT_NATIVE_INLINE, false)?
- .visit_field::<LongEnum>("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)?
- .visit_field::<LongEnum>("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)?
- .visit_field::<f32>("nan_default", Self::VT_NAN_DEFAULT, false)?
- .visit_field::<f32>("inf_default", Self::VT_INF_DEFAULT, false)?
- .visit_field::<f32>("positive_inf_default", Self::VT_POSITIVE_INF_DEFAULT, false)?
- .visit_field::<f32>("infinity_default", Self::VT_INFINITY_DEFAULT, false)?
- .visit_field::<f32>("positive_infinity_default", Self::VT_POSITIVE_INFINITY_DEFAULT, false)?
- .visit_field::<f32>("negative_inf_default", Self::VT_NEGATIVE_INF_DEFAULT, false)?
- .visit_field::<f32>("negative_infinity_default", Self::VT_NEGATIVE_INFINITY_DEFAULT, false)?
- .visit_field::<f64>("double_inf_default", Self::VT_DOUBLE_INF_DEFAULT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<Vec3>("pos", Self::VT_POS, false)?
+ .visit_field::<i16>("mana", Self::VT_MANA, false)?
+ .visit_field::<i16>("hp", Self::VT_HP, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .visit_union::<Any, _>("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| {
+ match key {
+ Any::Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("Any::Monster", pos),
+ Any::TestSimpleTableWithEnum => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("Any::TestSimpleTableWithEnum", pos),
+ Any::MyGame_Example2_Monster => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("Any::MyGame_Example2_Monster", pos),
+ _ => Ok(()),
+ }
+ })?
+ .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<Monster>>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<Monster>>("enemy", Self::VT_ENEMY, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<Stat>>("testempty", Self::VT_TESTEMPTY, false)?
+ .visit_field::<bool>("testbool", Self::VT_TESTBOOL, false)?
+ .visit_field::<i32>("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)?
+ .visit_field::<u32>("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)?
+ .visit_field::<i64>("testhashs64_fnv1", Self::VT_TESTHASHS64_FNV1, false)?
+ .visit_field::<u64>("testhashu64_fnv1", Self::VT_TESTHASHU64_FNV1, false)?
+ .visit_field::<i32>("testhashs32_fnv1a", Self::VT_TESTHASHS32_FNV1A, false)?
+ .visit_field::<u32>("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)?
+ .visit_field::<i64>("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)?
+ .visit_field::<u64>("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)?
+ .visit_field::<f32>("testf", Self::VT_TESTF, false)?
+ .visit_field::<f32>("testf2", Self::VT_TESTF2, false)?
+ .visit_field::<f32>("testf3", Self::VT_TESTF3, 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<super::InParentNamespace>>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)?
+ .visit_field::<u64>("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, 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<Referrable>>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)?
+ .visit_field::<u64>("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)?
+ .visit_field::<u64>("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)?
+ .visit_union::<AnyUniqueAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyUniqueAliases::M", pos),
+ AnyUniqueAliases::TS => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("AnyUniqueAliases::TS", pos),
+ AnyUniqueAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<super::example_2::Monster>>("AnyUniqueAliases::M2", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_union::<AnyAmbiguousAliases, _>("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::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M1", pos),
+ AnyAmbiguousAliases::M2 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M2", pos),
+ AnyAmbiguousAliases::M3 => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M3", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)?
+ .visit_field::<Race>("signed_enum", Self::VT_SIGNED_ENUM, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'_, ::flatbuffers::ForwardsUOffset<Stat>>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)?
+ .visit_field::<Test>("native_inline", Self::VT_NATIVE_INLINE, false)?
+ .visit_field::<LongEnum>("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)?
+ .visit_field::<LongEnum>("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)?
+ .visit_field::<f32>("nan_default", Self::VT_NAN_DEFAULT, false)?
+ .visit_field::<f32>("inf_default", Self::VT_INF_DEFAULT, false)?
+ .visit_field::<f32>("positive_inf_default", Self::VT_POSITIVE_INF_DEFAULT, false)?
+ .visit_field::<f32>("infinity_default", Self::VT_INFINITY_DEFAULT, false)?
+ .visit_field::<f32>("positive_infinity_default", Self::VT_POSITIVE_INFINITY_DEFAULT, false)?
+ .visit_field::<f32>("negative_inf_default", Self::VT_NEGATIVE_INF_DEFAULT, false)?
+ .visit_field::<f32>("negative_infinity_default", Self::VT_NEGATIVE_INFINITY_DEFAULT, false)?
+ .visit_field::<f64>("double_inf_default", Self::VT_DOUBLE_INF_DEFAULT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct MonsterArgs<'a> {
@@ -1204,1082 +1204,1082 @@
}
impl<'a> Default for MonsterArgs<'a> {
- #[inline]
- fn default() -> Self {
- MonsterArgs {
- pos: None,
- mana: 150,
- hp: 100,
- name: None, // required field
- inventory: None,
- color: Color::Blue,
- test_type: Any::NONE,
- test: None,
- test4: None,
- testarrayofstring: None,
- testarrayoftables: None,
- enemy: None,
- testnestedflatbuffer: None,
- testempty: None,
- testbool: false,
- testhashs32_fnv1: 0,
- testhashu32_fnv1: 0,
- testhashs64_fnv1: 0,
- testhashu64_fnv1: 0,
- testhashs32_fnv1a: 0,
- testhashu32_fnv1a: 0,
- testhashs64_fnv1a: 0,
- testhashu64_fnv1a: 0,
- testarrayofbools: None,
- testf: 3.14159,
- testf2: 3.0,
- testf3: 0.0,
- testarrayofstring2: None,
- testarrayofsortedstruct: None,
- flex: None,
- test5: None,
- vector_of_longs: None,
- vector_of_doubles: None,
- parent_namespace_test: None,
- vector_of_referrables: None,
- single_weak_reference: 0,
- vector_of_weak_references: None,
- vector_of_strong_referrables: None,
- co_owning_reference: 0,
- vector_of_co_owning_references: None,
- non_owning_reference: 0,
- vector_of_non_owning_references: None,
- any_unique_type: AnyUniqueAliases::NONE,
- any_unique: None,
- any_ambiguous_type: AnyAmbiguousAliases::NONE,
- any_ambiguous: None,
- vector_of_enums: None,
- signed_enum: Race::None,
- testrequirednestedflatbuffer: None,
- scalar_key_sorted_tables: None,
- native_inline: None,
- long_enum_non_enum_default: Default::default(),
- long_enum_normal_default: LongEnum::LongOne,
- nan_default: f32::NAN,
- inf_default: f32::INFINITY,
- positive_inf_default: f32::INFINITY,
- infinity_default: f32::INFINITY,
- positive_infinity_default: f32::INFINITY,
- negative_inf_default: f32::NEG_INFINITY,
- negative_infinity_default: f32::NEG_INFINITY,
- double_inf_default: f64::INFINITY,
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: None, // required field
+ inventory: None,
+ color: Color::Blue,
+ test_type: Any::NONE,
+ test: None,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique_type: AnyUniqueAliases::NONE,
+ any_unique: None,
+ any_ambiguous_type: AnyAmbiguousAliases::NONE,
+ any_ambiguous: None,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ nan_default: f32::NAN,
+ inf_default: f32::INFINITY,
+ positive_inf_default: f32::INFINITY,
+ infinity_default: f32::INFINITY,
+ positive_infinity_default: f32::INFINITY,
+ negative_inf_default: f32::NEG_INFINITY,
+ negative_infinity_default: f32::NEG_INFINITY,
+ double_inf_default: f64::INFINITY,
+ }
}
- }
}
impl Serialize for Monster<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("Monster", 62)?;
- if let Some(f) = self.pos() {
- s.serialize_field("pos", &f)?;
- } else {
- s.skip_field("pos")?;
- }
- s.serialize_field("mana", &self.mana())?;
- s.serialize_field("hp", &self.hp())?;
- s.serialize_field("name", &self.name())?;
- if let Some(f) = self.inventory() {
- s.serialize_field("inventory", &f)?;
- } else {
- s.skip_field("inventory")?;
- }
- s.serialize_field("color", &self.color())?;
- s.serialize_field("test_type", &self.test_type())?;
- match self.test_type() {
- Any::NONE => (),
- Any::Monster => {
- let f = self.test_as_monster()
- .expect("Invalid union table, expected `Any::Monster`.");
- s.serialize_field("test", &f)?;
- }
- Any::TestSimpleTableWithEnum => {
- let f = self.test_as_test_simple_table_with_enum()
- .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.");
- s.serialize_field("test", &f)?;
- }
- Any::MyGame_Example2_Monster => {
- let f = self.test_as_my_game_example_2_monster()
- .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.");
- s.serialize_field("test", &f)?;
- }
- _ => unimplemented!(),
- }
- if let Some(f) = self.test4() {
- s.serialize_field("test4", &f)?;
- } else {
- s.skip_field("test4")?;
- }
- if let Some(f) = self.testarrayofstring() {
- s.serialize_field("testarrayofstring", &f)?;
- } else {
- s.skip_field("testarrayofstring")?;
- }
- if let Some(f) = self.testarrayoftables() {
- s.serialize_field("testarrayoftables", &f)?;
- } else {
- s.skip_field("testarrayoftables")?;
- }
- if let Some(f) = self.enemy() {
- s.serialize_field("enemy", &f)?;
- } else {
- s.skip_field("enemy")?;
- }
- if let Some(f) = self.testnestedflatbuffer() {
- s.serialize_field("testnestedflatbuffer", &f)?;
- } else {
- s.skip_field("testnestedflatbuffer")?;
- }
- if let Some(f) = self.testempty() {
- s.serialize_field("testempty", &f)?;
- } else {
- s.skip_field("testempty")?;
- }
- s.serialize_field("testbool", &self.testbool())?;
- s.serialize_field("testhashs32_fnv1", &self.testhashs32_fnv1())?;
- s.serialize_field("testhashu32_fnv1", &self.testhashu32_fnv1())?;
- s.serialize_field("testhashs64_fnv1", &self.testhashs64_fnv1())?;
- s.serialize_field("testhashu64_fnv1", &self.testhashu64_fnv1())?;
- s.serialize_field("testhashs32_fnv1a", &self.testhashs32_fnv1a())?;
- s.serialize_field("testhashu32_fnv1a", &self.testhashu32_fnv1a())?;
- s.serialize_field("testhashs64_fnv1a", &self.testhashs64_fnv1a())?;
- s.serialize_field("testhashu64_fnv1a", &self.testhashu64_fnv1a())?;
- if let Some(f) = self.testarrayofbools() {
- s.serialize_field("testarrayofbools", &f)?;
- } else {
- s.skip_field("testarrayofbools")?;
- }
- s.serialize_field("testf", &self.testf())?;
- s.serialize_field("testf2", &self.testf2())?;
- s.serialize_field("testf3", &self.testf3())?;
- if let Some(f) = self.testarrayofstring2() {
- s.serialize_field("testarrayofstring2", &f)?;
- } else {
- s.skip_field("testarrayofstring2")?;
- }
- if let Some(f) = self.testarrayofsortedstruct() {
- s.serialize_field("testarrayofsortedstruct", &f)?;
- } else {
- s.skip_field("testarrayofsortedstruct")?;
- }
- if let Some(f) = self.flex() {
- s.serialize_field("flex", &f)?;
- } else {
- s.skip_field("flex")?;
- }
- if let Some(f) = self.test5() {
- s.serialize_field("test5", &f)?;
- } else {
- s.skip_field("test5")?;
- }
- if let Some(f) = self.vector_of_longs() {
- s.serialize_field("vector_of_longs", &f)?;
- } else {
- s.skip_field("vector_of_longs")?;
- }
- if let Some(f) = self.vector_of_doubles() {
- s.serialize_field("vector_of_doubles", &f)?;
- } else {
- s.skip_field("vector_of_doubles")?;
- }
- if let Some(f) = self.parent_namespace_test() {
- s.serialize_field("parent_namespace_test", &f)?;
- } else {
- s.skip_field("parent_namespace_test")?;
- }
- if let Some(f) = self.vector_of_referrables() {
- s.serialize_field("vector_of_referrables", &f)?;
- } else {
- s.skip_field("vector_of_referrables")?;
- }
- s.serialize_field("single_weak_reference", &self.single_weak_reference())?;
- if let Some(f) = self.vector_of_weak_references() {
- s.serialize_field("vector_of_weak_references", &f)?;
- } else {
- s.skip_field("vector_of_weak_references")?;
- }
- if let Some(f) = self.vector_of_strong_referrables() {
- s.serialize_field("vector_of_strong_referrables", &f)?;
- } else {
- s.skip_field("vector_of_strong_referrables")?;
- }
- s.serialize_field("co_owning_reference", &self.co_owning_reference())?;
- if let Some(f) = self.vector_of_co_owning_references() {
- s.serialize_field("vector_of_co_owning_references", &f)?;
- } else {
- s.skip_field("vector_of_co_owning_references")?;
- }
- s.serialize_field("non_owning_reference", &self.non_owning_reference())?;
- if let Some(f) = self.vector_of_non_owning_references() {
- s.serialize_field("vector_of_non_owning_references", &f)?;
- } else {
- s.skip_field("vector_of_non_owning_references")?;
- }
- s.serialize_field("any_unique_type", &self.any_unique_type())?;
- match self.any_unique_type() {
- AnyUniqueAliases::NONE => (),
- AnyUniqueAliases::M => {
- let f = self.any_unique_as_m()
- .expect("Invalid union table, expected `AnyUniqueAliases::M`.");
- s.serialize_field("any_unique", &f)?;
- }
- AnyUniqueAliases::TS => {
- let f = self.any_unique_as_ts()
- .expect("Invalid union table, expected `AnyUniqueAliases::TS`.");
- s.serialize_field("any_unique", &f)?;
- }
- AnyUniqueAliases::M2 => {
- let f = self.any_unique_as_m2()
- .expect("Invalid union table, expected `AnyUniqueAliases::M2`.");
- s.serialize_field("any_unique", &f)?;
- }
- _ => unimplemented!(),
- }
- s.serialize_field("any_ambiguous_type", &self.any_ambiguous_type())?;
- match self.any_ambiguous_type() {
- AnyAmbiguousAliases::NONE => (),
- AnyAmbiguousAliases::M1 => {
- let f = self.any_ambiguous_as_m1()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.");
- s.serialize_field("any_ambiguous", &f)?;
- }
- AnyAmbiguousAliases::M2 => {
- let f = self.any_ambiguous_as_m2()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.");
- s.serialize_field("any_ambiguous", &f)?;
- }
- AnyAmbiguousAliases::M3 => {
- let f = self.any_ambiguous_as_m3()
- .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.");
- s.serialize_field("any_ambiguous", &f)?;
- }
- _ => unimplemented!(),
- }
- if let Some(f) = self.vector_of_enums() {
- s.serialize_field("vector_of_enums", &f)?;
- } else {
- s.skip_field("vector_of_enums")?;
- }
- s.serialize_field("signed_enum", &self.signed_enum())?;
- if let Some(f) = self.testrequirednestedflatbuffer() {
- s.serialize_field("testrequirednestedflatbuffer", &f)?;
- } else {
- s.skip_field("testrequirednestedflatbuffer")?;
- }
- if let Some(f) = self.scalar_key_sorted_tables() {
- s.serialize_field("scalar_key_sorted_tables", &f)?;
- } else {
- s.skip_field("scalar_key_sorted_tables")?;
- }
- if let Some(f) = self.native_inline() {
- s.serialize_field("native_inline", &f)?;
- } else {
- s.skip_field("native_inline")?;
- }
- s.serialize_field("long_enum_non_enum_default", &self.long_enum_non_enum_default())?;
- s.serialize_field("long_enum_normal_default", &self.long_enum_normal_default())?;
- s.serialize_field("nan_default", &self.nan_default())?;
- s.serialize_field("inf_default", &self.inf_default())?;
- s.serialize_field("positive_inf_default", &self.positive_inf_default())?;
- s.serialize_field("infinity_default", &self.infinity_default())?;
- s.serialize_field("positive_infinity_default", &self.positive_infinity_default())?;
- s.serialize_field("negative_inf_default", &self.negative_inf_default())?;
- s.serialize_field("negative_infinity_default", &self.negative_infinity_default())?;
- s.serialize_field("double_inf_default", &self.double_inf_default())?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("Monster", 62)?;
+ if let Some(f) = self.pos() {
+ s.serialize_field("pos", &f)?;
+ } else {
+ s.skip_field("pos")?;
+ }
+ s.serialize_field("mana", &self.mana())?;
+ s.serialize_field("hp", &self.hp())?;
+ s.serialize_field("name", &self.name())?;
+ if let Some(f) = self.inventory() {
+ s.serialize_field("inventory", &f)?;
+ } else {
+ s.skip_field("inventory")?;
+ }
+ s.serialize_field("color", &self.color())?;
+ s.serialize_field("test_type", &self.test_type())?;
+ match self.test_type() {
+ Any::NONE => (),
+ Any::Monster => {
+ let f = self.test_as_monster()
+ .expect("Invalid union table, expected `Any::Monster`.");
+ s.serialize_field("test", &f)?;
+ }
+ Any::TestSimpleTableWithEnum => {
+ let f = self.test_as_test_simple_table_with_enum()
+ .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.");
+ s.serialize_field("test", &f)?;
+ }
+ Any::MyGame_Example2_Monster => {
+ let f = self.test_as_my_game_example_2_monster()
+ .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.");
+ s.serialize_field("test", &f)?;
+ }
+ _ => unimplemented!(),
+ }
+ if let Some(f) = self.test4() {
+ s.serialize_field("test4", &f)?;
+ } else {
+ s.skip_field("test4")?;
+ }
+ if let Some(f) = self.testarrayofstring() {
+ s.serialize_field("testarrayofstring", &f)?;
+ } else {
+ s.skip_field("testarrayofstring")?;
+ }
+ if let Some(f) = self.testarrayoftables() {
+ s.serialize_field("testarrayoftables", &f)?;
+ } else {
+ s.skip_field("testarrayoftables")?;
+ }
+ if let Some(f) = self.enemy() {
+ s.serialize_field("enemy", &f)?;
+ } else {
+ s.skip_field("enemy")?;
+ }
+ if let Some(f) = self.testnestedflatbuffer() {
+ s.serialize_field("testnestedflatbuffer", &f)?;
+ } else {
+ s.skip_field("testnestedflatbuffer")?;
+ }
+ if let Some(f) = self.testempty() {
+ s.serialize_field("testempty", &f)?;
+ } else {
+ s.skip_field("testempty")?;
+ }
+ s.serialize_field("testbool", &self.testbool())?;
+ s.serialize_field("testhashs32_fnv1", &self.testhashs32_fnv1())?;
+ s.serialize_field("testhashu32_fnv1", &self.testhashu32_fnv1())?;
+ s.serialize_field("testhashs64_fnv1", &self.testhashs64_fnv1())?;
+ s.serialize_field("testhashu64_fnv1", &self.testhashu64_fnv1())?;
+ s.serialize_field("testhashs32_fnv1a", &self.testhashs32_fnv1a())?;
+ s.serialize_field("testhashu32_fnv1a", &self.testhashu32_fnv1a())?;
+ s.serialize_field("testhashs64_fnv1a", &self.testhashs64_fnv1a())?;
+ s.serialize_field("testhashu64_fnv1a", &self.testhashu64_fnv1a())?;
+ if let Some(f) = self.testarrayofbools() {
+ s.serialize_field("testarrayofbools", &f)?;
+ } else {
+ s.skip_field("testarrayofbools")?;
+ }
+ s.serialize_field("testf", &self.testf())?;
+ s.serialize_field("testf2", &self.testf2())?;
+ s.serialize_field("testf3", &self.testf3())?;
+ if let Some(f) = self.testarrayofstring2() {
+ s.serialize_field("testarrayofstring2", &f)?;
+ } else {
+ s.skip_field("testarrayofstring2")?;
+ }
+ if let Some(f) = self.testarrayofsortedstruct() {
+ s.serialize_field("testarrayofsortedstruct", &f)?;
+ } else {
+ s.skip_field("testarrayofsortedstruct")?;
+ }
+ if let Some(f) = self.flex() {
+ s.serialize_field("flex", &f)?;
+ } else {
+ s.skip_field("flex")?;
+ }
+ if let Some(f) = self.test5() {
+ s.serialize_field("test5", &f)?;
+ } else {
+ s.skip_field("test5")?;
+ }
+ if let Some(f) = self.vector_of_longs() {
+ s.serialize_field("vector_of_longs", &f)?;
+ } else {
+ s.skip_field("vector_of_longs")?;
+ }
+ if let Some(f) = self.vector_of_doubles() {
+ s.serialize_field("vector_of_doubles", &f)?;
+ } else {
+ s.skip_field("vector_of_doubles")?;
+ }
+ if let Some(f) = self.parent_namespace_test() {
+ s.serialize_field("parent_namespace_test", &f)?;
+ } else {
+ s.skip_field("parent_namespace_test")?;
+ }
+ if let Some(f) = self.vector_of_referrables() {
+ s.serialize_field("vector_of_referrables", &f)?;
+ } else {
+ s.skip_field("vector_of_referrables")?;
+ }
+ s.serialize_field("single_weak_reference", &self.single_weak_reference())?;
+ if let Some(f) = self.vector_of_weak_references() {
+ s.serialize_field("vector_of_weak_references", &f)?;
+ } else {
+ s.skip_field("vector_of_weak_references")?;
+ }
+ if let Some(f) = self.vector_of_strong_referrables() {
+ s.serialize_field("vector_of_strong_referrables", &f)?;
+ } else {
+ s.skip_field("vector_of_strong_referrables")?;
+ }
+ s.serialize_field("co_owning_reference", &self.co_owning_reference())?;
+ if let Some(f) = self.vector_of_co_owning_references() {
+ s.serialize_field("vector_of_co_owning_references", &f)?;
+ } else {
+ s.skip_field("vector_of_co_owning_references")?;
+ }
+ s.serialize_field("non_owning_reference", &self.non_owning_reference())?;
+ if let Some(f) = self.vector_of_non_owning_references() {
+ s.serialize_field("vector_of_non_owning_references", &f)?;
+ } else {
+ s.skip_field("vector_of_non_owning_references")?;
+ }
+ s.serialize_field("any_unique_type", &self.any_unique_type())?;
+ match self.any_unique_type() {
+ AnyUniqueAliases::NONE => (),
+ AnyUniqueAliases::M => {
+ let f = self.any_unique_as_m()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M`.");
+ s.serialize_field("any_unique", &f)?;
+ }
+ AnyUniqueAliases::TS => {
+ let f = self.any_unique_as_ts()
+ .expect("Invalid union table, expected `AnyUniqueAliases::TS`.");
+ s.serialize_field("any_unique", &f)?;
+ }
+ AnyUniqueAliases::M2 => {
+ let f = self.any_unique_as_m2()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M2`.");
+ s.serialize_field("any_unique", &f)?;
+ }
+ _ => unimplemented!(),
+ }
+ s.serialize_field("any_ambiguous_type", &self.any_ambiguous_type())?;
+ match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::NONE => (),
+ AnyAmbiguousAliases::M1 => {
+ let f = self.any_ambiguous_as_m1()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.");
+ s.serialize_field("any_ambiguous", &f)?;
+ }
+ AnyAmbiguousAliases::M2 => {
+ let f = self.any_ambiguous_as_m2()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.");
+ s.serialize_field("any_ambiguous", &f)?;
+ }
+ AnyAmbiguousAliases::M3 => {
+ let f = self.any_ambiguous_as_m3()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.");
+ s.serialize_field("any_ambiguous", &f)?;
+ }
+ _ => unimplemented!(),
+ }
+ if let Some(f) = self.vector_of_enums() {
+ s.serialize_field("vector_of_enums", &f)?;
+ } else {
+ s.skip_field("vector_of_enums")?;
+ }
+ s.serialize_field("signed_enum", &self.signed_enum())?;
+ if let Some(f) = self.testrequirednestedflatbuffer() {
+ s.serialize_field("testrequirednestedflatbuffer", &f)?;
+ } else {
+ s.skip_field("testrequirednestedflatbuffer")?;
+ }
+ if let Some(f) = self.scalar_key_sorted_tables() {
+ s.serialize_field("scalar_key_sorted_tables", &f)?;
+ } else {
+ s.skip_field("scalar_key_sorted_tables")?;
+ }
+ if let Some(f) = self.native_inline() {
+ s.serialize_field("native_inline", &f)?;
+ } else {
+ s.skip_field("native_inline")?;
+ }
+ s.serialize_field("long_enum_non_enum_default", &self.long_enum_non_enum_default())?;
+ s.serialize_field("long_enum_normal_default", &self.long_enum_normal_default())?;
+ s.serialize_field("nan_default", &self.nan_default())?;
+ s.serialize_field("inf_default", &self.inf_default())?;
+ s.serialize_field("positive_inf_default", &self.positive_inf_default())?;
+ s.serialize_field("infinity_default", &self.infinity_default())?;
+ s.serialize_field("positive_infinity_default", &self.positive_infinity_default())?;
+ s.serialize_field("negative_inf_default", &self.negative_inf_default())?;
+ s.serialize_field("negative_infinity_default", &self.negative_infinity_default())?;
+ s.serialize_field("double_inf_default", &self.double_inf_default())?;
+ s.end()
+ }
}
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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);
- }
-
- #[inline]
- pub fn add_mana(&mut self, mana: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
- }
-
- #[inline]
- pub fn add_hp(&mut self, hp: i16) {
- self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
- }
-
- #[inline]
- pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
- }
-
- #[inline]
- pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
- }
-
- #[inline]
- pub fn add_color(&mut self, color: Color) {
- self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
- }
-
- #[inline]
- pub fn add_test_type(&mut self, test_type: Any) {
- self.fbb_.push_slot::<Any>(Monster::VT_TEST_TYPE, test_type, Any::NONE);
- }
-
- #[inline]
- 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<::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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Monster<'b >>>>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
- }
-
- #[inline]
- pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset<Monster<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Monster>>(Monster::VT_ENEMY, enemy);
- }
-
- #[inline]
- 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<Stat<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Stat>>(Monster::VT_TESTEMPTY, testempty);
- }
-
- #[inline]
- pub fn add_testbool(&mut self, testbool: bool) {
- self.fbb_.push_slot::<bool>(Monster::VT_TESTBOOL, testbool, false);
- }
-
- #[inline]
- pub fn add_testhashs32_fnv1(&mut self, testhashs32_fnv1: i32) {
- self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashu32_fnv1(&mut self, testhashu32_fnv1: u32) {
- self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashs64_fnv1(&mut self, testhashs64_fnv1: i64) {
- self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashu64_fnv1(&mut self, testhashu64_fnv1: u64) {
- self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
- }
-
- #[inline]
- pub fn add_testhashs32_fnv1a(&mut self, testhashs32_fnv1a: i32) {
- self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashu32_fnv1a(&mut self, testhashu32_fnv1a: u32) {
- self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashs64_fnv1a(&mut self, testhashs64_fnv1a: i64) {
- self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
- }
-
- #[inline]
- pub fn add_testhashu64_fnv1a(&mut self, testhashu64_fnv1a: u64) {
- self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
- }
-
- #[inline]
- 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) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF, testf, 3.14159);
- }
-
- #[inline]
- pub fn add_testf2(&mut self, testf2: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF2, testf2, 3.0);
- }
-
- #[inline]
- pub fn add_testf3(&mut self, testf3: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_TESTF3, testf3, 0.0);
- }
-
- #[inline]
- 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<::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<::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<::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<::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<::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<super::InParentNamespace<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
- }
-
- #[inline]
- pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
- 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::<u64>(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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
- 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::<u64>(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<::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::<u64>(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<::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::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE);
- }
-
- #[inline]
- 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::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE);
- }
-
- #[inline]
- 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<::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::<Race>(Monster::VT_SIGNED_ENUM, signed_enum, Race::None);
- }
-
- #[inline]
- 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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Stat<'b >>>>) {
- 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) {
- self.fbb_.push_slot_always::<&Test>(Monster::VT_NATIVE_INLINE, native_inline);
- }
-
- #[inline]
- pub fn add_long_enum_non_enum_default(&mut self, long_enum_non_enum_default: LongEnum) {
- self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, long_enum_non_enum_default, Default::default());
- }
-
- #[inline]
- pub fn add_long_enum_normal_default(&mut self, long_enum_normal_default: LongEnum) {
- self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, long_enum_normal_default, LongEnum::LongOne);
- }
-
- #[inline]
- pub fn add_nan_default(&mut self, nan_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NAN_DEFAULT, nan_default, f32::NAN);
- }
-
- #[inline]
- pub fn add_inf_default(&mut self, inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_INF_DEFAULT, inf_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_positive_inf_default(&mut self, positive_inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, positive_inf_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_infinity_default(&mut self, infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_INFINITY_DEFAULT, infinity_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_positive_infinity_default(&mut self, positive_infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, positive_infinity_default, f32::INFINITY);
- }
-
- #[inline]
- pub fn add_negative_inf_default(&mut self, negative_inf_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, negative_inf_default, f32::NEG_INFINITY);
- }
-
- #[inline]
- pub fn add_negative_infinity_default(&mut self, negative_infinity_default: f32) {
- self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, negative_infinity_default, f32::NEG_INFINITY);
- }
-
- #[inline]
- pub fn add_double_inf_default(&mut self, double_inf_default: f64) {
- self.fbb_.push_slot::<f64>(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> {
- let start = _fbb.start_table();
- MonsterBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_pos(&mut self, pos: &Vec3) {
+ self.fbb_.push_slot_always::<&Vec3>(Monster::VT_POS, pos);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
- let o = self.fbb_.end_table(self.start_);
- self.fbb_.required(o, Monster::VT_NAME,"name");
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_mana(&mut self, mana: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_MANA, mana, 150);
+ }
+
+ #[inline]
+ pub fn add_hp(&mut self, hp: i16) {
+ self.fbb_.push_slot::<i16>(Monster::VT_HP, hp, 100);
+ }
+
+ #[inline]
+ pub fn add_name(&mut self, name: ::flatbuffers::WIPOffset<&'b str>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_NAME, name);
+ }
+
+ #[inline]
+ pub fn add_inventory(&mut self, inventory: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , u8>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_INVENTORY, inventory);
+ }
+
+ #[inline]
+ pub fn add_color(&mut self, color: Color) {
+ self.fbb_.push_slot::<Color>(Monster::VT_COLOR, color, Color::Blue);
+ }
+
+ #[inline]
+ pub fn add_test_type(&mut self, test_type: Any) {
+ self.fbb_.push_slot::<Any>(Monster::VT_TEST_TYPE, test_type, Any::NONE);
+ }
+
+ #[inline]
+ 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<::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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Monster<'b >>>>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<_>>(Monster::VT_TESTARRAYOFTABLES, testarrayoftables);
+ }
+
+ #[inline]
+ pub fn add_enemy(&mut self, enemy: ::flatbuffers::WIPOffset<Monster<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Monster>>(Monster::VT_ENEMY, enemy);
+ }
+
+ #[inline]
+ 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<Stat<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<Stat>>(Monster::VT_TESTEMPTY, testempty);
+ }
+
+ #[inline]
+ pub fn add_testbool(&mut self, testbool: bool) {
+ self.fbb_.push_slot::<bool>(Monster::VT_TESTBOOL, testbool, false);
+ }
+
+ #[inline]
+ pub fn add_testhashs32_fnv1(&mut self, testhashs32_fnv1: i32) {
+ self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1, testhashs32_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu32_fnv1(&mut self, testhashu32_fnv1: u32) {
+ self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1, testhashu32_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs64_fnv1(&mut self, testhashs64_fnv1: i64) {
+ self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1, testhashs64_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu64_fnv1(&mut self, testhashu64_fnv1: u64) {
+ self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1, testhashu64_fnv1, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs32_fnv1a(&mut self, testhashs32_fnv1a: i32) {
+ self.fbb_.push_slot::<i32>(Monster::VT_TESTHASHS32_FNV1A, testhashs32_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu32_fnv1a(&mut self, testhashu32_fnv1a: u32) {
+ self.fbb_.push_slot::<u32>(Monster::VT_TESTHASHU32_FNV1A, testhashu32_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashs64_fnv1a(&mut self, testhashs64_fnv1a: i64) {
+ self.fbb_.push_slot::<i64>(Monster::VT_TESTHASHS64_FNV1A, testhashs64_fnv1a, 0);
+ }
+
+ #[inline]
+ pub fn add_testhashu64_fnv1a(&mut self, testhashu64_fnv1a: u64) {
+ self.fbb_.push_slot::<u64>(Monster::VT_TESTHASHU64_FNV1A, testhashu64_fnv1a, 0);
+ }
+
+ #[inline]
+ 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) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF, testf, 3.14159);
+ }
+
+ #[inline]
+ pub fn add_testf2(&mut self, testf2: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF2, testf2, 3.0);
+ }
+
+ #[inline]
+ pub fn add_testf3(&mut self, testf3: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_TESTF3, testf3, 0.0);
+ }
+
+ #[inline]
+ 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<::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<::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<::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<::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<::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<super::InParentNamespace<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::InParentNamespace>>(Monster::VT_PARENT_NAMESPACE_TEST, parent_namespace_test);
+ }
+
+ #[inline]
+ pub fn add_vector_of_referrables(&mut self, vector_of_referrables: ::flatbuffers::WIPOffset<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
+ 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::<u64>(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<::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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Referrable<'b >>>>) {
+ 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::<u64>(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<::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::<u64>(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<::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::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, any_unique_type, AnyUniqueAliases::NONE);
+ }
+
+ #[inline]
+ 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::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, any_ambiguous_type, AnyAmbiguousAliases::NONE);
+ }
+
+ #[inline]
+ 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<::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::<Race>(Monster::VT_SIGNED_ENUM, signed_enum, Race::None);
+ }
+
+ #[inline]
+ 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<::flatbuffers::Vector<'b , ::flatbuffers::ForwardsUOffset<Stat<'b >>>>) {
+ 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) {
+ self.fbb_.push_slot_always::<&Test>(Monster::VT_NATIVE_INLINE, native_inline);
+ }
+
+ #[inline]
+ pub fn add_long_enum_non_enum_default(&mut self, long_enum_non_enum_default: LongEnum) {
+ self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, long_enum_non_enum_default, Default::default());
+ }
+
+ #[inline]
+ pub fn add_long_enum_normal_default(&mut self, long_enum_normal_default: LongEnum) {
+ self.fbb_.push_slot::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, long_enum_normal_default, LongEnum::LongOne);
+ }
+
+ #[inline]
+ pub fn add_nan_default(&mut self, nan_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NAN_DEFAULT, nan_default, f32::NAN);
+ }
+
+ #[inline]
+ pub fn add_inf_default(&mut self, inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_INF_DEFAULT, inf_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_positive_inf_default(&mut self, positive_inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INF_DEFAULT, positive_inf_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_infinity_default(&mut self, infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_INFINITY_DEFAULT, infinity_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_positive_infinity_default(&mut self, positive_infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_POSITIVE_INFINITY_DEFAULT, positive_infinity_default, f32::INFINITY);
+ }
+
+ #[inline]
+ pub fn add_negative_inf_default(&mut self, negative_inf_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INF_DEFAULT, negative_inf_default, f32::NEG_INFINITY);
+ }
+
+ #[inline]
+ pub fn add_negative_infinity_default(&mut self, negative_infinity_default: f32) {
+ self.fbb_.push_slot::<f32>(Monster::VT_NEGATIVE_INFINITY_DEFAULT, negative_infinity_default, f32::NEG_INFINITY);
+ }
+
+ #[inline]
+ pub fn add_double_inf_default(&mut self, double_inf_default: f64) {
+ self.fbb_.push_slot::<f64>(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> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ self.fbb_.required(o, Monster::VT_NAME,"name");
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("hp", &self.hp());
- ds.field("name", &self.name());
- ds.field("inventory", &self.inventory());
- ds.field("color", &self.color());
- ds.field("test_type", &self.test_type());
- match self.test_type() {
- Any::Monster => {
- if let Some(x) = self.test_as_monster() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- Any::TestSimpleTableWithEnum => {
- if let Some(x) = self.test_as_test_simple_table_with_enum() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- Any::MyGame_Example2_Monster => {
- if let Some(x) = self.test_as_my_game_example_2_monster() {
- ds.field("test", &x)
- } else {
- ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("test", &x)
- },
- };
- ds.field("test4", &self.test4());
- ds.field("testarrayofstring", &self.testarrayofstring());
- ds.field("testarrayoftables", &self.testarrayoftables());
- ds.field("enemy", &self.enemy());
- ds.field("testnestedflatbuffer", &self.testnestedflatbuffer());
- ds.field("testempty", &self.testempty());
- ds.field("testbool", &self.testbool());
- ds.field("testhashs32_fnv1", &self.testhashs32_fnv1());
- ds.field("testhashu32_fnv1", &self.testhashu32_fnv1());
- ds.field("testhashs64_fnv1", &self.testhashs64_fnv1());
- ds.field("testhashu64_fnv1", &self.testhashu64_fnv1());
- ds.field("testhashs32_fnv1a", &self.testhashs32_fnv1a());
- ds.field("testhashu32_fnv1a", &self.testhashu32_fnv1a());
- ds.field("testhashs64_fnv1a", &self.testhashs64_fnv1a());
- ds.field("testhashu64_fnv1a", &self.testhashu64_fnv1a());
- ds.field("testarrayofbools", &self.testarrayofbools());
- ds.field("testf", &self.testf());
- ds.field("testf2", &self.testf2());
- ds.field("testf3", &self.testf3());
- ds.field("testarrayofstring2", &self.testarrayofstring2());
- ds.field("testarrayofsortedstruct", &self.testarrayofsortedstruct());
- ds.field("flex", &self.flex());
- ds.field("test5", &self.test5());
- ds.field("vector_of_longs", &self.vector_of_longs());
- ds.field("vector_of_doubles", &self.vector_of_doubles());
- ds.field("parent_namespace_test", &self.parent_namespace_test());
- ds.field("vector_of_referrables", &self.vector_of_referrables());
- ds.field("single_weak_reference", &self.single_weak_reference());
- ds.field("vector_of_weak_references", &self.vector_of_weak_references());
- ds.field("vector_of_strong_referrables", &self.vector_of_strong_referrables());
- ds.field("co_owning_reference", &self.co_owning_reference());
- ds.field("vector_of_co_owning_references", &self.vector_of_co_owning_references());
- ds.field("non_owning_reference", &self.non_owning_reference());
- ds.field("vector_of_non_owning_references", &self.vector_of_non_owning_references());
- ds.field("any_unique_type", &self.any_unique_type());
- match self.any_unique_type() {
- AnyUniqueAliases::M => {
- if let Some(x) = self.any_unique_as_m() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyUniqueAliases::TS => {
- if let Some(x) = self.any_unique_as_ts() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyUniqueAliases::M2 => {
- if let Some(x) = self.any_unique_as_m2() {
- ds.field("any_unique", &x)
- } else {
- ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("any_unique", &x)
- },
- };
- ds.field("any_ambiguous_type", &self.any_ambiguous_type());
- match self.any_ambiguous_type() {
- AnyAmbiguousAliases::M1 => {
- if let Some(x) = self.any_ambiguous_as_m1() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyAmbiguousAliases::M2 => {
- if let Some(x) = self.any_ambiguous_as_m2() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- AnyAmbiguousAliases::M3 => {
- if let Some(x) = self.any_ambiguous_as_m3() {
- ds.field("any_ambiguous", &x)
- } else {
- ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("any_ambiguous", &x)
- },
- };
- ds.field("vector_of_enums", &self.vector_of_enums());
- ds.field("signed_enum", &self.signed_enum());
- ds.field("testrequirednestedflatbuffer", &self.testrequirednestedflatbuffer());
- ds.field("scalar_key_sorted_tables", &self.scalar_key_sorted_tables());
- ds.field("native_inline", &self.native_inline());
- ds.field("long_enum_non_enum_default", &self.long_enum_non_enum_default());
- ds.field("long_enum_normal_default", &self.long_enum_normal_default());
- ds.field("nan_default", &self.nan_default());
- ds.field("inf_default", &self.inf_default());
- ds.field("positive_inf_default", &self.positive_inf_default());
- ds.field("infinity_default", &self.infinity_default());
- ds.field("positive_infinity_default", &self.positive_infinity_default());
- ds.field("negative_inf_default", &self.negative_inf_default());
- ds.field("negative_infinity_default", &self.negative_infinity_default());
- ds.field("double_inf_default", &self.double_inf_default());
- ds.finish()
- }
+ 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());
+ ds.field("hp", &self.hp());
+ ds.field("name", &self.name());
+ ds.field("inventory", &self.inventory());
+ ds.field("color", &self.color());
+ ds.field("test_type", &self.test_type());
+ match self.test_type() {
+ Any::Monster => {
+ if let Some(x) = self.test_as_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::TestSimpleTableWithEnum => {
+ if let Some(x) = self.test_as_test_simple_table_with_enum() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::MyGame_Example2_Monster => {
+ if let Some(x) = self.test_as_my_game_example_2_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("test", &x)
+ },
+ };
+ ds.field("test4", &self.test4());
+ ds.field("testarrayofstring", &self.testarrayofstring());
+ ds.field("testarrayoftables", &self.testarrayoftables());
+ ds.field("enemy", &self.enemy());
+ ds.field("testnestedflatbuffer", &self.testnestedflatbuffer());
+ ds.field("testempty", &self.testempty());
+ ds.field("testbool", &self.testbool());
+ ds.field("testhashs32_fnv1", &self.testhashs32_fnv1());
+ ds.field("testhashu32_fnv1", &self.testhashu32_fnv1());
+ ds.field("testhashs64_fnv1", &self.testhashs64_fnv1());
+ ds.field("testhashu64_fnv1", &self.testhashu64_fnv1());
+ ds.field("testhashs32_fnv1a", &self.testhashs32_fnv1a());
+ ds.field("testhashu32_fnv1a", &self.testhashu32_fnv1a());
+ ds.field("testhashs64_fnv1a", &self.testhashs64_fnv1a());
+ ds.field("testhashu64_fnv1a", &self.testhashu64_fnv1a());
+ ds.field("testarrayofbools", &self.testarrayofbools());
+ ds.field("testf", &self.testf());
+ ds.field("testf2", &self.testf2());
+ ds.field("testf3", &self.testf3());
+ ds.field("testarrayofstring2", &self.testarrayofstring2());
+ ds.field("testarrayofsortedstruct", &self.testarrayofsortedstruct());
+ ds.field("flex", &self.flex());
+ ds.field("test5", &self.test5());
+ ds.field("vector_of_longs", &self.vector_of_longs());
+ ds.field("vector_of_doubles", &self.vector_of_doubles());
+ ds.field("parent_namespace_test", &self.parent_namespace_test());
+ ds.field("vector_of_referrables", &self.vector_of_referrables());
+ ds.field("single_weak_reference", &self.single_weak_reference());
+ ds.field("vector_of_weak_references", &self.vector_of_weak_references());
+ ds.field("vector_of_strong_referrables", &self.vector_of_strong_referrables());
+ ds.field("co_owning_reference", &self.co_owning_reference());
+ ds.field("vector_of_co_owning_references", &self.vector_of_co_owning_references());
+ ds.field("non_owning_reference", &self.non_owning_reference());
+ ds.field("vector_of_non_owning_references", &self.vector_of_non_owning_references());
+ ds.field("any_unique_type", &self.any_unique_type());
+ match self.any_unique_type() {
+ AnyUniqueAliases::M => {
+ if let Some(x) = self.any_unique_as_m() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::TS => {
+ if let Some(x) = self.any_unique_as_ts() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::M2 => {
+ if let Some(x) = self.any_unique_as_m2() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_unique", &x)
+ },
+ };
+ ds.field("any_ambiguous_type", &self.any_ambiguous_type());
+ match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::M1 => {
+ if let Some(x) = self.any_ambiguous_as_m1() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M2 => {
+ if let Some(x) = self.any_ambiguous_as_m2() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M3 => {
+ if let Some(x) = self.any_ambiguous_as_m3() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_ambiguous", &x)
+ },
+ };
+ ds.field("vector_of_enums", &self.vector_of_enums());
+ ds.field("signed_enum", &self.signed_enum());
+ ds.field("testrequirednestedflatbuffer", &self.testrequirednestedflatbuffer());
+ ds.field("scalar_key_sorted_tables", &self.scalar_key_sorted_tables());
+ ds.field("native_inline", &self.native_inline());
+ ds.field("long_enum_non_enum_default", &self.long_enum_non_enum_default());
+ ds.field("long_enum_normal_default", &self.long_enum_normal_default());
+ ds.field("nan_default", &self.nan_default());
+ ds.field("inf_default", &self.inf_default());
+ ds.field("positive_inf_default", &self.positive_inf_default());
+ ds.field("infinity_default", &self.infinity_default());
+ ds.field("positive_infinity_default", &self.positive_infinity_default());
+ ds.field("negative_inf_default", &self.negative_inf_default());
+ ds.field("negative_infinity_default", &self.negative_infinity_default());
+ ds.field("double_inf_default", &self.double_inf_default());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
- pub pos: Option<Vec3T>,
- pub mana: i16,
- pub hp: i16,
- pub name: alloc::string::String,
- pub inventory: Option<alloc::vec::Vec<u8>>,
- pub color: Color,
- pub test: AnyT,
- pub test4: Option<alloc::vec::Vec<TestT>>,
- pub testarrayofstring: Option<alloc::vec::Vec<alloc::string::String>>,
- pub testarrayoftables: Option<alloc::vec::Vec<MonsterT>>,
- pub enemy: Option<alloc::boxed::Box<MonsterT>>,
- pub testnestedflatbuffer: Option<alloc::vec::Vec<u8>>,
- pub testempty: Option<alloc::boxed::Box<StatT>>,
- pub testbool: bool,
- pub testhashs32_fnv1: i32,
- pub testhashu32_fnv1: u32,
- pub testhashs64_fnv1: i64,
- pub testhashu64_fnv1: u64,
- pub testhashs32_fnv1a: i32,
- pub testhashu32_fnv1a: u32,
- pub testhashs64_fnv1a: i64,
- pub testhashu64_fnv1a: u64,
- pub testarrayofbools: Option<alloc::vec::Vec<bool>>,
- pub testf: f32,
- pub testf2: f32,
- pub testf3: f32,
- pub testarrayofstring2: Option<alloc::vec::Vec<alloc::string::String>>,
- pub testarrayofsortedstruct: Option<alloc::vec::Vec<AbilityT>>,
- pub flex: Option<alloc::vec::Vec<u8>>,
- pub test5: Option<alloc::vec::Vec<TestT>>,
- pub vector_of_longs: Option<alloc::vec::Vec<i64>>,
- pub vector_of_doubles: Option<alloc::vec::Vec<f64>>,
- pub parent_namespace_test: Option<alloc::boxed::Box<super::InParentNamespaceT>>,
- pub vector_of_referrables: Option<alloc::vec::Vec<ReferrableT>>,
- pub single_weak_reference: u64,
- pub vector_of_weak_references: Option<alloc::vec::Vec<u64>>,
- pub vector_of_strong_referrables: Option<alloc::vec::Vec<ReferrableT>>,
- pub co_owning_reference: u64,
- pub vector_of_co_owning_references: Option<alloc::vec::Vec<u64>>,
- pub non_owning_reference: u64,
- pub vector_of_non_owning_references: Option<alloc::vec::Vec<u64>>,
- pub any_unique: AnyUniqueAliasesT,
- pub any_ambiguous: AnyAmbiguousAliasesT,
- pub vector_of_enums: Option<alloc::vec::Vec<Color>>,
- pub signed_enum: Race,
- pub testrequirednestedflatbuffer: Option<alloc::vec::Vec<u8>>,
- pub scalar_key_sorted_tables: Option<alloc::vec::Vec<StatT>>,
- pub native_inline: Option<TestT>,
- pub long_enum_non_enum_default: LongEnum,
- pub long_enum_normal_default: LongEnum,
- pub nan_default: f32,
- pub inf_default: f32,
- pub positive_inf_default: f32,
- pub infinity_default: f32,
- pub positive_infinity_default: f32,
- pub negative_inf_default: f32,
- pub negative_infinity_default: f32,
- pub double_inf_default: f64,
+ pub pos: Option<Vec3T>,
+ pub mana: i16,
+ pub hp: i16,
+ pub name: alloc::string::String,
+ pub inventory: Option<alloc::vec::Vec<u8>>,
+ pub color: Color,
+ pub test: AnyT,
+ pub test4: Option<alloc::vec::Vec<TestT>>,
+ pub testarrayofstring: Option<alloc::vec::Vec<alloc::string::String>>,
+ pub testarrayoftables: Option<alloc::vec::Vec<MonsterT>>,
+ pub enemy: Option<alloc::boxed::Box<MonsterT>>,
+ pub testnestedflatbuffer: Option<alloc::vec::Vec<u8>>,
+ pub testempty: Option<alloc::boxed::Box<StatT>>,
+ pub testbool: bool,
+ pub testhashs32_fnv1: i32,
+ pub testhashu32_fnv1: u32,
+ pub testhashs64_fnv1: i64,
+ pub testhashu64_fnv1: u64,
+ pub testhashs32_fnv1a: i32,
+ pub testhashu32_fnv1a: u32,
+ pub testhashs64_fnv1a: i64,
+ pub testhashu64_fnv1a: u64,
+ pub testarrayofbools: Option<alloc::vec::Vec<bool>>,
+ pub testf: f32,
+ pub testf2: f32,
+ pub testf3: f32,
+ pub testarrayofstring2: Option<alloc::vec::Vec<alloc::string::String>>,
+ pub testarrayofsortedstruct: Option<alloc::vec::Vec<AbilityT>>,
+ pub flex: Option<alloc::vec::Vec<u8>>,
+ pub test5: Option<alloc::vec::Vec<TestT>>,
+ pub vector_of_longs: Option<alloc::vec::Vec<i64>>,
+ pub vector_of_doubles: Option<alloc::vec::Vec<f64>>,
+ pub parent_namespace_test: Option<alloc::boxed::Box<super::InParentNamespaceT>>,
+ pub vector_of_referrables: Option<alloc::vec::Vec<ReferrableT>>,
+ pub single_weak_reference: u64,
+ pub vector_of_weak_references: Option<alloc::vec::Vec<u64>>,
+ pub vector_of_strong_referrables: Option<alloc::vec::Vec<ReferrableT>>,
+ pub co_owning_reference: u64,
+ pub vector_of_co_owning_references: Option<alloc::vec::Vec<u64>>,
+ pub non_owning_reference: u64,
+ pub vector_of_non_owning_references: Option<alloc::vec::Vec<u64>>,
+ pub any_unique: AnyUniqueAliasesT,
+ pub any_ambiguous: AnyAmbiguousAliasesT,
+ pub vector_of_enums: Option<alloc::vec::Vec<Color>>,
+ pub signed_enum: Race,
+ pub testrequirednestedflatbuffer: Option<alloc::vec::Vec<u8>>,
+ pub scalar_key_sorted_tables: Option<alloc::vec::Vec<StatT>>,
+ pub native_inline: Option<TestT>,
+ pub long_enum_non_enum_default: LongEnum,
+ pub long_enum_normal_default: LongEnum,
+ pub nan_default: f32,
+ pub inf_default: f32,
+ pub positive_inf_default: f32,
+ pub infinity_default: f32,
+ pub positive_infinity_default: f32,
+ pub negative_inf_default: f32,
+ pub negative_infinity_default: f32,
+ pub double_inf_default: f64,
}
impl Default for MonsterT {
- fn default() -> Self {
- Self {
- pos: None,
- mana: 150,
- hp: 100,
- name: alloc::string::ToString::to_string(""),
- inventory: None,
- color: Color::Blue,
- test: AnyT::NONE,
- test4: None,
- testarrayofstring: None,
- testarrayoftables: None,
- enemy: None,
- testnestedflatbuffer: None,
- testempty: None,
- testbool: false,
- testhashs32_fnv1: 0,
- testhashu32_fnv1: 0,
- testhashs64_fnv1: 0,
- testhashu64_fnv1: 0,
- testhashs32_fnv1a: 0,
- testhashu32_fnv1a: 0,
- testhashs64_fnv1a: 0,
- testhashu64_fnv1a: 0,
- testarrayofbools: None,
- testf: 3.14159,
- testf2: 3.0,
- testf3: 0.0,
- testarrayofstring2: None,
- testarrayofsortedstruct: None,
- flex: None,
- test5: None,
- vector_of_longs: None,
- vector_of_doubles: None,
- parent_namespace_test: None,
- vector_of_referrables: None,
- single_weak_reference: 0,
- vector_of_weak_references: None,
- vector_of_strong_referrables: None,
- co_owning_reference: 0,
- vector_of_co_owning_references: None,
- non_owning_reference: 0,
- vector_of_non_owning_references: None,
- any_unique: AnyUniqueAliasesT::NONE,
- any_ambiguous: AnyAmbiguousAliasesT::NONE,
- vector_of_enums: None,
- signed_enum: Race::None,
- testrequirednestedflatbuffer: None,
- scalar_key_sorted_tables: None,
- native_inline: None,
- long_enum_non_enum_default: Default::default(),
- long_enum_normal_default: LongEnum::LongOne,
- nan_default: f32::NAN,
- inf_default: f32::INFINITY,
- positive_inf_default: f32::INFINITY,
- infinity_default: f32::INFINITY,
- positive_infinity_default: f32::INFINITY,
- negative_inf_default: f32::NEG_INFINITY,
- negative_infinity_default: f32::NEG_INFINITY,
- double_inf_default: f64::INFINITY,
+ fn default() -> Self {
+ Self {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: alloc::string::ToString::to_string(""),
+ inventory: None,
+ color: Color::Blue,
+ test: AnyT::NONE,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique: AnyUniqueAliasesT::NONE,
+ any_ambiguous: AnyAmbiguousAliasesT::NONE,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ nan_default: f32::NAN,
+ inf_default: f32::INFINITY,
+ positive_inf_default: f32::INFINITY,
+ infinity_default: f32::INFINITY,
+ positive_infinity_default: f32::INFINITY,
+ negative_inf_default: f32::NEG_INFINITY,
+ negative_infinity_default: f32::NEG_INFINITY,
+ double_inf_default: f64::INFINITY,
+ }
}
- }
}
impl MonsterT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
- let pos_tmp = self.pos.as_ref().map(|x| x.pack());
- let pos = pos_tmp.as_ref();
- let mana = self.mana;
- let hp = self.hp;
- let name = Some({
- let x = &self.name;
- _fbb.create_string(x)
- });
- let inventory = self.inventory.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let color = self.color;
- let test_type = self.test.any_type();
- let test = self.test.pack(_fbb);
- let test4 = self.test4.as_ref().map(|x|{
- let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
- });
- let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{
- 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: 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)
- });
- let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let testempty = self.testempty.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let testbool = self.testbool;
- let testhashs32_fnv1 = self.testhashs32_fnv1;
- let testhashu32_fnv1 = self.testhashu32_fnv1;
- let testhashs64_fnv1 = self.testhashs64_fnv1;
- let testhashu64_fnv1 = self.testhashu64_fnv1;
- let testhashs32_fnv1a = self.testhashs32_fnv1a;
- let testhashu32_fnv1a = self.testhashu32_fnv1a;
- let testhashs64_fnv1a = self.testhashs64_fnv1a;
- let testhashu64_fnv1a = self.testhashu64_fnv1a;
- let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let testf = self.testf;
- let testf2 = self.testf2;
- let testf3 = self.testf3;
- let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{
- let w: 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: 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: 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)
- });
- let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{
- let w: 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: 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|{
- _fbb.create_vector(x)
- });
- let non_owning_reference = self.non_owning_reference;
- let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let any_unique_type = self.any_unique.any_unique_aliases_type();
- let any_unique = self.any_unique.pack(_fbb);
- let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type();
- let any_ambiguous = self.any_ambiguous.pack(_fbb);
- let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let signed_enum = self.signed_enum;
- let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{
- let w: 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();
- let long_enum_non_enum_default = self.long_enum_non_enum_default;
- let long_enum_normal_default = self.long_enum_normal_default;
- let nan_default = self.nan_default;
- let inf_default = self.inf_default;
- let positive_inf_default = self.positive_inf_default;
- let infinity_default = self.infinity_default;
- let positive_infinity_default = self.positive_infinity_default;
- let negative_inf_default = self.negative_inf_default;
- let negative_infinity_default = self.negative_infinity_default;
- let double_inf_default = self.double_inf_default;
- Monster::create(_fbb, &MonsterArgs{
- pos,
- mana,
- hp,
- name,
- inventory,
- color,
- test_type,
- test,
- test4,
- testarrayofstring,
- testarrayoftables,
- enemy,
- testnestedflatbuffer,
- testempty,
- testbool,
- testhashs32_fnv1,
- testhashu32_fnv1,
- testhashs64_fnv1,
- testhashu64_fnv1,
- testhashs32_fnv1a,
- testhashu32_fnv1a,
- testhashs64_fnv1a,
- testhashu64_fnv1a,
- testarrayofbools,
- testf,
- testf2,
- testf3,
- testarrayofstring2,
- testarrayofsortedstruct,
- flex,
- test5,
- vector_of_longs,
- vector_of_doubles,
- parent_namespace_test,
- vector_of_referrables,
- single_weak_reference,
- vector_of_weak_references,
- vector_of_strong_referrables,
- co_owning_reference,
- vector_of_co_owning_references,
- non_owning_reference,
- vector_of_non_owning_references,
- any_unique_type,
- any_unique,
- any_ambiguous_type,
- any_ambiguous,
- vector_of_enums,
- signed_enum,
- testrequirednestedflatbuffer,
- scalar_key_sorted_tables,
- native_inline,
- long_enum_non_enum_default,
- long_enum_normal_default,
- nan_default,
- inf_default,
- positive_inf_default,
- infinity_default,
- positive_infinity_default,
- negative_inf_default,
- negative_infinity_default,
- double_inf_default,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
+ let pos_tmp = self.pos.as_ref().map(|x| x.pack());
+ let pos = pos_tmp.as_ref();
+ let mana = self.mana;
+ let hp = self.hp;
+ let name = Some({
+ let x = &self.name;
+ _fbb.create_string(x)
+ });
+ let inventory = self.inventory.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let color = self.color;
+ let test_type = self.test.any_type();
+ let test = self.test.pack(_fbb);
+ let test4 = self.test4.as_ref().map(|x|{
+ let w: alloc::vec::Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{
+ 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: 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)
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testempty = self.testempty.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let testbool = self.testbool;
+ let testhashs32_fnv1 = self.testhashs32_fnv1;
+ let testhashu32_fnv1 = self.testhashu32_fnv1;
+ let testhashs64_fnv1 = self.testhashs64_fnv1;
+ let testhashu64_fnv1 = self.testhashu64_fnv1;
+ let testhashs32_fnv1a = self.testhashs32_fnv1a;
+ let testhashu32_fnv1a = self.testhashu32_fnv1a;
+ let testhashs64_fnv1a = self.testhashs64_fnv1a;
+ let testhashu64_fnv1a = self.testhashu64_fnv1a;
+ let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testf = self.testf;
+ let testf2 = self.testf2;
+ let testf3 = self.testf3;
+ let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{
+ let w: 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: 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: 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)
+ });
+ let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{
+ let w: 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: 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|{
+ _fbb.create_vector(x)
+ });
+ let non_owning_reference = self.non_owning_reference;
+ let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let any_unique_type = self.any_unique.any_unique_aliases_type();
+ let any_unique = self.any_unique.pack(_fbb);
+ let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type();
+ let any_ambiguous = self.any_ambiguous.pack(_fbb);
+ let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let signed_enum = self.signed_enum;
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{
+ let w: 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();
+ let long_enum_non_enum_default = self.long_enum_non_enum_default;
+ let long_enum_normal_default = self.long_enum_normal_default;
+ let nan_default = self.nan_default;
+ let inf_default = self.inf_default;
+ let positive_inf_default = self.positive_inf_default;
+ let infinity_default = self.infinity_default;
+ let positive_infinity_default = self.positive_infinity_default;
+ let negative_inf_default = self.negative_inf_default;
+ let negative_infinity_default = self.negative_infinity_default;
+ let double_inf_default = self.double_inf_default;
+ Monster::create(_fbb, &MonsterArgs{
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test_type,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ nan_default,
+ inf_default,
+ positive_inf_default,
+ infinity_default,
+ positive_infinity_default,
+ negative_inf_default,
+ negative_infinity_default,
+ double_inf_default,
+ })
+ }
}
/// Verifies that a buffer of bytes contains a `Monster`
@@ -2290,7 +2290,7 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<Monster>(buf)
+ ::flatbuffers::root::<Monster>(buf)
}
/// Verifies that a buffer of bytes contains a size prefixed
@@ -2301,7 +2301,7 @@
/// `size_prefixed_root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<Monster>(buf)
+ ::flatbuffers::size_prefixed_root::<Monster>(buf)
}
/// Verifies, with the given options, that a buffer of bytes
@@ -2312,10 +2312,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
/// Verifies, with the given verifier options, that a buffer of
@@ -2326,10 +2326,10 @@
/// `root_as_monster_unchecked`.
#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
+ ::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
@@ -2337,7 +2337,7 @@
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
@@ -2345,19 +2345,19 @@
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
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";
@@ -2365,11 +2365,15 @@
#[inline]
pub fn finish_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<Monster<'a>>) {
- fbb.finish(root, Some(MONSTER_IDENTIFIER));
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ 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<Monster<'a>>) {
- fbb.finish_size_prefixed(root, Some(MONSTER_IDENTIFIER));
+pub fn finish_size_prefixed_monster_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<Monster<'a>>
+) {
+ fbb.finish_size_prefixed(root, 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 1f6de1d..b3e0e13 100644
--- a/tests/monster_test_serialize/my_game/example/race_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/race_generated.rs
@@ -14,10 +14,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_RACE: [Race; 4] = [
- Race::None,
- Race::Human,
- Race::Dwarf,
- Race::Elf,
+ Race::None,
+ Race::Human,
+ Race::Dwarf,
+ Race::Elf,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -26,49 +26,49 @@
#[allow(non_upper_case_globals)]
impl Race {
- pub const None: Self = Self(-1);
- pub const Human: Self = Self(0);
- pub const Dwarf: Self = Self(1);
- pub const Elf: Self = Self(2);
+ pub const None: Self = Self(-1);
+ pub const Human: Self = Self(0);
+ pub const Dwarf: Self = Self(1);
+ pub const Elf: Self = Self(2);
- pub const ENUM_MIN: i8 = -1;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::None,
- Self::Human,
- Self::Dwarf,
- Self::Elf,
- ];
+ pub const ENUM_MIN: i8 = -1;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::None,
+ Self::Human,
+ Self::Dwarf,
+ Self::Elf,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::None => Some("None"),
- Self::Human => Some("Human"),
- Self::Dwarf => Some("Dwarf"),
- Self::Elf => Some("Elf"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::None => Some("None"),
+ Self::Human => Some("Human"),
+ Self::Dwarf => Some("Dwarf"),
+ Self::Elf => Some("Elf"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl Serialize for Race {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_unit_variant("Race", self.0 as u32, self.variant_name().unwrap())
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant("Race", self.0 as u32, self.variant_name().unwrap())
+ }
}
impl<'de> serde::Deserialize<'de> for Race {
@@ -91,13 +91,13 @@
}
impl<'a> ::flatbuffers::Follow<'a> for Race {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Race {
@@ -110,28 +110,28 @@
}
impl ::flatbuffers::EndianScalar for Race {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Race {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
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 c861df0..d7224c4 100644
--- a/tests/monster_test_serialize/my_game/example/referrable_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
@@ -9,77 +9,77 @@
#[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> {
- type Inner = Referrable<'a>;
+ type Inner = Referrable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args ReferrableArgs
- ) -> ::flatbuffers::WIPOffset<Referrable<'bldr>> {
- let mut builder = ReferrableBuilder::new(_fbb);
- builder.add_id(args.id);
- builder.finish()
- }
-
- pub fn unpack(&self) -> ReferrableT {
- let id = self.id();
- ReferrableT {
- id,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Referrable"
}
- }
- #[inline]
- pub fn id(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Referrable { _tab: table }
+ }
- #[inline]
- pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
- self.id() < o.id()
- }
+ #[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>,
+ args: &'args ReferrableArgs
+ ) -> ::flatbuffers::WIPOffset<Referrable<'bldr>> {
+ let mut builder = ReferrableBuilder::new(_fbb);
+ builder.add_id(args.id);
+ builder.finish()
+ }
- #[inline]
- pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
- let key = self.id();
- key.cmp(&val)
- }
+ pub fn unpack(&self) -> ReferrableT {
+ let id = self.id();
+ ReferrableT {
+ id,
+ }
+ }
+
+ #[inline]
+ pub fn id(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u64) -> ::core::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
}
impl ::flatbuffers::Verifiable for Referrable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<u64>("id", Self::VT_ID, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<u64>("id", Self::VT_ID, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct ReferrableArgs {
@@ -87,82 +87,82 @@
}
impl<'a> Default for ReferrableArgs {
- #[inline]
- fn default() -> Self {
- ReferrableArgs {
- id: 0,
+ #[inline]
+ fn default() -> Self {
+ ReferrableArgs {
+ id: 0,
+ }
}
- }
}
impl Serialize for Referrable<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("Referrable", 1)?;
- s.serialize_field("id", &self.id())?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("Referrable", 1)?;
+ s.serialize_field("id", &self.id())?;
+ s.end()
+ }
}
pub struct ReferrableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<u64>(Referrable::VT_ID, id, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- ReferrableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_id(&mut self, id: u64) {
+ self.fbb_.push_slot::<u64>(Referrable::VT_ID, id, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ReferrableBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ ReferrableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ReferrableT {
- pub id: u64,
+ pub id: u64,
}
impl Default for ReferrableT {
- fn default() -> Self {
- Self {
- id: 0,
+ fn default() -> Self {
+ Self {
+ id: 0,
+ }
}
- }
}
impl ReferrableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Referrable<'b>> {
- let id = self.id;
- Referrable::create(_fbb, &ReferrableArgs{
- id,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Referrable<'b>> {
+ 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 1d4d43f..eb81b1c 100644
--- a/tests/monster_test_serialize/my_game/example/stat_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/stat_generated.rs
@@ -9,105 +9,105 @@
#[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> {
- type Inner = Stat<'a>;
+ type Inner = Stat<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args StatArgs<'args>
- ) -> ::flatbuffers::WIPOffset<Stat<'bldr>> {
- let mut builder = StatBuilder::new(_fbb);
- builder.add_val(args.val);
- if let Some(x) = args.id { builder.add_id(x); }
- builder.add_count(args.count);
- builder.finish()
- }
-
- pub fn unpack(&self) -> StatT {
- let id = self.id().map(|x| {
- alloc::string::ToString::to_string(x)
- });
- let val = self.val();
- let count = self.count();
- StatT {
- id,
- val,
- count,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Stat"
}
- }
- #[inline]
- pub fn id(&self) -> Option<&'a str> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ Stat { _tab: table }
+ }
- #[inline]
- pub fn val(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()}
- }
+ #[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>,
+ args: &'args StatArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<Stat<'bldr>> {
+ let mut builder = StatBuilder::new(_fbb);
+ builder.add_val(args.val);
+ if let Some(x) = args.id { builder.add_id(x); }
+ builder.add_count(args.count);
+ builder.finish()
+ }
- #[inline]
- pub fn count(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()}
- }
+ pub fn unpack(&self) -> StatT {
+ let id = self.id().map(|x| {
+ alloc::string::ToString::to_string(x)
+ });
+ let val = self.val();
+ let count = self.count();
+ StatT {
+ id,
+ val,
+ count,
+ }
+ }
- #[inline]
- pub fn key_compare_less_than(&self, o: &Stat) -> bool {
- self.count() < o.count()
- }
+ #[inline]
+ pub fn id(&self) -> Option<&'a str> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
+ }
- #[inline]
- pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
- let key = self.count();
- key.cmp(&val)
- }
+ #[inline]
+ pub fn val(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn count(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Stat) -> bool {
+ self.count() < o.count()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u16) -> ::core::cmp::Ordering {
+ let key = self.count();
+ key.cmp(&val)
+ }
}
impl ::flatbuffers::Verifiable for Stat<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
- .visit_field::<i64>("val", Self::VT_VAL, false)?
- .visit_field::<u16>("count", Self::VT_COUNT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
+ .visit_field::<i64>("val", Self::VT_VAL, false)?
+ .visit_field::<u16>("count", Self::VT_COUNT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct StatArgs<'a> {
@@ -117,112 +117,112 @@
}
impl<'a> Default for StatArgs<'a> {
- #[inline]
- fn default() -> Self {
- StatArgs {
- id: None,
- val: 0,
- count: 0,
+ #[inline]
+ fn default() -> Self {
+ StatArgs {
+ id: None,
+ val: 0,
+ count: 0,
+ }
}
- }
}
impl Serialize for Stat<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("Stat", 3)?;
- if let Some(f) = self.id() {
- s.serialize_field("id", &f)?;
- } else {
- s.skip_field("id")?;
- }
- s.serialize_field("val", &self.val())?;
- s.serialize_field("count", &self.count())?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("Stat", 3)?;
+ if let Some(f) = self.id() {
+ s.serialize_field("id", &f)?;
+ } else {
+ s.skip_field("id")?;
+ }
+ s.serialize_field("val", &self.val())?;
+ s.serialize_field("count", &self.count())?;
+ s.end()
+ }
}
pub struct StatBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<::flatbuffers::WIPOffset<_>>(Stat::VT_ID, id);
- }
-
- #[inline]
- pub fn add_val(&mut self, val: i64) {
- self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0);
- }
-
- #[inline]
- pub fn add_count(&mut self, count: u16) {
- self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- StatBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ 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 finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_val(&mut self, val: i64) {
+ self.fbb_.push_slot::<i64>(Stat::VT_VAL, val, 0);
+ }
+
+ #[inline]
+ pub fn add_count(&mut self, count: u16) {
+ self.fbb_.push_slot::<u16>(Stat::VT_COUNT, count, 0);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> StatBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ StatBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("count", &self.count());
- ds.finish()
- }
+ 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());
+ ds.field("count", &self.count());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct StatT {
- pub id: Option<alloc::string::String>,
- pub val: i64,
- pub count: u16,
+ pub id: Option<alloc::string::String>,
+ pub val: i64,
+ pub count: u16,
}
impl Default for StatT {
- fn default() -> Self {
- Self {
- id: None,
- val: 0,
- count: 0,
+ fn default() -> Self {
+ Self {
+ id: None,
+ val: 0,
+ count: 0,
+ }
}
- }
}
impl StatT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Stat<'b>> {
- let id = self.id.as_ref().map(|x|{
- _fbb.create_string(x)
- });
- let val = self.val;
- let count = self.count;
- Stat::create(_fbb, &StatArgs{
- id,
- val,
- count,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Stat<'b>> {
+ let id = self.id.as_ref().map(|x|{
+ _fbb.create_string(x)
+ });
+ let val = self.val;
+ let count = self.count;
+ Stat::create(_fbb, &StatArgs{
+ id,
+ val,
+ count,
+ })
+ }
}
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 8706562..053cb49 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
@@ -10,40 +10,40 @@
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructs(pub [u8; 20]);
-impl Default for StructOfStructs {
- fn default() -> Self {
- Self([0; 20])
- }
+impl Default for StructOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
}
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())
- .field("c", &self.c())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("StructOfStructs")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .field("c", &self.c())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs {
- type Inner = &'a StructOfStructs;
+ type Inner = &'a StructOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a StructOfStructs>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a StructOfStructs>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructs {
- type Inner = &'a StructOfStructs;
+ type Inner = &'a StructOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for StructOfStructs {
@@ -62,103 +62,103 @@
}
impl<'a> ::flatbuffers::Verifiable for StructOfStructs {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for StructOfStructs {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("StructOfStructs", 3)?;
- s.serialize_field("a", &self.a())?;
- s.serialize_field("b", &self.b())?;
- s.serialize_field("c", &self.c())?;
- s.end()
- }
+ s.serialize_field("a", &self.a())?;
+ s.serialize_field("b", &self.b())?;
+ s.serialize_field("c", &self.c())?;
+ s.end()
+ }
}
impl<'a> StructOfStructs {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: &Ability,
- b: &Test,
- c: &Ability,
- ) -> Self {
- let mut s = Self([0; 20]);
- s.set_a(a);
- s.set_b(b);
- s.set_c(c);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.StructOfStructs"
- }
-
- pub fn a(&self) -> &Ability {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_a(&mut self, x: &Ability) {
- self.0[0..0 + 8].copy_from_slice(&x.0)
- }
-
- pub fn b(&self) -> &Test {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[8..].as_ptr() as *const Test) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_b(&mut self, x: &Test) {
- self.0[8..8 + 4].copy_from_slice(&x.0)
- }
-
- pub fn c(&self) -> &Ability {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_c(&mut self, x: &Ability) {
- self.0[12..12 + 8].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> StructOfStructsT {
- StructOfStructsT {
- a: self.a().unpack(),
- b: self.b().unpack(),
- c: self.c().unpack(),
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &Ability,
+ b: &Test,
+ c: &Ability,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s.set_b(b);
+ s.set_c(c);
+ s
}
- }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructs"
+ }
+
+ pub fn a(&self) -> &Ability {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &Ability) {
+ self.0[0..0 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn b(&self) -> &Test {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[8..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_b(&mut self, x: &Test) {
+ self.0[8..8 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn c(&self) -> &Ability {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_c(&mut self, x: &Ability) {
+ self.0[12..12 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsT {
+ StructOfStructsT {
+ a: self.a().unpack(),
+ b: self.b().unpack(),
+ c: self.c().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StructOfStructsT {
- pub a: AbilityT,
- pub b: TestT,
- pub c: AbilityT,
+ pub a: AbilityT,
+ pub b: TestT,
+ pub c: AbilityT,
}
impl StructOfStructsT {
- pub fn pack(&self) -> StructOfStructs {
- StructOfStructs::new(
- &self.a.pack(),
- &self.b.pack(),
- &self.c.pack(),
- )
- }
+ pub fn pack(&self) -> StructOfStructs {
+ StructOfStructs::new(
+ &self.a.pack(),
+ &self.b.pack(),
+ &self.c.pack(),
+ )
+ }
}
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 dae0180..9172c8c 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
@@ -10,38 +10,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructsOfStructs(pub [u8; 20]);
-impl Default for StructOfStructsOfStructs {
- fn default() -> Self {
- Self([0; 20])
- }
+impl Default for StructOfStructsOfStructs {
+ fn default() -> Self {
+ Self([0; 20])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a StructOfStructsOfStructs;
+ type Inner = &'a StructOfStructsOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a StructOfStructsOfStructs {
- type Inner = &'a StructOfStructsOfStructs;
+ type Inner = &'a StructOfStructsOfStructs;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<StructOfStructsOfStructs>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs {
@@ -60,67 +60,67 @@
}
impl<'a> ::flatbuffers::Verifiable for StructOfStructsOfStructs {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for StructOfStructsOfStructs {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("StructOfStructsOfStructs", 1)?;
- s.serialize_field("a", &self.a())?;
- s.end()
- }
+ s.serialize_field("a", &self.a())?;
+ s.end()
+ }
}
impl<'a> StructOfStructsOfStructs {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: &StructOfStructs,
- ) -> Self {
- let mut s = Self([0; 20]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.StructOfStructsOfStructs"
- }
-
- pub fn a(&self) -> &StructOfStructs {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_a(&mut self, x: &StructOfStructs) {
- self.0[0..0 + 20].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> StructOfStructsOfStructsT {
- StructOfStructsOfStructsT {
- a: self.a().unpack(),
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &StructOfStructs,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s
}
- }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructsOfStructs"
+ }
+
+ pub fn a(&self) -> &StructOfStructs {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[0..].as_ptr() as *const StructOfStructs) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &StructOfStructs) {
+ self.0[0..0 + 20].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsOfStructsT {
+ StructOfStructsOfStructsT {
+ a: self.a().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StructOfStructsOfStructsT {
- pub a: StructOfStructsT,
+ pub a: StructOfStructsT,
}
impl StructOfStructsOfStructsT {
- pub fn pack(&self) -> StructOfStructsOfStructs {
- StructOfStructsOfStructs::new(
- &self.a.pack(),
- )
- }
+ pub fn pack(&self) -> StructOfStructsOfStructs {
+ StructOfStructsOfStructs::new(
+ &self.a.pack(),
+ )
+ }
}
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 b1e4e2c..f34509c 100644
--- a/tests/monster_test_serialize/my_game/example/test_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_generated.rs
@@ -10,39 +10,39 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Test(pub [u8; 4]);
-impl Default for Test {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Test {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Test")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Test {}
impl<'a> ::flatbuffers::Follow<'a> for Test {
- type Inner = &'a Test;
+ type Inner = &'a Test;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Test>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Test>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Test {
- type Inner = &'a Test;
+ type Inner = &'a Test;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Test>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Test>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Test {
@@ -61,119 +61,119 @@
}
impl<'a> ::flatbuffers::Verifiable for Test {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for Test {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("Test", 2)?;
- s.serialize_field("a", &self.a())?;
- s.serialize_field("b", &self.b())?;
- s.end()
- }
+ s.serialize_field("a", &self.a())?;
+ s.serialize_field("b", &self.b())?;
+ s.end()
+ }
}
impl<'a> Test {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i16,
- b: i8,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s.set_b(b);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Test"
- }
-
- pub fn a(&self) -> i16 {
- let mut mem = ::core::mem::MaybeUninit::<<i16 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i16) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i16,
+ b: i8,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s.set_b(b);
+ s
}
- }
- pub fn b(&self) -> i8 {
- let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_b(&mut self, x: i8) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[2..].as_mut_ptr(),
- ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Test"
}
- }
- pub fn unpack(&self) -> TestT {
- TestT {
- a: self.a(),
- b: self.b(),
+ pub fn a(&self) -> i16 {
+ let mut mem = ::core::mem::MaybeUninit::<<i16 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_a(&mut self, x: i16) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i16 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn b(&self) -> i8 {
+ let mut mem = ::core::mem::MaybeUninit::<<i8 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_b(&mut self, x: i8) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[2..].as_mut_ptr(),
+ ::core::mem::size_of::<<i8 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> TestT {
+ TestT {
+ a: self.a(),
+ b: self.b(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct TestT {
- pub a: i16,
- pub b: i8,
+ pub a: i16,
+ pub b: i8,
}
impl TestT {
- pub fn pack(&self) -> Test {
- Test::new(
- self.a,
- self.b,
- )
- }
+ pub fn pack(&self) -> Test {
+ Test::new(
+ self.a,
+ self.b,
+ )
+ }
}
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 c55e1cb..6cd14b1 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
@@ -9,66 +9,66 @@
#[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> {
- type Inner = TestSimpleTableWithEnum<'a>;
+ type Inner = TestSimpleTableWithEnum<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TestSimpleTableWithEnumArgs
- ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
- let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
- builder.add_color(args.color);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TestSimpleTableWithEnumT {
- let color = self.color();
- TestSimpleTableWithEnumT {
- color,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TestSimpleTableWithEnum"
}
- }
- #[inline]
- pub fn color(&self) -> Color {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<Color>(TestSimpleTableWithEnum::VT_COLOR, Some(Color::Green)).unwrap()}
- }
+ #[inline]
+ 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>,
+ args: &'args TestSimpleTableWithEnumArgs
+ ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
+ let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
+ builder.add_color(args.color);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TestSimpleTableWithEnumT {
+ let color = self.color();
+ TestSimpleTableWithEnumT {
+ color,
+ }
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<Color>(TestSimpleTableWithEnum::VT_COLOR, Some(Color::Green)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<Color>("color", Self::VT_COLOR, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TestSimpleTableWithEnumArgs {
@@ -76,82 +76,82 @@
}
impl<'a> Default for TestSimpleTableWithEnumArgs {
- #[inline]
- fn default() -> Self {
- TestSimpleTableWithEnumArgs {
- color: Color::Green,
+ #[inline]
+ fn default() -> Self {
+ TestSimpleTableWithEnumArgs {
+ color: Color::Green,
+ }
}
- }
}
impl Serialize for TestSimpleTableWithEnum<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("TestSimpleTableWithEnum", 1)?;
- s.serialize_field("color", &self.color())?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("TestSimpleTableWithEnum", 1)?;
+ s.serialize_field("color", &self.color())?;
+ s.end()
+ }
}
pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<Color>(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TestSimpleTableWithEnumBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_color(&mut self, color: Color) {
+ self.fbb_.push_slot::<Color>(TestSimpleTableWithEnum::VT_COLOR, color, Color::Green);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TestSimpleTableWithEnumBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TestSimpleTableWithEnumBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TestSimpleTableWithEnumT {
- pub color: Color,
+ pub color: Color,
}
impl Default for TestSimpleTableWithEnumT {
- fn default() -> Self {
- Self {
- color: Color::Green,
+ fn default() -> Self {
+ Self {
+ color: Color::Green,
+ }
}
- }
}
impl TestSimpleTableWithEnumT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> {
- let color = self.color;
- TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{
- color,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> {
+ 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 5c6393f..698b5f7 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
@@ -9,213 +9,213 @@
#[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> {
- type Inner = TypeAliases<'a>;
+ type Inner = TypeAliases<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TypeAliasesArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TypeAliases<'bldr>> {
- let mut builder = TypeAliasesBuilder::new(_fbb);
- builder.add_f64_(args.f64_);
- builder.add_u64_(args.u64_);
- builder.add_i64_(args.i64_);
- if let Some(x) = args.vf64 { builder.add_vf64(x); }
- if let Some(x) = args.v8 { builder.add_v8(x); }
- builder.add_f32_(args.f32_);
- builder.add_u32_(args.u32_);
- builder.add_i32_(args.i32_);
- builder.add_u16_(args.u16_);
- builder.add_i16_(args.i16_);
- builder.add_u8_(args.u8_);
- builder.add_i8_(args.i8_);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TypeAliasesT {
- let i8_ = self.i8_();
- let u8_ = self.u8_();
- let i16_ = self.i16_();
- let u16_ = self.u16_();
- let i32_ = self.i32_();
- let u32_ = self.u32_();
- let i64_ = self.i64_();
- let u64_ = self.u64_();
- let f32_ = self.f32_();
- let f64_ = self.f64_();
- let v8 = self.v8().map(|x| {
- x.into_iter().collect()
- });
- let vf64 = self.vf64().map(|x| {
- x.into_iter().collect()
- });
- TypeAliasesT {
- i8_,
- u8_,
- i16_,
- u16_,
- i32_,
- u32_,
- i64_,
- u64_,
- f32_,
- f64_,
- v8,
- vf64,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TypeAliases"
}
- }
- #[inline]
- pub fn i8_(&self) -> i8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ TypeAliases { _tab: table }
+ }
- #[inline]
- pub fn u8_(&self) -> u8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
- }
+ #[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>,
+ args: &'args TypeAliasesArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TypeAliases<'bldr>> {
+ let mut builder = TypeAliasesBuilder::new(_fbb);
+ builder.add_f64_(args.f64_);
+ builder.add_u64_(args.u64_);
+ builder.add_i64_(args.i64_);
+ if let Some(x) = args.vf64 { builder.add_vf64(x); }
+ if let Some(x) = args.v8 { builder.add_v8(x); }
+ builder.add_f32_(args.f32_);
+ builder.add_u32_(args.u32_);
+ builder.add_i32_(args.i32_);
+ builder.add_u16_(args.u16_);
+ builder.add_i16_(args.i16_);
+ builder.add_u8_(args.u8_);
+ builder.add_i8_(args.i8_);
+ builder.finish()
+ }
- #[inline]
- pub fn i16_(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
- }
+ pub fn unpack(&self) -> TypeAliasesT {
+ let i8_ = self.i8_();
+ let u8_ = self.u8_();
+ let i16_ = self.i16_();
+ let u16_ = self.u16_();
+ let i32_ = self.i32_();
+ let u32_ = self.u32_();
+ let i64_ = self.i64_();
+ let u64_ = self.u64_();
+ let f32_ = self.f32_();
+ let f64_ = self.f64_();
+ let v8 = self.v8().map(|x| {
+ x.into_iter().collect()
+ });
+ let vf64 = self.vf64().map(|x| {
+ x.into_iter().collect()
+ });
+ TypeAliasesT {
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ }
+ }
- #[inline]
- pub fn u16_(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i8_(&self) -> i8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn i32_(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn u8_(&self) -> u8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn u32_(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i16_(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn i64_(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn u16_(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn u64_(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn i32_(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn f32_(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(TypeAliases::VT_F32_, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn u32_(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn f64_(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(TypeAliases::VT_F64_, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn i64_(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)}
- }
+ #[inline]
+ pub fn u64_(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)}
- }
+ #[inline]
+ pub fn f32_(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(TypeAliases::VT_F32_, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ pub fn f64_(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(TypeAliases::VT_F64_, Some(0.0)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None)}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)}
+ }
}
impl ::flatbuffers::Verifiable for TypeAliases<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i8>("i8_", Self::VT_I8_, false)?
- .visit_field::<u8>("u8_", Self::VT_U8_, false)?
- .visit_field::<i16>("i16_", Self::VT_I16_, false)?
- .visit_field::<u16>("u16_", Self::VT_U16_, false)?
- .visit_field::<i32>("i32_", Self::VT_I32_, false)?
- .visit_field::<u32>("u32_", Self::VT_U32_, false)?
- .visit_field::<i64>("i64_", Self::VT_I64_, false)?
- .visit_field::<u64>("u64_", Self::VT_U64_, false)?
- .visit_field::<f32>("f32_", Self::VT_F32_, false)?
- .visit_field::<f64>("f64_", Self::VT_F64_, 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(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i8>("i8_", Self::VT_I8_, false)?
+ .visit_field::<u8>("u8_", Self::VT_U8_, false)?
+ .visit_field::<i16>("i16_", Self::VT_I16_, false)?
+ .visit_field::<u16>("u16_", Self::VT_U16_, false)?
+ .visit_field::<i32>("i32_", Self::VT_I32_, false)?
+ .visit_field::<u32>("u32_", Self::VT_U32_, false)?
+ .visit_field::<i64>("i64_", Self::VT_I64_, false)?
+ .visit_field::<u64>("u64_", Self::VT_U64_, false)?
+ .visit_field::<f32>("f32_", Self::VT_F32_, false)?
+ .visit_field::<f64>("f64_", Self::VT_F64_, 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(())
+ }
}
pub struct TypeAliasesArgs<'a> {
@@ -234,226 +234,226 @@
}
impl<'a> Default for TypeAliasesArgs<'a> {
- #[inline]
- fn default() -> Self {
- TypeAliasesArgs {
- i8_: 0,
- u8_: 0,
- i16_: 0,
- u16_: 0,
- i32_: 0,
- u32_: 0,
- i64_: 0,
- u64_: 0,
- f32_: 0.0,
- f64_: 0.0,
- v8: None,
- vf64: None,
+ #[inline]
+ fn default() -> Self {
+ TypeAliasesArgs {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
}
- }
}
impl Serialize for TypeAliases<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("TypeAliases", 12)?;
- s.serialize_field("i8_", &self.i8_())?;
- s.serialize_field("u8_", &self.u8_())?;
- s.serialize_field("i16_", &self.i16_())?;
- s.serialize_field("u16_", &self.u16_())?;
- s.serialize_field("i32_", &self.i32_())?;
- s.serialize_field("u32_", &self.u32_())?;
- s.serialize_field("i64_", &self.i64_())?;
- s.serialize_field("u64_", &self.u64_())?;
- s.serialize_field("f32_", &self.f32_())?;
- s.serialize_field("f64_", &self.f64_())?;
- if let Some(f) = self.v8() {
- s.serialize_field("v8", &f)?;
- } else {
- s.skip_field("v8")?;
- }
- if let Some(f) = self.vf64() {
- s.serialize_field("vf64", &f)?;
- } else {
- s.skip_field("vf64")?;
- }
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("TypeAliases", 12)?;
+ s.serialize_field("i8_", &self.i8_())?;
+ s.serialize_field("u8_", &self.u8_())?;
+ s.serialize_field("i16_", &self.i16_())?;
+ s.serialize_field("u16_", &self.u16_())?;
+ s.serialize_field("i32_", &self.i32_())?;
+ s.serialize_field("u32_", &self.u32_())?;
+ s.serialize_field("i64_", &self.i64_())?;
+ s.serialize_field("u64_", &self.u64_())?;
+ s.serialize_field("f32_", &self.f32_())?;
+ s.serialize_field("f64_", &self.f64_())?;
+ if let Some(f) = self.v8() {
+ s.serialize_field("v8", &f)?;
+ } else {
+ s.skip_field("v8")?;
+ }
+ if let Some(f) = self.vf64() {
+ s.serialize_field("vf64", &f)?;
+ } else {
+ s.skip_field("vf64")?;
+ }
+ s.end()
+ }
}
pub struct TypeAliasesBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i8>(TypeAliases::VT_I8_, i8_, 0);
- }
-
- #[inline]
- pub fn add_u8_(&mut self, u8_: u8) {
- self.fbb_.push_slot::<u8>(TypeAliases::VT_U8_, u8_, 0);
- }
-
- #[inline]
- pub fn add_i16_(&mut self, i16_: i16) {
- self.fbb_.push_slot::<i16>(TypeAliases::VT_I16_, i16_, 0);
- }
-
- #[inline]
- pub fn add_u16_(&mut self, u16_: u16) {
- self.fbb_.push_slot::<u16>(TypeAliases::VT_U16_, u16_, 0);
- }
-
- #[inline]
- pub fn add_i32_(&mut self, i32_: i32) {
- self.fbb_.push_slot::<i32>(TypeAliases::VT_I32_, i32_, 0);
- }
-
- #[inline]
- pub fn add_u32_(&mut self, u32_: u32) {
- self.fbb_.push_slot::<u32>(TypeAliases::VT_U32_, u32_, 0);
- }
-
- #[inline]
- pub fn add_i64_(&mut self, i64_: i64) {
- self.fbb_.push_slot::<i64>(TypeAliases::VT_I64_, i64_, 0);
- }
-
- #[inline]
- pub fn add_u64_(&mut self, u64_: u64) {
- self.fbb_.push_slot::<u64>(TypeAliases::VT_U64_, u64_, 0);
- }
-
- #[inline]
- pub fn add_f32_(&mut self, f32_: f32) {
- self.fbb_.push_slot::<f32>(TypeAliases::VT_F32_, f32_, 0.0);
- }
-
- #[inline]
- pub fn add_f64_(&mut self, f64_: f64) {
- self.fbb_.push_slot::<f64>(TypeAliases::VT_F64_, f64_, 0.0);
- }
-
- #[inline]
- 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<::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> {
- let start = _fbb.start_table();
- TypeAliasesBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_i8_(&mut self, i8_: i8) {
+ self.fbb_.push_slot::<i8>(TypeAliases::VT_I8_, i8_, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_u8_(&mut self, u8_: u8) {
+ self.fbb_.push_slot::<u8>(TypeAliases::VT_U8_, u8_, 0);
+ }
+
+ #[inline]
+ pub fn add_i16_(&mut self, i16_: i16) {
+ self.fbb_.push_slot::<i16>(TypeAliases::VT_I16_, i16_, 0);
+ }
+
+ #[inline]
+ pub fn add_u16_(&mut self, u16_: u16) {
+ self.fbb_.push_slot::<u16>(TypeAliases::VT_U16_, u16_, 0);
+ }
+
+ #[inline]
+ pub fn add_i32_(&mut self, i32_: i32) {
+ self.fbb_.push_slot::<i32>(TypeAliases::VT_I32_, i32_, 0);
+ }
+
+ #[inline]
+ pub fn add_u32_(&mut self, u32_: u32) {
+ self.fbb_.push_slot::<u32>(TypeAliases::VT_U32_, u32_, 0);
+ }
+
+ #[inline]
+ pub fn add_i64_(&mut self, i64_: i64) {
+ self.fbb_.push_slot::<i64>(TypeAliases::VT_I64_, i64_, 0);
+ }
+
+ #[inline]
+ pub fn add_u64_(&mut self, u64_: u64) {
+ self.fbb_.push_slot::<u64>(TypeAliases::VT_U64_, u64_, 0);
+ }
+
+ #[inline]
+ pub fn add_f32_(&mut self, f32_: f32) {
+ self.fbb_.push_slot::<f32>(TypeAliases::VT_F32_, f32_, 0.0);
+ }
+
+ #[inline]
+ pub fn add_f64_(&mut self, f64_: f64) {
+ self.fbb_.push_slot::<f64>(TypeAliases::VT_F64_, f64_, 0.0);
+ }
+
+ #[inline]
+ 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<::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> {
+ let start = _fbb.start_table();
+ TypeAliasesBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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_());
- ds.field("i16_", &self.i16_());
- ds.field("u16_", &self.u16_());
- ds.field("i32_", &self.i32_());
- ds.field("u32_", &self.u32_());
- ds.field("i64_", &self.i64_());
- ds.field("u64_", &self.u64_());
- ds.field("f32_", &self.f32_());
- ds.field("f64_", &self.f64_());
- ds.field("v8", &self.v8());
- ds.field("vf64", &self.vf64());
- ds.finish()
- }
+ 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_());
+ ds.field("i16_", &self.i16_());
+ ds.field("u16_", &self.u16_());
+ ds.field("i32_", &self.i32_());
+ ds.field("u32_", &self.u32_());
+ ds.field("i64_", &self.i64_());
+ ds.field("u64_", &self.u64_());
+ ds.field("f32_", &self.f32_());
+ ds.field("f64_", &self.f64_());
+ ds.field("v8", &self.v8());
+ ds.field("vf64", &self.vf64());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TypeAliasesT {
- pub i8_: i8,
- pub u8_: u8,
- pub i16_: i16,
- pub u16_: u16,
- pub i32_: i32,
- pub u32_: u32,
- pub i64_: i64,
- pub u64_: u64,
- pub f32_: f32,
- pub f64_: f64,
- pub v8: Option<alloc::vec::Vec<i8>>,
- pub vf64: Option<alloc::vec::Vec<f64>>,
+ pub i8_: i8,
+ pub u8_: u8,
+ pub i16_: i16,
+ pub u16_: u16,
+ pub i32_: i32,
+ pub u32_: u32,
+ pub i64_: i64,
+ pub u64_: u64,
+ pub f32_: f32,
+ pub f64_: f64,
+ pub v8: Option<alloc::vec::Vec<i8>>,
+ pub vf64: Option<alloc::vec::Vec<f64>>,
}
impl Default for TypeAliasesT {
- fn default() -> Self {
- Self {
- i8_: 0,
- u8_: 0,
- i16_: 0,
- u16_: 0,
- i32_: 0,
- u32_: 0,
- i64_: 0,
- u64_: 0,
- f32_: 0.0,
- f64_: 0.0,
- v8: None,
- vf64: None,
+ fn default() -> Self {
+ Self {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
}
- }
}
impl TypeAliasesT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TypeAliases<'b>> {
- let i8_ = self.i8_;
- let u8_ = self.u8_;
- let i16_ = self.i16_;
- let u16_ = self.u16_;
- let i32_ = self.i32_;
- let u32_ = self.u32_;
- let i64_ = self.i64_;
- let u64_ = self.u64_;
- let f32_ = self.f32_;
- let f64_ = self.f64_;
- let v8 = self.v8.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- let vf64 = self.vf64.as_ref().map(|x|{
- _fbb.create_vector(x)
- });
- TypeAliases::create(_fbb, &TypeAliasesArgs{
- i8_,
- u8_,
- i16_,
- u16_,
- i32_,
- u32_,
- i64_,
- u64_,
- f32_,
- f64_,
- v8,
- vf64,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TypeAliases<'b>> {
+ let i8_ = self.i8_;
+ let u8_ = self.u8_;
+ let i16_ = self.i16_;
+ let u16_ = self.u16_;
+ let i32_ = self.i32_;
+ let u32_ = self.u32_;
+ let i64_ = self.i64_;
+ let u64_ = self.u64_;
+ let f32_ = self.f32_;
+ let f64_ = self.f64_;
+ let v8 = self.v8.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let vf64 = self.vf64.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ TypeAliases::create(_fbb, &TypeAliasesArgs{
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ })
+ }
}
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 f92107d..193c4c4 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
@@ -10,43 +10,43 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 32]);
-impl Default for Vec3 {
- fn default() -> Self {
- Self([0; 32])
- }
+impl Default for Vec3 {
+ fn default() -> Self {
+ Self([0; 32])
+ }
}
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())
- .field("z", &self.z())
- .field("test1", &self.test1())
- .field("test2", &self.test2())
- .field("test3", &self.test3())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("Vec3")
+ .field("x", &self.x())
+ .field("y", &self.y())
+ .field("z", &self.z())
+ .field("test1", &self.test1())
+ .field("test2", &self.test2())
+ .field("test3", &self.test3())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Vec3>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Vec3>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
- type Inner = &'a Vec3;
+ type Inner = &'a Vec3;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Vec3>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Vec3 {
@@ -65,242 +65,242 @@
}
impl<'a> ::flatbuffers::Verifiable for Vec3 {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for Vec3 {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("Vec3", 6)?;
- s.serialize_field("x", &self.x())?;
- s.serialize_field("y", &self.y())?;
- s.serialize_field("z", &self.z())?;
- s.serialize_field("test1", &self.test1())?;
- s.serialize_field("test2", &self.test2())?;
- s.serialize_field("test3", &self.test3())?;
- s.end()
- }
+ s.serialize_field("x", &self.x())?;
+ s.serialize_field("y", &self.y())?;
+ s.serialize_field("z", &self.z())?;
+ s.serialize_field("test1", &self.test1())?;
+ s.serialize_field("test2", &self.test2())?;
+ s.serialize_field("test3", &self.test3())?;
+ s.end()
+ }
}
impl<'a> Vec3 {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- x: f32,
- y: f32,
- z: f32,
- test1: f64,
- test2: Color,
- test3: &Test,
- ) -> Self {
- let mut s = Self([0; 32]);
- s.set_x(x);
- s.set_y(y);
- s.set_z(z);
- s.set_test1(test1);
- s.set_test2(test2);
- s.set_test3(test3);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example.Vec3"
- }
-
- pub fn x(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[0..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_x(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ x: f32,
+ y: f32,
+ z: f32,
+ test1: f64,
+ test2: Color,
+ test3: &Test,
+ ) -> Self {
+ let mut s = Self([0; 32]);
+ s.set_x(x);
+ s.set_y(y);
+ s.set_z(z);
+ s.set_test1(test1);
+ s.set_test2(test2);
+ s.set_test3(test3);
+ s
}
- }
- pub fn y(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[4..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_y(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Vec3"
}
- }
- pub fn z(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[8..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_z(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[8..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn x(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn test1(&self) -> f64 {
- let mut mem = ::core::mem::MaybeUninit::<<f64 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_test1(&mut self, x: f64) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[16..].as_mut_ptr(),
- ::core::mem::size_of::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn set_x(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
- pub fn test2(&self) -> Color {
- let mut mem = ::core::mem::MaybeUninit::<<Color as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_test2(&mut self, x: Color) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[24..].as_mut_ptr(),
- ::core::mem::size_of::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn y(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn test3(&self) -> &Test {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid struct in this slot
- unsafe { &*(self.0[26..].as_ptr() as *const Test) }
- }
-
- #[allow(clippy::identity_op)]
- pub fn set_test3(&mut self, x: &Test) {
- self.0[26..26 + 4].copy_from_slice(&x.0)
- }
-
- pub fn unpack(&self) -> Vec3T {
- Vec3T {
- x: self.x(),
- y: self.y(),
- z: self.z(),
- test1: self.test1(),
- test2: self.test2(),
- test3: self.test3().unpack(),
+ pub fn set_y(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
+
+ pub fn z(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[8..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_z(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[8..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test1(&self) -> f64 {
+ let mut mem = ::core::mem::MaybeUninit::<<f64 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_test1(&mut self, x: f64) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[16..].as_mut_ptr(),
+ ::core::mem::size_of::<<f64 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test2(&self) -> Color {
+ let mut mem = ::core::mem::MaybeUninit::<<Color as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_test2(&mut self, x: Color) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[24..].as_mut_ptr(),
+ ::core::mem::size_of::<<Color as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn test3(&self) -> &Test {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid struct in this slot
+ unsafe { &*(self.0[26..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_test3(&mut self, x: &Test) {
+ self.0[26..26 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> Vec3T {
+ Vec3T {
+ x: self.x(),
+ y: self.y(),
+ z: self.z(),
+ test1: self.test1(),
+ test2: self.test2(),
+ test3: self.test3().unpack(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct Vec3T {
- pub x: f32,
- pub y: f32,
- pub z: f32,
- pub test1: f64,
- pub test2: Color,
- pub test3: TestT,
+ pub x: f32,
+ pub y: f32,
+ pub z: f32,
+ pub test1: f64,
+ pub test2: Color,
+ pub test3: TestT,
}
impl Vec3T {
- pub fn pack(&self) -> Vec3 {
- Vec3::new(
- self.x,
- self.y,
- self.z,
- self.test1,
- self.test2,
- &self.test3.pack(),
- )
- }
+ pub fn pack(&self) -> Vec3 {
+ Vec3::new(
+ self.x,
+ self.y,
+ self.z,
+ self.test1,
+ self.test2,
+ &self.test3.pack(),
+ )
+ }
}
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 cef325d..7c5856e 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
@@ -9,102 +9,102 @@
#[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> {
- type Inner = Monster<'a>;
+ type Inner = Monster<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> Monster<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.Example2.Monster"
- }
-
- #[inline]
- 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>,
- _args: &'args MonsterArgs
- ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
- let mut builder = MonsterBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> MonsterT {
- MonsterT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example2.Monster"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args MonsterArgs
+ ) -> ::flatbuffers::WIPOffset<Monster<'bldr>> {
+ let mut builder = MonsterBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> MonsterT {
+ MonsterT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for Monster<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct MonsterArgs {
}
impl<'a> Default for MonsterArgs {
- #[inline]
- fn default() -> Self {
- MonsterArgs {
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ }
}
- }
}
impl Serialize for Monster<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let s = serializer.serialize_struct("Monster", 0)?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let s = serializer.serialize_struct("Monster", 0)?;
+ s.end()
+ }
}
pub struct MonsterBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- MonsterBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> MonsterBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("Monster");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -113,18 +113,18 @@
}
impl Default for MonsterT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl MonsterT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
- Monster::create(_fbb, &MonsterArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Monster<'b>> {
+ 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 19d3fdf..2b4bcc1 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
@@ -9,102 +9,102 @@
#[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> {
- type Inner = InParentNamespace<'a>;
+ type Inner = InParentNamespace<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> InParentNamespace<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.InParentNamespace"
- }
-
- #[inline]
- 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>,
- _args: &'args InParentNamespaceArgs
- ) -> ::flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
- let mut builder = InParentNamespaceBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> InParentNamespaceT {
- InParentNamespaceT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.InParentNamespace"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args InParentNamespaceArgs
+ ) -> ::flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
+ let mut builder = InParentNamespaceBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> InParentNamespaceT {
+ InParentNamespaceT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for InParentNamespace<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct InParentNamespaceArgs {
}
impl<'a> Default for InParentNamespaceArgs {
- #[inline]
- fn default() -> Self {
- InParentNamespaceArgs {
+ #[inline]
+ fn default() -> Self {
+ InParentNamespaceArgs {
+ }
}
- }
}
impl Serialize for InParentNamespace<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let s = serializer.serialize_struct("InParentNamespace", 0)?;
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let s = serializer.serialize_struct("InParentNamespace", 0)?;
+ s.end()
+ }
}
pub struct InParentNamespaceBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- InParentNamespaceBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> InParentNamespaceBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ InParentNamespaceBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("InParentNamespace");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -113,18 +113,18 @@
}
impl Default for InParentNamespaceT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl InParentNamespaceT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<InParentNamespace<'b>> {
- InParentNamespace::create(_fbb, &InParentNamespaceArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<InParentNamespace<'b>> {
+ 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 fb89543..1ee5da7 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
@@ -14,7 +14,7 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
- FromInclude::IncludeVal,
+ FromInclude::IncludeVal,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,40 +23,40 @@
#[allow(non_upper_case_globals)]
impl FromInclude {
- pub const IncludeVal: Self = Self(0);
+ pub const IncludeVal: Self = Self(0);
- pub const ENUM_MIN: i64 = 0;
- pub const ENUM_MAX: i64 = 0;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::IncludeVal,
- ];
+ pub const ENUM_MIN: i64 = 0;
+ pub const ENUM_MAX: i64 = 0;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::IncludeVal,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::IncludeVal => Some("IncludeVal"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::IncludeVal => Some("IncludeVal"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl Serialize for FromInclude {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- serializer.serialize_unit_variant("FromInclude", self.0 as u32, self.variant_name().unwrap())
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ serializer.serialize_unit_variant("FromInclude", self.0 as u32, self.variant_name().unwrap())
+ }
}
impl<'de> serde::Deserialize<'de> for FromInclude {
@@ -79,13 +79,13 @@
}
impl<'a> ::flatbuffers::Follow<'a> for FromInclude {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i64>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for FromInclude {
@@ -98,28 +98,28 @@
}
impl ::flatbuffers::EndianScalar for FromInclude {
- type Scalar = i64;
+ type Scalar = i64;
- #[inline]
- fn to_little_endian(self) -> i64 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i64 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i64) -> Self {
- let b = i64::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i64) -> Self {
+ let b = i64::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for FromInclude {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i64::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i64::run_verifier(v, pos)
+ }
}
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 9a7eb88..177cfeb 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
@@ -9,68 +9,68 @@
#[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> {
- type Inner = TableB<'a>;
+ type Inner = TableB<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableBArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
- let mut builder = TableBBuilder::new(_fbb);
- if let Some(x) = args.a { builder.add_a(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableBT {
- let a = self.a().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableBT {
- a,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.TableB"
}
- }
- #[inline]
- pub fn a(&self) -> Option<super::super::TableA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableBArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableB<'bldr>> {
+ let mut builder = TableBBuilder::new(_fbb);
+ if let Some(x) = args.a { builder.add_a(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableBT {
+ let a = self.a().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::super::TableA>>(TableB::VT_A, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableBArgs<'a> {
@@ -78,88 +78,88 @@
}
impl<'a> Default for TableBArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableBArgs {
- a: None,
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
}
- }
}
impl Serialize for TableB<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("TableB", 1)?;
- if let Some(f) = self.a() {
- s.serialize_field("a", &f)?;
- } else {
- s.skip_field("a")?;
- }
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("TableB", 1)?;
+ if let Some(f) = self.a() {
+ s.serialize_field("a", &f)?;
+ } else {
+ s.skip_field("a")?;
+ }
+ s.end()
+ }
}
pub struct TableBBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableBBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableBBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_a(&mut self, a: ::flatbuffers::WIPOffset<super::super::TableA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::super::TableA>>(TableB::VT_A, a);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableBBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableBBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableBT {
- pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
+ pub a: Option<alloc::boxed::Box<super::super::TableAT>>,
}
impl Default for TableBT {
- fn default() -> Self {
- Self {
- a: None,
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
}
- }
}
impl TableBT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
- let a = self.a.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableB::create(_fbb, &TableBArgs{
- a,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
}
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 03491e2..4d8a1b9 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
@@ -10,38 +10,38 @@
#[derive(Clone, Copy, PartialEq)]
pub struct Unused(pub [u8; 4]);
-impl Default for Unused {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Unused {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Unused>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Unused>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Unused {
- type Inner = &'a Unused;
+ type Inner = &'a Unused;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Unused>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Unused {
@@ -60,84 +60,84 @@
}
impl<'a> ::flatbuffers::Verifiable for Unused {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl Serialize for Unused {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
let mut s = serializer.serialize_struct("Unused", 1)?;
- s.serialize_field("a", &self.a())?;
- s.end()
- }
+ s.serialize_field("a", &self.a())?;
+ s.end()
+ }
}
impl<'a> Unused {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_a(a);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "MyGame.OtherNameSpace.Unused"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s
}
- }
- pub fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.OtherNameSpace.Unused"
}
- }
+
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> UnusedT {
+ UnusedT {
+ a: self.a(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct UnusedT {
- pub a: i32,
+ pub a: i32,
}
impl UnusedT {
- pub fn pack(&self) -> Unused {
- Unused::new(
- self.a,
- )
- }
+ pub fn pack(&self) -> Unused {
+ Unused::new(
+ self.a,
+ )
+ }
}
diff --git a/tests/monster_test_serialize/table_a_generated.rs b/tests/monster_test_serialize/table_a_generated.rs
index 1f8a709..d079d5f 100644
--- a/tests/monster_test_serialize/table_a_generated.rs
+++ b/tests/monster_test_serialize/table_a_generated.rs
@@ -9,68 +9,68 @@
#[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> {
- type Inner = TableA<'a>;
+ type Inner = TableA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
- let mut builder = TableABuilder::new(_fbb);
- if let Some(x) = args.b { builder.add_b(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableAT {
- let b = self.b().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableAT {
- b,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
}
- }
- #[inline]
- pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args TableAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableAArgs<'a> {
@@ -78,88 +78,88 @@
}
impl<'a> Default for TableAArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableAArgs {
- b: None,
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
}
- }
}
impl Serialize for TableA<'_> {
- fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
- where
- S: Serializer,
- {
- let mut s = serializer.serialize_struct("TableA", 1)?;
- if let Some(f) = self.b() {
- s.serialize_field("b", &f)?;
- } else {
- s.skip_field("b")?;
- }
- s.end()
- }
+ fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
+ where
+ S: Serializer,
+ {
+ let mut s = serializer.serialize_struct("TableA", 1)?;
+ if let Some(f) = self.b() {
+ s.serialize_field("b", &f)?;
+ } else {
+ s.skip_field("b")?;
+ }
+ s.end()
+ }
}
pub struct TableABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableABuilder<'a, 'b, A> {
- #[inline]
- pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_b(&mut self, b: ::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<my_game::other_name_space::TableB>>(TableA::VT_B, b);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
- pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
+ pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
impl Default for TableAT {
- fn default() -> Self {
- Self {
- b: None,
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
}
- }
}
impl TableAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
- let b = self.b.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableA::create(_fbb, &TableAArgs{
- b,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
}
diff --git a/tests/more_defaults/abc_generated.rs b/tests/more_defaults/abc_generated.rs
index a3c54fb..5a87917 100644
--- a/tests/more_defaults/abc_generated.rs
+++ b/tests/more_defaults/abc_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ABC: [ABC; 3] = [
- ABC::A,
- ABC::B,
- ABC::C,
+ ABC::A,
+ ABC::B,
+ ABC::C,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl ABC {
- pub const A: Self = Self(0);
- pub const B: Self = Self(1);
- pub const C: Self = Self(2);
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
+ pub const C: Self = Self(2);
- pub const ENUM_MIN: i32 = 0;
- pub const ENUM_MAX: i32 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::A,
- Self::B,
- Self::C,
- ];
+ pub const ENUM_MIN: i32 = 0;
+ pub const ENUM_MAX: i32 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ Self::C,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::A => Some("A"),
- Self::B => Some("B"),
- Self::C => Some("C"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::A => Some("A"),
+ Self::B => Some("B"),
+ Self::C => Some("C"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for ABC {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for ABC {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for ABC {
- type Scalar = i32;
+ type Scalar = i32;
- #[inline]
- fn to_little_endian(self) -> i32 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i32 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i32) -> Self {
- let b = i32::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i32) -> Self {
+ let b = i32::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for ABC {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i32::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i32::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for ABC {}
diff --git a/tests/more_defaults/more_defaults_generated.rs b/tests/more_defaults/more_defaults_generated.rs
index 784297c..7099875 100644
--- a/tests/more_defaults/more_defaults_generated.rs
+++ b/tests/more_defaults/more_defaults_generated.rs
@@ -7,149 +7,149 @@
#[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> {
- type Inner = MoreDefaults<'a>;
+ type Inner = MoreDefaults<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args MoreDefaultsArgs<'args>
- ) -> ::flatbuffers::WIPOffset<MoreDefaults<'bldr>> {
- let mut builder = MoreDefaultsBuilder::new(_fbb);
- if let Some(x) = args.bools { builder.add_bools(x); }
- if let Some(x) = args.abcs { builder.add_abcs(x); }
- if let Some(x) = args.some_string { builder.add_some_string(x); }
- if let Some(x) = args.empty_string { builder.add_empty_string(x); }
- if let Some(x) = args.floats { builder.add_floats(x); }
- if let Some(x) = args.ints { builder.add_ints(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> MoreDefaultsT {
- let ints = {
- let x = self.ints();
- x.into_iter().collect()
- };
- let floats = {
- let x = self.floats();
- x.into_iter().collect()
- };
- let empty_string = {
- let x = self.empty_string();
- alloc::string::ToString::to_string(x)
- };
- let some_string = {
- let x = self.some_string();
- alloc::string::ToString::to_string(x)
- };
- let abcs = {
- let x = self.abcs();
- x.into_iter().collect()
- };
- let bools = {
- let x = self.bools();
- x.into_iter().collect()
- };
- MoreDefaultsT {
- ints,
- floats,
- empty_string,
- some_string,
- abcs,
- bools,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MoreDefaults"
}
- }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i32>>>(MoreDefaults::VT_INTS, Some(Default::default())).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ MoreDefaults { _tab: table }
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f32>>>(MoreDefaults::VT_FLOATS, Some(Default::default())).unwrap()}
- }
+ #[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>,
+ args: &'args MoreDefaultsArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<MoreDefaults<'bldr>> {
+ let mut builder = MoreDefaultsBuilder::new(_fbb);
+ if let Some(x) = args.bools { builder.add_bools(x); }
+ if let Some(x) = args.abcs { builder.add_abcs(x); }
+ if let Some(x) = args.some_string { builder.add_some_string(x); }
+ if let Some(x) = args.empty_string { builder.add_empty_string(x); }
+ if let Some(x) = args.floats { builder.add_floats(x); }
+ if let Some(x) = args.ints { builder.add_ints(x); }
+ builder.finish()
+ }
- #[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::<::flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_EMPTY_STRING, Some(&"")).unwrap()}
- }
+ pub fn unpack(&self) -> MoreDefaultsT {
+ let ints = {
+ let x = self.ints();
+ x.into_iter().collect()
+ };
+ let floats = {
+ let x = self.floats();
+ x.into_iter().collect()
+ };
+ let empty_string = {
+ let x = self.empty_string();
+ alloc::string::ToString::to_string(x)
+ };
+ let some_string = {
+ let x = self.some_string();
+ alloc::string::ToString::to_string(x)
+ };
+ let abcs = {
+ let x = self.abcs();
+ x.into_iter().collect()
+ };
+ let bools = {
+ let x = self.bools();
+ x.into_iter().collect()
+ };
+ MoreDefaultsT {
+ ints,
+ floats,
+ empty_string,
+ some_string,
+ abcs,
+ bools,
+ }
+ }
- #[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::<::flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_SOME_STRING, Some(&"some")).unwrap()}
- }
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, i32>>>(MoreDefaults::VT_INTS, Some(Default::default())).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ABC>>>(MoreDefaults::VT_ABCS, Some(Default::default())).unwrap()}
- }
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, f32>>>(MoreDefaults::VT_FLOATS, Some(Default::default())).unwrap()}
+ }
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(MoreDefaults::VT_BOOLS, 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::<::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::<::flatbuffers::ForwardsUOffset<&str>>(MoreDefaults::VT_SOME_STRING, Some(&"some")).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, ABC>>>(MoreDefaults::VT_ABCS, Some(Default::default())).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Vector<'a, bool>>>(MoreDefaults::VT_BOOLS, Some(Default::default())).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for MoreDefaults<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .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(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .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> {
@@ -162,144 +162,144 @@
}
impl<'a> Default for MoreDefaultsArgs<'a> {
- #[inline]
- fn default() -> Self {
- MoreDefaultsArgs {
- ints: None,
- floats: None,
- empty_string: None,
- some_string: None,
- abcs: None,
- bools: None,
+ #[inline]
+ fn default() -> Self {
+ MoreDefaultsArgs {
+ ints: None,
+ floats: None,
+ empty_string: None,
+ some_string: None,
+ abcs: None,
+ bools: None,
+ }
}
- }
}
pub struct MoreDefaultsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> MoreDefaultsBuilder<'a, 'b, A> {
- #[inline]
- 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<::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::<::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::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_SOME_STRING, some_string);
- }
-
- #[inline]
- 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<::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> {
- let start = _fbb.start_table();
- MoreDefaultsBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ 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 finish(self) -> ::flatbuffers::WIPOffset<MoreDefaults<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ 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::<::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::<::flatbuffers::WIPOffset<_>>(MoreDefaults::VT_SOME_STRING, some_string);
+ }
+
+ #[inline]
+ 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<::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> {
+ let start = _fbb.start_table();
+ MoreDefaultsBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<MoreDefaults<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("empty_string", &self.empty_string());
- ds.field("some_string", &self.some_string());
- ds.field("abcs", &self.abcs());
- ds.field("bools", &self.bools());
- ds.finish()
- }
+ 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());
+ ds.field("empty_string", &self.empty_string());
+ ds.field("some_string", &self.some_string());
+ ds.field("abcs", &self.abcs());
+ ds.field("bools", &self.bools());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MoreDefaultsT {
- pub ints: alloc::vec::Vec<i32>,
- pub floats: alloc::vec::Vec<f32>,
- pub empty_string: alloc::string::String,
- pub some_string: alloc::string::String,
- pub abcs: alloc::vec::Vec<ABC>,
- pub bools: alloc::vec::Vec<bool>,
+ pub ints: alloc::vec::Vec<i32>,
+ pub floats: alloc::vec::Vec<f32>,
+ pub empty_string: alloc::string::String,
+ pub some_string: alloc::string::String,
+ pub abcs: alloc::vec::Vec<ABC>,
+ pub bools: alloc::vec::Vec<bool>,
}
impl Default for MoreDefaultsT {
- fn default() -> Self {
- Self {
- ints: Default::default(),
- floats: Default::default(),
- empty_string: alloc::string::ToString::to_string(""),
- some_string: alloc::string::ToString::to_string("some"),
- abcs: Default::default(),
- bools: Default::default(),
+ fn default() -> Self {
+ Self {
+ ints: Default::default(),
+ floats: Default::default(),
+ 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>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<MoreDefaults<'b>> {
- let ints = Some({
- let x = &self.ints;
- _fbb.create_vector(x)
- });
- let floats = Some({
- let x = &self.floats;
- _fbb.create_vector(x)
- });
- let empty_string = Some({
- let x = &self.empty_string;
- _fbb.create_string(x)
- });
- let some_string = Some({
- let x = &self.some_string;
- _fbb.create_string(x)
- });
- let abcs = Some({
- let x = &self.abcs;
- _fbb.create_vector(x)
- });
- let bools = Some({
- let x = &self.bools;
- _fbb.create_vector(x)
- });
- MoreDefaults::create(_fbb, &MoreDefaultsArgs{
- ints,
- floats,
- empty_string,
- some_string,
- abcs,
- bools,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<MoreDefaults<'b>> {
+ let ints = Some({
+ let x = &self.ints;
+ _fbb.create_vector(x)
+ });
+ let floats = Some({
+ let x = &self.floats;
+ _fbb.create_vector(x)
+ });
+ let empty_string = Some({
+ let x = &self.empty_string;
+ _fbb.create_string(x)
+ });
+ let some_string = Some({
+ let x = &self.some_string;
+ _fbb.create_string(x)
+ });
+ let abcs = Some({
+ let x = &self.abcs;
+ _fbb.create_vector(x)
+ });
+ let bools = Some({
+ let x = &self.bools;
+ _fbb.create_vector(x)
+ });
+ MoreDefaults::create(_fbb, &MoreDefaultsArgs{
+ ints,
+ floats,
+ empty_string,
+ some_string,
+ abcs,
+ bools,
+ })
+ }
}
diff --git a/tests/namespace_test/mod.rs b/tests/namespace_test/mod.rs
index 22c667e..1a0c58c 100644
--- a/tests/namespace_test/mod.rs
+++ b/tests/namespace_test/mod.rs
@@ -1,25 +1,25 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod namespace_a {
- use super::*;
- pub mod namespace_b {
use super::*;
- mod union_in_nested_ns_generated;
- pub use self::union_in_nested_ns_generated::*;
- mod enum_in_nested_ns_generated;
- pub use self::enum_in_nested_ns_generated::*;
- mod table_in_nested_ns_generated;
- pub use self::table_in_nested_ns_generated::*;
- mod struct_in_nested_ns_generated;
- pub use self::struct_in_nested_ns_generated::*;
- } // namespace_b
- mod table_in_first_ns_generated;
- pub use self::table_in_first_ns_generated::*;
- mod second_table_in_a_generated;
- pub use self::second_table_in_a_generated::*;
+ pub mod namespace_b {
+ use super::*;
+ mod union_in_nested_ns_generated;
+ pub use self::union_in_nested_ns_generated::*;
+ mod enum_in_nested_ns_generated;
+ pub use self::enum_in_nested_ns_generated::*;
+ mod table_in_nested_ns_generated;
+ pub use self::table_in_nested_ns_generated::*;
+ mod struct_in_nested_ns_generated;
+ pub use self::struct_in_nested_ns_generated::*;
+ } // namespace_b
+ mod table_in_first_ns_generated;
+ pub use self::table_in_first_ns_generated::*;
+ mod second_table_in_a_generated;
+ pub use self::second_table_in_a_generated::*;
} // namespace_a
pub mod namespace_c {
- use super::*;
- mod table_in_c_generated;
- pub use self::table_in_c_generated::*;
+ use super::*;
+ mod table_in_c_generated;
+ pub use self::table_in_c_generated::*;
} // namespace_c
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 54b79c1..e466ac8 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
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ENUM_IN_NESTED_NS: [EnumInNestedNS; 3] = [
- EnumInNestedNS::A,
- EnumInNestedNS::B,
- EnumInNestedNS::C,
+ EnumInNestedNS::A,
+ EnumInNestedNS::B,
+ EnumInNestedNS::C,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl EnumInNestedNS {
- pub const A: Self = Self(0);
- pub const B: Self = Self(1);
- pub const C: Self = Self(2);
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
+ pub const C: Self = Self(2);
- pub const ENUM_MIN: i8 = 0;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::A,
- Self::B,
- Self::C,
- ];
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ Self::C,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::A => Some("A"),
- Self::B => Some("B"),
- Self::C => Some("C"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::A => Some("A"),
+ Self::B => Some("B"),
+ Self::C => Some("C"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for EnumInNestedNS {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for EnumInNestedNS {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for EnumInNestedNS {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for EnumInNestedNS {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
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 75d1909..c3c627b 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
@@ -8,39 +8,39 @@
#[derive(Clone, Copy, PartialEq)]
pub struct StructInNestedNS(pub [u8; 8]);
-impl Default for StructInNestedNS {
- fn default() -> Self {
- Self([0; 8])
- }
+impl Default for StructInNestedNS {
+ fn default() -> Self {
+ Self([0; 8])
+ }
}
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())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("StructInNestedNS")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {}
impl<'a> ::flatbuffers::Follow<'a> for StructInNestedNS {
- type Inner = &'a StructInNestedNS;
+ type Inner = &'a StructInNestedNS;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a StructInNestedNS>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a StructInNestedNS>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a StructInNestedNS {
- type Inner = &'a StructInNestedNS;
+ type Inner = &'a StructInNestedNS;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<StructInNestedNS>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for StructInNestedNS {
@@ -59,107 +59,107 @@
}
impl<'a> ::flatbuffers::Verifiable for StructInNestedNS {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> StructInNestedNS {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- a: i32,
- b: i32,
- ) -> Self {
- let mut s = Self([0; 8]);
- s.set_a(a);
- s.set_b(b);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "NamespaceA.NamespaceB.StructInNestedNS"
- }
-
- pub fn a(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_a(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i32,
+ b: i32,
+ ) -> Self {
+ let mut s = Self([0; 8]);
+ s.set_a(a);
+ s.set_b(b);
+ s
}
- }
- pub fn b(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_b(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.NamespaceB.StructInNestedNS"
}
- }
- pub fn unpack(&self) -> StructInNestedNST {
- StructInNestedNST {
- a: self.a(),
- b: self.b(),
+ pub fn a(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_a(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn b(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_b(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> StructInNestedNST {
+ StructInNestedNST {
+ a: self.a(),
+ b: self.b(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct StructInNestedNST {
- pub a: i32,
- pub b: i32,
+ pub a: i32,
+ pub b: i32,
}
impl StructInNestedNST {
- pub fn pack(&self) -> StructInNestedNS {
- StructInNestedNS::new(
- self.a,
- self.b,
- )
- }
+ pub fn pack(&self) -> StructInNestedNS {
+ StructInNestedNS::new(
+ self.a,
+ self.b,
+ )
+ }
}
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 856ae6e..f85b0d2 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
@@ -7,66 +7,66 @@
#[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> {
- type Inner = TableInNestedNS<'a>;
+ type Inner = TableInNestedNS<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableInNestedNSArgs
- ) -> ::flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
- let mut builder = TableInNestedNSBuilder::new(_fbb);
- builder.add_foo(args.foo);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableInNestedNST {
- let foo = self.foo();
- TableInNestedNST {
- foo,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.NamespaceB.TableInNestedNS"
}
- }
- #[inline]
- pub fn foo(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(TableInNestedNS::VT_FOO, Some(0)).unwrap()}
- }
+ #[inline]
+ 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>,
+ args: &'args TableInNestedNSArgs
+ ) -> ::flatbuffers::WIPOffset<TableInNestedNS<'bldr>> {
+ let mut builder = TableInNestedNSBuilder::new(_fbb);
+ builder.add_foo(args.foo);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableInNestedNST {
+ let foo = self.foo();
+ TableInNestedNST {
+ foo,
+ }
+ }
+
+ #[inline]
+ pub fn foo(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(TableInNestedNS::VT_FOO, Some(0)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for TableInNestedNS<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i32>("foo", Self::VT_FOO, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i32>("foo", Self::VT_FOO, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableInNestedNSArgs {
@@ -74,71 +74,71 @@
}
impl<'a> Default for TableInNestedNSArgs {
- #[inline]
- fn default() -> Self {
- TableInNestedNSArgs {
- foo: 0,
+ #[inline]
+ fn default() -> Self {
+ TableInNestedNSArgs {
+ foo: 0,
+ }
}
- }
}
pub struct TableInNestedNSBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i32>(TableInNestedNS::VT_FOO, foo, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableInNestedNSBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_foo(&mut self, foo: i32) {
+ self.fbb_.push_slot::<i32>(TableInNestedNS::VT_FOO, foo, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInNestedNS<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInNestedNSBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableInNestedNSBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInNestedNS<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInNestedNST {
- pub foo: i32,
+ pub foo: i32,
}
impl Default for TableInNestedNST {
- fn default() -> Self {
- Self {
- foo: 0,
+ fn default() -> Self {
+ Self {
+ foo: 0,
+ }
}
- }
}
impl TableInNestedNST {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableInNestedNS<'b>> {
- let foo = self.foo;
- TableInNestedNS::create(_fbb, &TableInNestedNSArgs{
- foo,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableInNestedNS<'b>> {
+ 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 87ea03a..0ac41c0 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
@@ -12,8 +12,8 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_UNION_IN_NESTED_NS: [UnionInNestedNS; 2] = [
- UnionInNestedNS::NONE,
- UnionInNestedNS::TableInNestedNS,
+ UnionInNestedNS::NONE,
+ UnionInNestedNS::TableInNestedNS,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -22,44 +22,44 @@
#[allow(non_upper_case_globals)]
impl UnionInNestedNS {
- pub const NONE: Self = Self(0);
- pub const TableInNestedNS: Self = Self(1);
+ pub const NONE: Self = Self(0);
+ pub const TableInNestedNS: Self = Self(1);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 1;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::TableInNestedNS,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::TableInNestedNS,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::TableInNestedNS => Some("TableInNestedNS"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::TableInNestedNS => Some("TableInNestedNS"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for UnionInNestedNS {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for UnionInNestedNS {
@@ -72,28 +72,28 @@
}
impl ::flatbuffers::EndianScalar for UnionInNestedNS {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for UnionInNestedNS {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
@@ -104,53 +104,53 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum UnionInNestedNST {
- NONE,
- TableInNestedNS(alloc::boxed::Box<TableInNestedNST>),
+ NONE,
+ TableInNestedNS(alloc::boxed::Box<TableInNestedNST>),
}
impl Default for UnionInNestedNST {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl UnionInNestedNST {
- pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
- match self {
- Self::NONE => UnionInNestedNS::NONE,
- Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
+ pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
+ match self {
+ Self::NONE => UnionInNestedNS::NONE,
+ Self::TableInNestedNS(_) => UnionInNestedNS::TableInNestedNS,
+ }
}
- }
- 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()),
+ 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<alloc::boxed::Box<TableInNestedNST>> {
- if let Self::TableInNestedNS(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::TableInNestedNS(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned TableInNestedNST, setting the union to NONE.
+ pub fn take_table_in_nested_ns(&mut self) -> Option<alloc::boxed::Box<TableInNestedNST>> {
+ if let Self::TableInNestedNS(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::TableInNestedNS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the TableInNestedNST.
- pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> {
- if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return a reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns(&self) -> Option<&TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_ref()) } else { None }
+ }
- /// If the union variant matches, return a mutable reference to the TableInNestedNST.
- pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> {
- if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a mutable reference to the TableInNestedNST.
+ pub fn as_table_in_nested_ns_mut(&mut self) -> Option<&mut TableInNestedNST> {
+ if let Self::TableInNestedNS(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 2e30045..0c0a754 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
@@ -7,68 +7,68 @@
#[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> {
- type Inner = SecondTableInA<'a>;
+ type Inner = SecondTableInA<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args SecondTableInAArgs<'args>
- ) -> ::flatbuffers::WIPOffset<SecondTableInA<'bldr>> {
- let mut builder = SecondTableInABuilder::new(_fbb);
- if let Some(x) = args.refer_to_c { builder.add_refer_to_c(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> SecondTableInAT {
- let refer_to_c = self.refer_to_c().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- SecondTableInAT {
- refer_to_c,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.SecondTableInA"
}
- }
- #[inline]
- pub fn refer_to_c(&self) -> Option<super::namespace_c::TableInC<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_c::TableInC>>(SecondTableInA::VT_REFER_TO_C, None)}
- }
+ #[inline]
+ 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>,
+ args: &'args SecondTableInAArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<SecondTableInA<'bldr>> {
+ let mut builder = SecondTableInABuilder::new(_fbb);
+ if let Some(x) = args.refer_to_c { builder.add_refer_to_c(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> SecondTableInAT {
+ let refer_to_c = self.refer_to_c().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ SecondTableInAT {
+ refer_to_c,
+ }
+ }
+
+ #[inline]
+ pub fn refer_to_c(&self) -> Option<super::namespace_c::TableInC<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_c::TableInC>>(SecondTableInA::VT_REFER_TO_C, None)}
+ }
}
impl ::flatbuffers::Verifiable for SecondTableInA<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_c::TableInC>>("refer_to_c", Self::VT_REFER_TO_C, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_c::TableInC>>("refer_to_c", Self::VT_REFER_TO_C, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct SecondTableInAArgs<'a> {
@@ -76,73 +76,73 @@
}
impl<'a> Default for SecondTableInAArgs<'a> {
- #[inline]
- fn default() -> Self {
- SecondTableInAArgs {
- refer_to_c: None,
+ #[inline]
+ fn default() -> Self {
+ SecondTableInAArgs {
+ refer_to_c: None,
+ }
}
- }
}
pub struct SecondTableInABuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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<super::namespace_c::TableInC<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_c::TableInC>>(SecondTableInA::VT_REFER_TO_C, refer_to_c);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> SecondTableInABuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- SecondTableInABuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_refer_to_c(&mut self, refer_to_c: ::flatbuffers::WIPOffset<super::namespace_c::TableInC<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_c::TableInC>>(SecondTableInA::VT_REFER_TO_C, refer_to_c);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<SecondTableInA<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> SecondTableInABuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ SecondTableInABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<SecondTableInA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct SecondTableInAT {
- pub refer_to_c: Option<alloc::boxed::Box<super::namespace_c::TableInCT>>,
+ pub refer_to_c: Option<alloc::boxed::Box<super::namespace_c::TableInCT>>,
}
impl Default for SecondTableInAT {
- fn default() -> Self {
- Self {
- refer_to_c: None,
+ fn default() -> Self {
+ Self {
+ refer_to_c: None,
+ }
}
- }
}
impl SecondTableInAT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<SecondTableInA<'b>> {
- let refer_to_c = self.refer_to_c.as_ref().map(|x|{
- x.pack(_fbb)
- });
- SecondTableInA::create(_fbb, &SecondTableInAArgs{
- refer_to_c,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<SecondTableInA<'b>> {
+ let refer_to_c = self.refer_to_c.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ SecondTableInA::create(_fbb, &SecondTableInAArgs{
+ refer_to_c,
+ })
+ }
}
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 3ff5ee2..10b14c4 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
@@ -7,147 +7,147 @@
#[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> {
- type Inner = TableInFirstNS<'a>;
+ type Inner = TableInFirstNS<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableInFirstNSArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableInFirstNS<'bldr>> {
- let mut builder = TableInFirstNSBuilder::new(_fbb);
- if let Some(x) = args.foo_struct { builder.add_foo_struct(x); }
- if let Some(x) = args.foo_union { builder.add_foo_union(x); }
- if let Some(x) = args.foo_table { builder.add_foo_table(x); }
- builder.add_foo_union_type(args.foo_union_type);
- builder.add_foo_enum(args.foo_enum);
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableInFirstNST {
- let foo_table = self.foo_table().map(|x| {
- 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(alloc::boxed::Box::new(
- self.foo_union_as_table_in_nested_ns()
- .expect("Invalid union table, expected `namespace_b::UnionInNestedNS::TableInNestedNS`.")
- .unpack()
- )),
- _ => namespace_b::UnionInNestedNST::NONE,
- };
- let foo_struct = self.foo_struct().map(|x| {
- x.unpack()
- });
- TableInFirstNST {
- foo_table,
- foo_enum,
- foo_union,
- foo_struct,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceA.TableInFirstNS"
}
- }
- #[inline]
- pub fn foo_table(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, None)}
- }
-
- #[inline]
- pub fn foo_enum(&self) -> namespace_b::EnumInNestedNS {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, Some(namespace_b::EnumInNestedNS::A)).unwrap()}
- }
-
- #[inline]
- pub fn foo_union_type(&self) -> namespace_b::UnionInNestedNS {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, Some(namespace_b::UnionInNestedNS::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(TableInFirstNS::VT_FOO_UNION, None)}
- }
-
- #[inline]
- pub fn foo_struct(&self) -> Option<&'a namespace_b::StructInNestedNS> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, None)}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn foo_union_as_table_in_nested_ns(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
- if self.foo_union_type() == namespace_b::UnionInNestedNS::TableInNestedNS {
- self.foo_union().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { namespace_b::TableInNestedNS::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ 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>,
+ args: &'args TableInFirstNSArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableInFirstNS<'bldr>> {
+ let mut builder = TableInFirstNSBuilder::new(_fbb);
+ if let Some(x) = args.foo_struct { builder.add_foo_struct(x); }
+ if let Some(x) = args.foo_union { builder.add_foo_union(x); }
+ if let Some(x) = args.foo_table { builder.add_foo_table(x); }
+ builder.add_foo_union_type(args.foo_union_type);
+ builder.add_foo_enum(args.foo_enum);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableInFirstNST {
+ let foo_table = self.foo_table().map(|x| {
+ 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(alloc::boxed::Box::new(
+ self.foo_union_as_table_in_nested_ns()
+ .expect("Invalid union table, expected `namespace_b::UnionInNestedNS::TableInNestedNS`.")
+ .unpack()
+ )),
+ _ => namespace_b::UnionInNestedNST::NONE,
+ };
+ let foo_struct = self.foo_struct().map(|x| {
+ x.unpack()
+ });
+ TableInFirstNST {
+ foo_table,
+ foo_enum,
+ foo_union,
+ foo_struct,
+ }
+ }
+
+ #[inline]
+ pub fn foo_table(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, None)}
+ }
+
+ #[inline]
+ pub fn foo_enum(&self) -> namespace_b::EnumInNestedNS {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, Some(namespace_b::EnumInNestedNS::A)).unwrap()}
+ }
+
+ #[inline]
+ pub fn foo_union_type(&self) -> namespace_b::UnionInNestedNS {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, Some(namespace_b::UnionInNestedNS::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(TableInFirstNS::VT_FOO_UNION, None)}
+ }
+
+ #[inline]
+ pub fn foo_struct(&self) -> Option<&'a namespace_b::StructInNestedNS> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<namespace_b::StructInNestedNS>(TableInFirstNS::VT_FOO_STRUCT, None)}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn foo_union_as_table_in_nested_ns(&self) -> Option<namespace_b::TableInNestedNS<'a>> {
+ if self.foo_union_type() == namespace_b::UnionInNestedNS::TableInNestedNS {
+ self.foo_union().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { namespace_b::TableInNestedNS::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for TableInFirstNS<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("foo_table", Self::VT_FOO_TABLE, false)?
- .visit_field::<namespace_b::EnumInNestedNS>("foo_enum", Self::VT_FOO_ENUM, false)?
- .visit_union::<namespace_b::UnionInNestedNS, _>("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::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("namespace_b::UnionInNestedNS::TableInNestedNS", pos),
- _ => Ok(()),
- }
- })?
- .visit_field::<namespace_b::StructInNestedNS>("foo_struct", Self::VT_FOO_STRUCT, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("foo_table", Self::VT_FOO_TABLE, false)?
+ .visit_field::<namespace_b::EnumInNestedNS>("foo_enum", Self::VT_FOO_ENUM, false)?
+ .visit_union::<namespace_b::UnionInNestedNS, _>("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::<::flatbuffers::ForwardsUOffset<namespace_b::TableInNestedNS>>("namespace_b::UnionInNestedNS::TableInNestedNS", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<namespace_b::StructInNestedNS>("foo_struct", Self::VT_FOO_STRUCT, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableInFirstNSArgs<'a> {
@@ -159,128 +159,128 @@
}
impl<'a> Default for TableInFirstNSArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableInFirstNSArgs {
- foo_table: None,
- foo_enum: namespace_b::EnumInNestedNS::A,
- foo_union_type: namespace_b::UnionInNestedNS::NONE,
- foo_union: None,
- foo_struct: None,
+ #[inline]
+ fn default() -> Self {
+ TableInFirstNSArgs {
+ foo_table: None,
+ foo_enum: namespace_b::EnumInNestedNS::A,
+ foo_union_type: namespace_b::UnionInNestedNS::NONE,
+ foo_union: None,
+ foo_struct: None,
+ }
}
- }
}
pub struct TableInFirstNSBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
impl<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> TableInFirstNSBuilder<'a, 'b, A> {
- #[inline]
- pub fn add_foo_table(&mut self, foo_table: ::flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, foo_table);
- }
-
- #[inline]
- pub fn add_foo_enum(&mut self, foo_enum: namespace_b::EnumInNestedNS) {
- self.fbb_.push_slot::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, foo_enum, namespace_b::EnumInNestedNS::A);
- }
-
- #[inline]
- pub fn add_foo_union_type(&mut self, foo_union_type: namespace_b::UnionInNestedNS) {
- self.fbb_.push_slot::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, foo_union_type, namespace_b::UnionInNestedNS::NONE);
- }
-
- #[inline]
- 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> {
- let start = _fbb.start_table();
- TableInFirstNSBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_foo_table(&mut self, foo_table: ::flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<namespace_b::TableInNestedNS>>(TableInFirstNS::VT_FOO_TABLE, foo_table);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInFirstNS<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_foo_enum(&mut self, foo_enum: namespace_b::EnumInNestedNS) {
+ self.fbb_.push_slot::<namespace_b::EnumInNestedNS>(TableInFirstNS::VT_FOO_ENUM, foo_enum, namespace_b::EnumInNestedNS::A);
+ }
+
+ #[inline]
+ pub fn add_foo_union_type(&mut self, foo_union_type: namespace_b::UnionInNestedNS) {
+ self.fbb_.push_slot::<namespace_b::UnionInNestedNS>(TableInFirstNS::VT_FOO_UNION_TYPE, foo_union_type, namespace_b::UnionInNestedNS::NONE);
+ }
+
+ #[inline]
+ 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> {
+ let start = _fbb.start_table();
+ TableInFirstNSBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInFirstNS<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("foo_union_type", &self.foo_union_type());
- match self.foo_union_type() {
- namespace_b::UnionInNestedNS::TableInNestedNS => {
- if let Some(x) = self.foo_union_as_table_in_nested_ns() {
- ds.field("foo_union", &x)
- } else {
- ds.field("foo_union", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("foo_union", &x)
- },
- };
- ds.field("foo_struct", &self.foo_struct());
- ds.finish()
- }
+ 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());
+ ds.field("foo_union_type", &self.foo_union_type());
+ match self.foo_union_type() {
+ namespace_b::UnionInNestedNS::TableInNestedNS => {
+ if let Some(x) = self.foo_union_as_table_in_nested_ns() {
+ ds.field("foo_union", &x)
+ } else {
+ ds.field("foo_union", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("foo_union", &x)
+ },
+ };
+ ds.field("foo_struct", &self.foo_struct());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInFirstNST {
- pub foo_table: Option<alloc::boxed::Box<namespace_b::TableInNestedNST>>,
- pub foo_enum: namespace_b::EnumInNestedNS,
- pub foo_union: namespace_b::UnionInNestedNST,
- pub foo_struct: Option<namespace_b::StructInNestedNST>,
+ pub foo_table: Option<alloc::boxed::Box<namespace_b::TableInNestedNST>>,
+ pub foo_enum: namespace_b::EnumInNestedNS,
+ pub foo_union: namespace_b::UnionInNestedNST,
+ pub foo_struct: Option<namespace_b::StructInNestedNST>,
}
impl Default for TableInFirstNST {
- fn default() -> Self {
- Self {
- foo_table: None,
- foo_enum: namespace_b::EnumInNestedNS::A,
- foo_union: namespace_b::UnionInNestedNST::NONE,
- foo_struct: None,
+ fn default() -> Self {
+ Self {
+ foo_table: None,
+ foo_enum: namespace_b::EnumInNestedNS::A,
+ foo_union: namespace_b::UnionInNestedNST::NONE,
+ foo_struct: None,
+ }
}
- }
}
impl TableInFirstNST {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableInFirstNS<'b>> {
- let foo_table = self.foo_table.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let foo_enum = self.foo_enum;
- let foo_union_type = self.foo_union.union_in_nested_ns_type();
- let foo_union = self.foo_union.pack(_fbb);
- let foo_struct_tmp = self.foo_struct.as_ref().map(|x| x.pack());
- let foo_struct = foo_struct_tmp.as_ref();
- TableInFirstNS::create(_fbb, &TableInFirstNSArgs{
- foo_table,
- foo_enum,
- foo_union_type,
- foo_union,
- foo_struct,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableInFirstNS<'b>> {
+ let foo_table = self.foo_table.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let foo_enum = self.foo_enum;
+ let foo_union_type = self.foo_union.union_in_nested_ns_type();
+ let foo_union = self.foo_union.pack(_fbb);
+ let foo_struct_tmp = self.foo_struct.as_ref().map(|x| x.pack());
+ let foo_struct = foo_struct_tmp.as_ref();
+ TableInFirstNS::create(_fbb, &TableInFirstNSArgs{
+ foo_table,
+ foo_enum,
+ foo_union_type,
+ foo_union,
+ foo_struct,
+ })
+ }
}
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 df3c80e..9988686 100644
--- a/tests/namespace_test/namespace_c/table_in_c_generated.rs
+++ b/tests/namespace_test/namespace_c/table_in_c_generated.rs
@@ -7,83 +7,83 @@
#[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> {
- type Inner = TableInC<'a>;
+ type Inner = TableInC<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args TableInCArgs<'args>
- ) -> ::flatbuffers::WIPOffset<TableInC<'bldr>> {
- let mut builder = TableInCBuilder::new(_fbb);
- if let Some(x) = args.refer_to_a2 { builder.add_refer_to_a2(x); }
- if let Some(x) = args.refer_to_a1 { builder.add_refer_to_a1(x); }
- builder.finish()
- }
-
- pub fn unpack(&self) -> TableInCT {
- let refer_to_a1 = self.refer_to_a1().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- let refer_to_a2 = self.refer_to_a2().map(|x| {
- alloc::boxed::Box::new(x.unpack())
- });
- TableInCT {
- refer_to_a1,
- refer_to_a2,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "NamespaceC.TableInC"
}
- }
- #[inline]
- pub fn refer_to_a1(&self) -> Option<super::namespace_a::TableInFirstNS<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_a::TableInFirstNS>>(TableInC::VT_REFER_TO_A1, None)}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ TableInC { _tab: table }
+ }
- #[inline]
- pub fn refer_to_a2(&self) -> Option<super::namespace_a::SecondTableInA<'a>> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_a::SecondTableInA>>(TableInC::VT_REFER_TO_A2, None)}
- }
+ #[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>,
+ args: &'args TableInCArgs<'args>
+ ) -> ::flatbuffers::WIPOffset<TableInC<'bldr>> {
+ let mut builder = TableInCBuilder::new(_fbb);
+ if let Some(x) = args.refer_to_a2 { builder.add_refer_to_a2(x); }
+ if let Some(x) = args.refer_to_a1 { builder.add_refer_to_a1(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableInCT {
+ let refer_to_a1 = self.refer_to_a1().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ let refer_to_a2 = self.refer_to_a2().map(|x| {
+ alloc::boxed::Box::new(x.unpack())
+ });
+ TableInCT {
+ refer_to_a1,
+ refer_to_a2,
+ }
+ }
+
+ #[inline]
+ pub fn refer_to_a1(&self) -> Option<super::namespace_a::TableInFirstNS<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_a::TableInFirstNS>>(TableInC::VT_REFER_TO_A1, None)}
+ }
+
+ #[inline]
+ pub fn refer_to_a2(&self) -> Option<super::namespace_a::SecondTableInA<'a>> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<super::namespace_a::SecondTableInA>>(TableInC::VT_REFER_TO_A2, None)}
+ }
}
impl ::flatbuffers::Verifiable for TableInC<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_a::TableInFirstNS>>("refer_to_a1", Self::VT_REFER_TO_A1, false)?
- .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_a::SecondTableInA>>("refer_to_a2", Self::VT_REFER_TO_A2, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_a::TableInFirstNS>>("refer_to_a1", Self::VT_REFER_TO_A1, false)?
+ .visit_field::<::flatbuffers::ForwardsUOffset<super::namespace_a::SecondTableInA>>("refer_to_a2", Self::VT_REFER_TO_A2, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct TableInCArgs<'a> {
@@ -92,86 +92,86 @@
}
impl<'a> Default for TableInCArgs<'a> {
- #[inline]
- fn default() -> Self {
- TableInCArgs {
- refer_to_a1: None,
- refer_to_a2: None,
+ #[inline]
+ fn default() -> Self {
+ TableInCArgs {
+ refer_to_a1: None,
+ refer_to_a2: None,
+ }
}
- }
}
pub struct TableInCBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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<super::namespace_a::TableInFirstNS<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_a::TableInFirstNS>>(TableInC::VT_REFER_TO_A1, refer_to_a1);
- }
-
- #[inline]
- pub fn add_refer_to_a2(&mut self, refer_to_a2: ::flatbuffers::WIPOffset<super::namespace_a::SecondTableInA<'b >>) {
- self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_a::SecondTableInA>>(TableInC::VT_REFER_TO_A2, refer_to_a2);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInCBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- TableInCBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_refer_to_a1(&mut self, refer_to_a1: ::flatbuffers::WIPOffset<super::namespace_a::TableInFirstNS<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_a::TableInFirstNS>>(TableInC::VT_REFER_TO_A1, refer_to_a1);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInC<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_refer_to_a2(&mut self, refer_to_a2: ::flatbuffers::WIPOffset<super::namespace_a::SecondTableInA<'b >>) {
+ self.fbb_.push_slot_always::<::flatbuffers::WIPOffset<super::namespace_a::SecondTableInA>>(TableInC::VT_REFER_TO_A2, refer_to_a2);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> TableInCBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ TableInCBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInC<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.finish()
- }
+ 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());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInCT {
- pub refer_to_a1: Option<alloc::boxed::Box<super::namespace_a::TableInFirstNST>>,
- pub refer_to_a2: Option<alloc::boxed::Box<super::namespace_a::SecondTableInAT>>,
+ pub refer_to_a1: Option<alloc::boxed::Box<super::namespace_a::TableInFirstNST>>,
+ pub refer_to_a2: Option<alloc::boxed::Box<super::namespace_a::SecondTableInAT>>,
}
impl Default for TableInCT {
- fn default() -> Self {
- Self {
- refer_to_a1: None,
- refer_to_a2: None,
+ fn default() -> Self {
+ Self {
+ refer_to_a1: None,
+ refer_to_a2: None,
+ }
}
- }
}
impl TableInCT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<TableInC<'b>> {
- let refer_to_a1 = self.refer_to_a1.as_ref().map(|x|{
- x.pack(_fbb)
- });
- let refer_to_a2 = self.refer_to_a2.as_ref().map(|x|{
- x.pack(_fbb)
- });
- TableInC::create(_fbb, &TableInCArgs{
- refer_to_a1,
- refer_to_a2,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<TableInC<'b>> {
+ let refer_to_a1 = self.refer_to_a1.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let refer_to_a2 = self.refer_to_a2.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableInC::create(_fbb, &TableInCArgs{
+ refer_to_a1,
+ refer_to_a2,
+ })
+ }
}
diff --git a/tests/optional_scalars/mod.rs b/tests/optional_scalars/mod.rs
index 84291e3..cbd72e3 100644
--- a/tests/optional_scalars/mod.rs
+++ b/tests/optional_scalars/mod.rs
@@ -1,9 +1,9 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod optional_scalars {
- use super::*;
- mod optional_byte_generated;
- pub use self::optional_byte_generated::*;
- mod scalar_stuff_generated;
- pub use self::scalar_stuff_generated::*;
+ use super::*;
+ mod optional_byte_generated;
+ pub use self::optional_byte_generated::*;
+ mod scalar_stuff_generated;
+ pub use self::scalar_stuff_generated::*;
} // optional_scalars
diff --git a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
index 72026c4..4da704e 100644
--- a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
+++ b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_OPTIONAL_BYTE: [OptionalByte; 3] = [
- OptionalByte::None,
- OptionalByte::One,
- OptionalByte::Two,
+ OptionalByte::None,
+ OptionalByte::One,
+ OptionalByte::Two,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl OptionalByte {
- pub const None: Self = Self(0);
- pub const One: Self = Self(1);
- pub const Two: Self = Self(2);
+ pub const None: Self = Self(0);
+ pub const One: Self = Self(1);
+ pub const Two: Self = Self(2);
- pub const ENUM_MIN: i8 = 0;
- pub const ENUM_MAX: i8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::None,
- Self::One,
- Self::Two,
- ];
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::None,
+ Self::One,
+ Self::Two,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::None => Some("None"),
- Self::One => Some("One"),
- Self::Two => Some("Two"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::None => Some("None"),
+ Self::One => Some("One"),
+ Self::Two => Some("Two"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for OptionalByte {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for OptionalByte {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for OptionalByte {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for OptionalByte {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
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 fe3d8fe..4524bec 100644
--- a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
+++ b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
@@ -7,521 +7,521 @@
#[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> {
- type Inner = ScalarStuff<'a>;
+ type Inner = ScalarStuff<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args ScalarStuffArgs
- ) -> ::flatbuffers::WIPOffset<ScalarStuff<'bldr>> {
- let mut builder = ScalarStuffBuilder::new(_fbb);
- builder.add_default_f64(args.default_f64);
- if let Some(x) = args.maybe_f64 { builder.add_maybe_f64(x); }
- builder.add_just_f64(args.just_f64);
- builder.add_default_u64(args.default_u64);
- if let Some(x) = args.maybe_u64 { builder.add_maybe_u64(x); }
- builder.add_just_u64(args.just_u64);
- builder.add_default_i64(args.default_i64);
- if let Some(x) = args.maybe_i64 { builder.add_maybe_i64(x); }
- builder.add_just_i64(args.just_i64);
- builder.add_default_f32(args.default_f32);
- if let Some(x) = args.maybe_f32 { builder.add_maybe_f32(x); }
- builder.add_just_f32(args.just_f32);
- builder.add_default_u32(args.default_u32);
- if let Some(x) = args.maybe_u32 { builder.add_maybe_u32(x); }
- builder.add_just_u32(args.just_u32);
- builder.add_default_i32(args.default_i32);
- if let Some(x) = args.maybe_i32 { builder.add_maybe_i32(x); }
- builder.add_just_i32(args.just_i32);
- builder.add_default_u16(args.default_u16);
- if let Some(x) = args.maybe_u16 { builder.add_maybe_u16(x); }
- builder.add_just_u16(args.just_u16);
- builder.add_default_i16(args.default_i16);
- if let Some(x) = args.maybe_i16 { builder.add_maybe_i16(x); }
- builder.add_just_i16(args.just_i16);
- builder.add_default_enum(args.default_enum);
- if let Some(x) = args.maybe_enum { builder.add_maybe_enum(x); }
- builder.add_just_enum(args.just_enum);
- builder.add_default_bool(args.default_bool);
- if let Some(x) = args.maybe_bool { builder.add_maybe_bool(x); }
- builder.add_just_bool(args.just_bool);
- builder.add_default_u8(args.default_u8);
- if let Some(x) = args.maybe_u8 { builder.add_maybe_u8(x); }
- builder.add_just_u8(args.just_u8);
- builder.add_default_i8(args.default_i8);
- if let Some(x) = args.maybe_i8 { builder.add_maybe_i8(x); }
- builder.add_just_i8(args.just_i8);
- builder.finish()
- }
-
- pub fn unpack(&self) -> ScalarStuffT {
- let just_i8 = self.just_i8();
- let maybe_i8 = self.maybe_i8();
- let default_i8 = self.default_i8();
- let just_u8 = self.just_u8();
- let maybe_u8 = self.maybe_u8();
- let default_u8 = self.default_u8();
- let just_i16 = self.just_i16();
- let maybe_i16 = self.maybe_i16();
- let default_i16 = self.default_i16();
- let just_u16 = self.just_u16();
- let maybe_u16 = self.maybe_u16();
- let default_u16 = self.default_u16();
- let just_i32 = self.just_i32();
- let maybe_i32 = self.maybe_i32();
- let default_i32 = self.default_i32();
- let just_u32 = self.just_u32();
- let maybe_u32 = self.maybe_u32();
- let default_u32 = self.default_u32();
- let just_i64 = self.just_i64();
- let maybe_i64 = self.maybe_i64();
- let default_i64 = self.default_i64();
- let just_u64 = self.just_u64();
- let maybe_u64 = self.maybe_u64();
- let default_u64 = self.default_u64();
- let just_f32 = self.just_f32();
- let maybe_f32 = self.maybe_f32();
- let default_f32 = self.default_f32();
- let just_f64 = self.just_f64();
- let maybe_f64 = self.maybe_f64();
- let default_f64 = self.default_f64();
- let just_bool = self.just_bool();
- let maybe_bool = self.maybe_bool();
- let default_bool = self.default_bool();
- let just_enum = self.just_enum();
- let maybe_enum = self.maybe_enum();
- let default_enum = self.default_enum();
- ScalarStuffT {
- just_i8,
- maybe_i8,
- default_i8,
- just_u8,
- maybe_u8,
- default_u8,
- just_i16,
- maybe_i16,
- default_i16,
- just_u16,
- maybe_u16,
- default_u16,
- just_i32,
- maybe_i32,
- default_i32,
- just_u32,
- maybe_u32,
- default_u32,
- just_i64,
- maybe_i64,
- default_i64,
- just_u64,
- maybe_u64,
- default_u64,
- just_f32,
- maybe_f32,
- default_f32,
- just_f64,
- maybe_f64,
- default_f64,
- just_bool,
- maybe_bool,
- default_bool,
- just_enum,
- maybe_enum,
- default_enum,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "optional_scalars.ScalarStuff"
}
- }
- #[inline]
- pub fn just_i8(&self) -> i8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i8>(ScalarStuff::VT_JUST_I8, Some(0)).unwrap()}
- }
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ ScalarStuff { _tab: table }
+ }
- #[inline]
- pub fn maybe_i8(&self) -> Option<i8> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i8>(ScalarStuff::VT_MAYBE_I8, None)}
- }
+ #[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>,
+ args: &'args ScalarStuffArgs
+ ) -> ::flatbuffers::WIPOffset<ScalarStuff<'bldr>> {
+ let mut builder = ScalarStuffBuilder::new(_fbb);
+ builder.add_default_f64(args.default_f64);
+ if let Some(x) = args.maybe_f64 { builder.add_maybe_f64(x); }
+ builder.add_just_f64(args.just_f64);
+ builder.add_default_u64(args.default_u64);
+ if let Some(x) = args.maybe_u64 { builder.add_maybe_u64(x); }
+ builder.add_just_u64(args.just_u64);
+ builder.add_default_i64(args.default_i64);
+ if let Some(x) = args.maybe_i64 { builder.add_maybe_i64(x); }
+ builder.add_just_i64(args.just_i64);
+ builder.add_default_f32(args.default_f32);
+ if let Some(x) = args.maybe_f32 { builder.add_maybe_f32(x); }
+ builder.add_just_f32(args.just_f32);
+ builder.add_default_u32(args.default_u32);
+ if let Some(x) = args.maybe_u32 { builder.add_maybe_u32(x); }
+ builder.add_just_u32(args.just_u32);
+ builder.add_default_i32(args.default_i32);
+ if let Some(x) = args.maybe_i32 { builder.add_maybe_i32(x); }
+ builder.add_just_i32(args.just_i32);
+ builder.add_default_u16(args.default_u16);
+ if let Some(x) = args.maybe_u16 { builder.add_maybe_u16(x); }
+ builder.add_just_u16(args.just_u16);
+ builder.add_default_i16(args.default_i16);
+ if let Some(x) = args.maybe_i16 { builder.add_maybe_i16(x); }
+ builder.add_just_i16(args.just_i16);
+ builder.add_default_enum(args.default_enum);
+ if let Some(x) = args.maybe_enum { builder.add_maybe_enum(x); }
+ builder.add_just_enum(args.just_enum);
+ builder.add_default_bool(args.default_bool);
+ if let Some(x) = args.maybe_bool { builder.add_maybe_bool(x); }
+ builder.add_just_bool(args.just_bool);
+ builder.add_default_u8(args.default_u8);
+ if let Some(x) = args.maybe_u8 { builder.add_maybe_u8(x); }
+ builder.add_just_u8(args.just_u8);
+ builder.add_default_i8(args.default_i8);
+ if let Some(x) = args.maybe_i8 { builder.add_maybe_i8(x); }
+ builder.add_just_i8(args.just_i8);
+ builder.finish()
+ }
- #[inline]
- pub fn default_i8(&self) -> i8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i8>(ScalarStuff::VT_DEFAULT_I8, Some(42)).unwrap()}
- }
+ pub fn unpack(&self) -> ScalarStuffT {
+ let just_i8 = self.just_i8();
+ let maybe_i8 = self.maybe_i8();
+ let default_i8 = self.default_i8();
+ let just_u8 = self.just_u8();
+ let maybe_u8 = self.maybe_u8();
+ let default_u8 = self.default_u8();
+ let just_i16 = self.just_i16();
+ let maybe_i16 = self.maybe_i16();
+ let default_i16 = self.default_i16();
+ let just_u16 = self.just_u16();
+ let maybe_u16 = self.maybe_u16();
+ let default_u16 = self.default_u16();
+ let just_i32 = self.just_i32();
+ let maybe_i32 = self.maybe_i32();
+ let default_i32 = self.default_i32();
+ let just_u32 = self.just_u32();
+ let maybe_u32 = self.maybe_u32();
+ let default_u32 = self.default_u32();
+ let just_i64 = self.just_i64();
+ let maybe_i64 = self.maybe_i64();
+ let default_i64 = self.default_i64();
+ let just_u64 = self.just_u64();
+ let maybe_u64 = self.maybe_u64();
+ let default_u64 = self.default_u64();
+ let just_f32 = self.just_f32();
+ let maybe_f32 = self.maybe_f32();
+ let default_f32 = self.default_f32();
+ let just_f64 = self.just_f64();
+ let maybe_f64 = self.maybe_f64();
+ let default_f64 = self.default_f64();
+ let just_bool = self.just_bool();
+ let maybe_bool = self.maybe_bool();
+ let default_bool = self.default_bool();
+ let just_enum = self.just_enum();
+ let maybe_enum = self.maybe_enum();
+ let default_enum = self.default_enum();
+ ScalarStuffT {
+ just_i8,
+ maybe_i8,
+ default_i8,
+ just_u8,
+ maybe_u8,
+ default_u8,
+ just_i16,
+ maybe_i16,
+ default_i16,
+ just_u16,
+ maybe_u16,
+ default_u16,
+ just_i32,
+ maybe_i32,
+ default_i32,
+ just_u32,
+ maybe_u32,
+ default_u32,
+ just_i64,
+ maybe_i64,
+ default_i64,
+ just_u64,
+ maybe_u64,
+ default_u64,
+ just_f32,
+ maybe_f32,
+ default_f32,
+ just_f64,
+ maybe_f64,
+ default_f64,
+ just_bool,
+ maybe_bool,
+ default_bool,
+ just_enum,
+ maybe_enum,
+ default_enum,
+ }
+ }
- #[inline]
- pub fn just_u8(&self) -> u8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u8>(ScalarStuff::VT_JUST_U8, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_i8(&self) -> i8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i8>(ScalarStuff::VT_JUST_I8, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_u8(&self) -> Option<u8> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u8>(ScalarStuff::VT_MAYBE_U8, None)}
- }
+ #[inline]
+ pub fn maybe_i8(&self) -> Option<i8> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i8>(ScalarStuff::VT_MAYBE_I8, None)}
+ }
- #[inline]
- pub fn default_u8(&self) -> u8 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u8>(ScalarStuff::VT_DEFAULT_U8, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_i8(&self) -> i8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i8>(ScalarStuff::VT_DEFAULT_I8, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_i16(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(ScalarStuff::VT_JUST_I16, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_u8(&self) -> u8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u8>(ScalarStuff::VT_JUST_U8, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_i16(&self) -> Option<i16> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(ScalarStuff::VT_MAYBE_I16, None)}
- }
+ #[inline]
+ pub fn maybe_u8(&self) -> Option<u8> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u8>(ScalarStuff::VT_MAYBE_U8, None)}
+ }
- #[inline]
- pub fn default_i16(&self) -> i16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i16>(ScalarStuff::VT_DEFAULT_I16, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_u8(&self) -> u8 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u8>(ScalarStuff::VT_DEFAULT_U8, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_u16(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(ScalarStuff::VT_JUST_U16, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_i16(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(ScalarStuff::VT_JUST_I16, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_u16(&self) -> Option<u16> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(ScalarStuff::VT_MAYBE_U16, None)}
- }
+ #[inline]
+ pub fn maybe_i16(&self) -> Option<i16> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(ScalarStuff::VT_MAYBE_I16, None)}
+ }
- #[inline]
- pub fn default_u16(&self) -> u16 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u16>(ScalarStuff::VT_DEFAULT_U16, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_i16(&self) -> i16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i16>(ScalarStuff::VT_DEFAULT_I16, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_i32(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(ScalarStuff::VT_JUST_I32, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_u16(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(ScalarStuff::VT_JUST_U16, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_i32(&self) -> Option<i32> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(ScalarStuff::VT_MAYBE_I32, None)}
- }
+ #[inline]
+ pub fn maybe_u16(&self) -> Option<u16> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(ScalarStuff::VT_MAYBE_U16, None)}
+ }
- #[inline]
- pub fn default_i32(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(ScalarStuff::VT_DEFAULT_I32, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_u16(&self) -> u16 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u16>(ScalarStuff::VT_DEFAULT_U16, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_u32(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(ScalarStuff::VT_JUST_U32, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_i32(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(ScalarStuff::VT_JUST_I32, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_u32(&self) -> Option<u32> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(ScalarStuff::VT_MAYBE_U32, None)}
- }
+ #[inline]
+ pub fn maybe_i32(&self) -> Option<i32> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(ScalarStuff::VT_MAYBE_I32, None)}
+ }
- #[inline]
- pub fn default_u32(&self) -> u32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u32>(ScalarStuff::VT_DEFAULT_U32, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_i32(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(ScalarStuff::VT_DEFAULT_I32, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_i64(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(ScalarStuff::VT_JUST_I64, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_u32(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(ScalarStuff::VT_JUST_U32, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_i64(&self) -> Option<i64> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(ScalarStuff::VT_MAYBE_I64, None)}
- }
+ #[inline]
+ pub fn maybe_u32(&self) -> Option<u32> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(ScalarStuff::VT_MAYBE_U32, None)}
+ }
- #[inline]
- pub fn default_i64(&self) -> i64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i64>(ScalarStuff::VT_DEFAULT_I64, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_u32(&self) -> u32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u32>(ScalarStuff::VT_DEFAULT_U32, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_u64(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(ScalarStuff::VT_JUST_U64, Some(0)).unwrap()}
- }
+ #[inline]
+ pub fn just_i64(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(ScalarStuff::VT_JUST_I64, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_u64(&self) -> Option<u64> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(ScalarStuff::VT_MAYBE_U64, None)}
- }
+ #[inline]
+ pub fn maybe_i64(&self) -> Option<i64> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(ScalarStuff::VT_MAYBE_I64, None)}
+ }
- #[inline]
- pub fn default_u64(&self) -> u64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<u64>(ScalarStuff::VT_DEFAULT_U64, Some(42)).unwrap()}
- }
+ #[inline]
+ pub fn default_i64(&self) -> i64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i64>(ScalarStuff::VT_DEFAULT_I64, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_f32(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(ScalarStuff::VT_JUST_F32, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn just_u64(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(ScalarStuff::VT_JUST_U64, Some(0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_f32(&self) -> Option<f32> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(ScalarStuff::VT_MAYBE_F32, None)}
- }
+ #[inline]
+ pub fn maybe_u64(&self) -> Option<u64> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(ScalarStuff::VT_MAYBE_U64, None)}
+ }
- #[inline]
- pub fn default_f32(&self) -> f32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f32>(ScalarStuff::VT_DEFAULT_F32, Some(42.0)).unwrap()}
- }
+ #[inline]
+ pub fn default_u64(&self) -> u64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<u64>(ScalarStuff::VT_DEFAULT_U64, Some(42)).unwrap()}
+ }
- #[inline]
- pub fn just_f64(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(ScalarStuff::VT_JUST_F64, Some(0.0)).unwrap()}
- }
+ #[inline]
+ pub fn just_f32(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(ScalarStuff::VT_JUST_F32, Some(0.0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_f64(&self) -> Option<f64> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(ScalarStuff::VT_MAYBE_F64, None)}
- }
+ #[inline]
+ pub fn maybe_f32(&self) -> Option<f32> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(ScalarStuff::VT_MAYBE_F32, None)}
+ }
- #[inline]
- pub fn default_f64(&self) -> f64 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<f64>(ScalarStuff::VT_DEFAULT_F64, Some(42.0)).unwrap()}
- }
+ #[inline]
+ pub fn default_f32(&self) -> f32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f32>(ScalarStuff::VT_DEFAULT_F32, Some(42.0)).unwrap()}
+ }
- #[inline]
- pub fn just_bool(&self) -> bool {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(ScalarStuff::VT_JUST_BOOL, Some(false)).unwrap()}
- }
+ #[inline]
+ pub fn just_f64(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(ScalarStuff::VT_JUST_F64, Some(0.0)).unwrap()}
+ }
- #[inline]
- pub fn maybe_bool(&self) -> Option<bool> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(ScalarStuff::VT_MAYBE_BOOL, None)}
- }
+ #[inline]
+ pub fn maybe_f64(&self) -> Option<f64> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(ScalarStuff::VT_MAYBE_F64, None)}
+ }
- #[inline]
- pub fn default_bool(&self) -> bool {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<bool>(ScalarStuff::VT_DEFAULT_BOOL, Some(true)).unwrap()}
- }
+ #[inline]
+ pub fn default_f64(&self) -> f64 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<f64>(ScalarStuff::VT_DEFAULT_F64, Some(42.0)).unwrap()}
+ }
- #[inline]
- pub fn just_enum(&self) -> OptionalByte {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_JUST_ENUM, Some(OptionalByte::None)).unwrap()}
- }
+ #[inline]
+ pub fn just_bool(&self) -> bool {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(ScalarStuff::VT_JUST_BOOL, Some(false)).unwrap()}
+ }
- #[inline]
- pub fn maybe_enum(&self) -> Option<OptionalByte> {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_MAYBE_ENUM, None)}
- }
+ #[inline]
+ pub fn maybe_bool(&self) -> Option<bool> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(ScalarStuff::VT_MAYBE_BOOL, None)}
+ }
- #[inline]
- pub fn default_enum(&self) -> OptionalByte {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_DEFAULT_ENUM, Some(OptionalByte::One)).unwrap()}
- }
+ #[inline]
+ pub fn default_bool(&self) -> bool {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<bool>(ScalarStuff::VT_DEFAULT_BOOL, Some(true)).unwrap()}
+ }
+
+ #[inline]
+ pub fn just_enum(&self) -> OptionalByte {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_JUST_ENUM, Some(OptionalByte::None)).unwrap()}
+ }
+
+ #[inline]
+ pub fn maybe_enum(&self) -> Option<OptionalByte> {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_MAYBE_ENUM, None)}
+ }
+
+ #[inline]
+ pub fn default_enum(&self) -> OptionalByte {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<OptionalByte>(ScalarStuff::VT_DEFAULT_ENUM, Some(OptionalByte::One)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for ScalarStuff<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i8>("just_i8", Self::VT_JUST_I8, false)?
- .visit_field::<i8>("maybe_i8", Self::VT_MAYBE_I8, false)?
- .visit_field::<i8>("default_i8", Self::VT_DEFAULT_I8, false)?
- .visit_field::<u8>("just_u8", Self::VT_JUST_U8, false)?
- .visit_field::<u8>("maybe_u8", Self::VT_MAYBE_U8, false)?
- .visit_field::<u8>("default_u8", Self::VT_DEFAULT_U8, false)?
- .visit_field::<i16>("just_i16", Self::VT_JUST_I16, false)?
- .visit_field::<i16>("maybe_i16", Self::VT_MAYBE_I16, false)?
- .visit_field::<i16>("default_i16", Self::VT_DEFAULT_I16, false)?
- .visit_field::<u16>("just_u16", Self::VT_JUST_U16, false)?
- .visit_field::<u16>("maybe_u16", Self::VT_MAYBE_U16, false)?
- .visit_field::<u16>("default_u16", Self::VT_DEFAULT_U16, false)?
- .visit_field::<i32>("just_i32", Self::VT_JUST_I32, false)?
- .visit_field::<i32>("maybe_i32", Self::VT_MAYBE_I32, false)?
- .visit_field::<i32>("default_i32", Self::VT_DEFAULT_I32, false)?
- .visit_field::<u32>("just_u32", Self::VT_JUST_U32, false)?
- .visit_field::<u32>("maybe_u32", Self::VT_MAYBE_U32, false)?
- .visit_field::<u32>("default_u32", Self::VT_DEFAULT_U32, false)?
- .visit_field::<i64>("just_i64", Self::VT_JUST_I64, false)?
- .visit_field::<i64>("maybe_i64", Self::VT_MAYBE_I64, false)?
- .visit_field::<i64>("default_i64", Self::VT_DEFAULT_I64, false)?
- .visit_field::<u64>("just_u64", Self::VT_JUST_U64, false)?
- .visit_field::<u64>("maybe_u64", Self::VT_MAYBE_U64, false)?
- .visit_field::<u64>("default_u64", Self::VT_DEFAULT_U64, false)?
- .visit_field::<f32>("just_f32", Self::VT_JUST_F32, false)?
- .visit_field::<f32>("maybe_f32", Self::VT_MAYBE_F32, false)?
- .visit_field::<f32>("default_f32", Self::VT_DEFAULT_F32, false)?
- .visit_field::<f64>("just_f64", Self::VT_JUST_F64, false)?
- .visit_field::<f64>("maybe_f64", Self::VT_MAYBE_F64, false)?
- .visit_field::<f64>("default_f64", Self::VT_DEFAULT_F64, false)?
- .visit_field::<bool>("just_bool", Self::VT_JUST_BOOL, false)?
- .visit_field::<bool>("maybe_bool", Self::VT_MAYBE_BOOL, false)?
- .visit_field::<bool>("default_bool", Self::VT_DEFAULT_BOOL, false)?
- .visit_field::<OptionalByte>("just_enum", Self::VT_JUST_ENUM, false)?
- .visit_field::<OptionalByte>("maybe_enum", Self::VT_MAYBE_ENUM, false)?
- .visit_field::<OptionalByte>("default_enum", Self::VT_DEFAULT_ENUM, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i8>("just_i8", Self::VT_JUST_I8, false)?
+ .visit_field::<i8>("maybe_i8", Self::VT_MAYBE_I8, false)?
+ .visit_field::<i8>("default_i8", Self::VT_DEFAULT_I8, false)?
+ .visit_field::<u8>("just_u8", Self::VT_JUST_U8, false)?
+ .visit_field::<u8>("maybe_u8", Self::VT_MAYBE_U8, false)?
+ .visit_field::<u8>("default_u8", Self::VT_DEFAULT_U8, false)?
+ .visit_field::<i16>("just_i16", Self::VT_JUST_I16, false)?
+ .visit_field::<i16>("maybe_i16", Self::VT_MAYBE_I16, false)?
+ .visit_field::<i16>("default_i16", Self::VT_DEFAULT_I16, false)?
+ .visit_field::<u16>("just_u16", Self::VT_JUST_U16, false)?
+ .visit_field::<u16>("maybe_u16", Self::VT_MAYBE_U16, false)?
+ .visit_field::<u16>("default_u16", Self::VT_DEFAULT_U16, false)?
+ .visit_field::<i32>("just_i32", Self::VT_JUST_I32, false)?
+ .visit_field::<i32>("maybe_i32", Self::VT_MAYBE_I32, false)?
+ .visit_field::<i32>("default_i32", Self::VT_DEFAULT_I32, false)?
+ .visit_field::<u32>("just_u32", Self::VT_JUST_U32, false)?
+ .visit_field::<u32>("maybe_u32", Self::VT_MAYBE_U32, false)?
+ .visit_field::<u32>("default_u32", Self::VT_DEFAULT_U32, false)?
+ .visit_field::<i64>("just_i64", Self::VT_JUST_I64, false)?
+ .visit_field::<i64>("maybe_i64", Self::VT_MAYBE_I64, false)?
+ .visit_field::<i64>("default_i64", Self::VT_DEFAULT_I64, false)?
+ .visit_field::<u64>("just_u64", Self::VT_JUST_U64, false)?
+ .visit_field::<u64>("maybe_u64", Self::VT_MAYBE_U64, false)?
+ .visit_field::<u64>("default_u64", Self::VT_DEFAULT_U64, false)?
+ .visit_field::<f32>("just_f32", Self::VT_JUST_F32, false)?
+ .visit_field::<f32>("maybe_f32", Self::VT_MAYBE_F32, false)?
+ .visit_field::<f32>("default_f32", Self::VT_DEFAULT_F32, false)?
+ .visit_field::<f64>("just_f64", Self::VT_JUST_F64, false)?
+ .visit_field::<f64>("maybe_f64", Self::VT_MAYBE_F64, false)?
+ .visit_field::<f64>("default_f64", Self::VT_DEFAULT_F64, false)?
+ .visit_field::<bool>("just_bool", Self::VT_JUST_BOOL, false)?
+ .visit_field::<bool>("maybe_bool", Self::VT_MAYBE_BOOL, false)?
+ .visit_field::<bool>("default_bool", Self::VT_DEFAULT_BOOL, false)?
+ .visit_field::<OptionalByte>("just_enum", Self::VT_JUST_ENUM, false)?
+ .visit_field::<OptionalByte>("maybe_enum", Self::VT_MAYBE_ENUM, false)?
+ .visit_field::<OptionalByte>("default_enum", Self::VT_DEFAULT_ENUM, false)?
+ .finish();
+ Ok(())
+ }
}
pub struct ScalarStuffArgs {
@@ -564,458 +564,458 @@
}
impl<'a> Default for ScalarStuffArgs {
- #[inline]
- fn default() -> Self {
- ScalarStuffArgs {
- just_i8: 0,
- maybe_i8: None,
- default_i8: 42,
- just_u8: 0,
- maybe_u8: None,
- default_u8: 42,
- just_i16: 0,
- maybe_i16: None,
- default_i16: 42,
- just_u16: 0,
- maybe_u16: None,
- default_u16: 42,
- just_i32: 0,
- maybe_i32: None,
- default_i32: 42,
- just_u32: 0,
- maybe_u32: None,
- default_u32: 42,
- just_i64: 0,
- maybe_i64: None,
- default_i64: 42,
- just_u64: 0,
- maybe_u64: None,
- default_u64: 42,
- just_f32: 0.0,
- maybe_f32: None,
- default_f32: 42.0,
- just_f64: 0.0,
- maybe_f64: None,
- default_f64: 42.0,
- just_bool: false,
- maybe_bool: None,
- default_bool: true,
- just_enum: OptionalByte::None,
- maybe_enum: None,
- default_enum: OptionalByte::One,
+ #[inline]
+ fn default() -> Self {
+ ScalarStuffArgs {
+ just_i8: 0,
+ maybe_i8: None,
+ default_i8: 42,
+ just_u8: 0,
+ maybe_u8: None,
+ default_u8: 42,
+ just_i16: 0,
+ maybe_i16: None,
+ default_i16: 42,
+ just_u16: 0,
+ maybe_u16: None,
+ default_u16: 42,
+ just_i32: 0,
+ maybe_i32: None,
+ default_i32: 42,
+ just_u32: 0,
+ maybe_u32: None,
+ default_u32: 42,
+ just_i64: 0,
+ maybe_i64: None,
+ default_i64: 42,
+ just_u64: 0,
+ maybe_u64: None,
+ default_u64: 42,
+ just_f32: 0.0,
+ maybe_f32: None,
+ default_f32: 42.0,
+ just_f64: 0.0,
+ maybe_f64: None,
+ default_f64: 42.0,
+ just_bool: false,
+ maybe_bool: None,
+ default_bool: true,
+ just_enum: OptionalByte::None,
+ maybe_enum: None,
+ default_enum: OptionalByte::One,
+ }
}
- }
}
pub struct ScalarStuffBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i8>(ScalarStuff::VT_JUST_I8, just_i8, 0);
- }
-
- #[inline]
- pub fn add_maybe_i8(&mut self, maybe_i8: i8) {
- self.fbb_.push_slot_always::<i8>(ScalarStuff::VT_MAYBE_I8, maybe_i8);
- }
-
- #[inline]
- pub fn add_default_i8(&mut self, default_i8: i8) {
- self.fbb_.push_slot::<i8>(ScalarStuff::VT_DEFAULT_I8, default_i8, 42);
- }
-
- #[inline]
- pub fn add_just_u8(&mut self, just_u8: u8) {
- self.fbb_.push_slot::<u8>(ScalarStuff::VT_JUST_U8, just_u8, 0);
- }
-
- #[inline]
- pub fn add_maybe_u8(&mut self, maybe_u8: u8) {
- self.fbb_.push_slot_always::<u8>(ScalarStuff::VT_MAYBE_U8, maybe_u8);
- }
-
- #[inline]
- pub fn add_default_u8(&mut self, default_u8: u8) {
- self.fbb_.push_slot::<u8>(ScalarStuff::VT_DEFAULT_U8, default_u8, 42);
- }
-
- #[inline]
- pub fn add_just_i16(&mut self, just_i16: i16) {
- self.fbb_.push_slot::<i16>(ScalarStuff::VT_JUST_I16, just_i16, 0);
- }
-
- #[inline]
- pub fn add_maybe_i16(&mut self, maybe_i16: i16) {
- self.fbb_.push_slot_always::<i16>(ScalarStuff::VT_MAYBE_I16, maybe_i16);
- }
-
- #[inline]
- pub fn add_default_i16(&mut self, default_i16: i16) {
- self.fbb_.push_slot::<i16>(ScalarStuff::VT_DEFAULT_I16, default_i16, 42);
- }
-
- #[inline]
- pub fn add_just_u16(&mut self, just_u16: u16) {
- self.fbb_.push_slot::<u16>(ScalarStuff::VT_JUST_U16, just_u16, 0);
- }
-
- #[inline]
- pub fn add_maybe_u16(&mut self, maybe_u16: u16) {
- self.fbb_.push_slot_always::<u16>(ScalarStuff::VT_MAYBE_U16, maybe_u16);
- }
-
- #[inline]
- pub fn add_default_u16(&mut self, default_u16: u16) {
- self.fbb_.push_slot::<u16>(ScalarStuff::VT_DEFAULT_U16, default_u16, 42);
- }
-
- #[inline]
- pub fn add_just_i32(&mut self, just_i32: i32) {
- self.fbb_.push_slot::<i32>(ScalarStuff::VT_JUST_I32, just_i32, 0);
- }
-
- #[inline]
- pub fn add_maybe_i32(&mut self, maybe_i32: i32) {
- self.fbb_.push_slot_always::<i32>(ScalarStuff::VT_MAYBE_I32, maybe_i32);
- }
-
- #[inline]
- pub fn add_default_i32(&mut self, default_i32: i32) {
- self.fbb_.push_slot::<i32>(ScalarStuff::VT_DEFAULT_I32, default_i32, 42);
- }
-
- #[inline]
- pub fn add_just_u32(&mut self, just_u32: u32) {
- self.fbb_.push_slot::<u32>(ScalarStuff::VT_JUST_U32, just_u32, 0);
- }
-
- #[inline]
- pub fn add_maybe_u32(&mut self, maybe_u32: u32) {
- self.fbb_.push_slot_always::<u32>(ScalarStuff::VT_MAYBE_U32, maybe_u32);
- }
-
- #[inline]
- pub fn add_default_u32(&mut self, default_u32: u32) {
- self.fbb_.push_slot::<u32>(ScalarStuff::VT_DEFAULT_U32, default_u32, 42);
- }
-
- #[inline]
- pub fn add_just_i64(&mut self, just_i64: i64) {
- self.fbb_.push_slot::<i64>(ScalarStuff::VT_JUST_I64, just_i64, 0);
- }
-
- #[inline]
- pub fn add_maybe_i64(&mut self, maybe_i64: i64) {
- self.fbb_.push_slot_always::<i64>(ScalarStuff::VT_MAYBE_I64, maybe_i64);
- }
-
- #[inline]
- pub fn add_default_i64(&mut self, default_i64: i64) {
- self.fbb_.push_slot::<i64>(ScalarStuff::VT_DEFAULT_I64, default_i64, 42);
- }
-
- #[inline]
- pub fn add_just_u64(&mut self, just_u64: u64) {
- self.fbb_.push_slot::<u64>(ScalarStuff::VT_JUST_U64, just_u64, 0);
- }
-
- #[inline]
- pub fn add_maybe_u64(&mut self, maybe_u64: u64) {
- self.fbb_.push_slot_always::<u64>(ScalarStuff::VT_MAYBE_U64, maybe_u64);
- }
-
- #[inline]
- pub fn add_default_u64(&mut self, default_u64: u64) {
- self.fbb_.push_slot::<u64>(ScalarStuff::VT_DEFAULT_U64, default_u64, 42);
- }
-
- #[inline]
- pub fn add_just_f32(&mut self, just_f32: f32) {
- self.fbb_.push_slot::<f32>(ScalarStuff::VT_JUST_F32, just_f32, 0.0);
- }
-
- #[inline]
- pub fn add_maybe_f32(&mut self, maybe_f32: f32) {
- self.fbb_.push_slot_always::<f32>(ScalarStuff::VT_MAYBE_F32, maybe_f32);
- }
-
- #[inline]
- pub fn add_default_f32(&mut self, default_f32: f32) {
- self.fbb_.push_slot::<f32>(ScalarStuff::VT_DEFAULT_F32, default_f32, 42.0);
- }
-
- #[inline]
- pub fn add_just_f64(&mut self, just_f64: f64) {
- self.fbb_.push_slot::<f64>(ScalarStuff::VT_JUST_F64, just_f64, 0.0);
- }
-
- #[inline]
- pub fn add_maybe_f64(&mut self, maybe_f64: f64) {
- self.fbb_.push_slot_always::<f64>(ScalarStuff::VT_MAYBE_F64, maybe_f64);
- }
-
- #[inline]
- pub fn add_default_f64(&mut self, default_f64: f64) {
- self.fbb_.push_slot::<f64>(ScalarStuff::VT_DEFAULT_F64, default_f64, 42.0);
- }
-
- #[inline]
- pub fn add_just_bool(&mut self, just_bool: bool) {
- self.fbb_.push_slot::<bool>(ScalarStuff::VT_JUST_BOOL, just_bool, false);
- }
-
- #[inline]
- pub fn add_maybe_bool(&mut self, maybe_bool: bool) {
- self.fbb_.push_slot_always::<bool>(ScalarStuff::VT_MAYBE_BOOL, maybe_bool);
- }
-
- #[inline]
- pub fn add_default_bool(&mut self, default_bool: bool) {
- self.fbb_.push_slot::<bool>(ScalarStuff::VT_DEFAULT_BOOL, default_bool, true);
- }
-
- #[inline]
- pub fn add_just_enum(&mut self, just_enum: OptionalByte) {
- self.fbb_.push_slot::<OptionalByte>(ScalarStuff::VT_JUST_ENUM, just_enum, OptionalByte::None);
- }
-
- #[inline]
- pub fn add_maybe_enum(&mut self, maybe_enum: OptionalByte) {
- self.fbb_.push_slot_always::<OptionalByte>(ScalarStuff::VT_MAYBE_ENUM, maybe_enum);
- }
-
- #[inline]
- pub fn add_default_enum(&mut self, default_enum: OptionalByte) {
- self.fbb_.push_slot::<OptionalByte>(ScalarStuff::VT_DEFAULT_ENUM, default_enum, OptionalByte::One);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarStuffBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- ScalarStuffBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_just_i8(&mut self, just_i8: i8) {
+ self.fbb_.push_slot::<i8>(ScalarStuff::VT_JUST_I8, just_i8, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<ScalarStuff<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn add_maybe_i8(&mut self, maybe_i8: i8) {
+ self.fbb_.push_slot_always::<i8>(ScalarStuff::VT_MAYBE_I8, maybe_i8);
+ }
+
+ #[inline]
+ pub fn add_default_i8(&mut self, default_i8: i8) {
+ self.fbb_.push_slot::<i8>(ScalarStuff::VT_DEFAULT_I8, default_i8, 42);
+ }
+
+ #[inline]
+ pub fn add_just_u8(&mut self, just_u8: u8) {
+ self.fbb_.push_slot::<u8>(ScalarStuff::VT_JUST_U8, just_u8, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_u8(&mut self, maybe_u8: u8) {
+ self.fbb_.push_slot_always::<u8>(ScalarStuff::VT_MAYBE_U8, maybe_u8);
+ }
+
+ #[inline]
+ pub fn add_default_u8(&mut self, default_u8: u8) {
+ self.fbb_.push_slot::<u8>(ScalarStuff::VT_DEFAULT_U8, default_u8, 42);
+ }
+
+ #[inline]
+ pub fn add_just_i16(&mut self, just_i16: i16) {
+ self.fbb_.push_slot::<i16>(ScalarStuff::VT_JUST_I16, just_i16, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_i16(&mut self, maybe_i16: i16) {
+ self.fbb_.push_slot_always::<i16>(ScalarStuff::VT_MAYBE_I16, maybe_i16);
+ }
+
+ #[inline]
+ pub fn add_default_i16(&mut self, default_i16: i16) {
+ self.fbb_.push_slot::<i16>(ScalarStuff::VT_DEFAULT_I16, default_i16, 42);
+ }
+
+ #[inline]
+ pub fn add_just_u16(&mut self, just_u16: u16) {
+ self.fbb_.push_slot::<u16>(ScalarStuff::VT_JUST_U16, just_u16, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_u16(&mut self, maybe_u16: u16) {
+ self.fbb_.push_slot_always::<u16>(ScalarStuff::VT_MAYBE_U16, maybe_u16);
+ }
+
+ #[inline]
+ pub fn add_default_u16(&mut self, default_u16: u16) {
+ self.fbb_.push_slot::<u16>(ScalarStuff::VT_DEFAULT_U16, default_u16, 42);
+ }
+
+ #[inline]
+ pub fn add_just_i32(&mut self, just_i32: i32) {
+ self.fbb_.push_slot::<i32>(ScalarStuff::VT_JUST_I32, just_i32, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_i32(&mut self, maybe_i32: i32) {
+ self.fbb_.push_slot_always::<i32>(ScalarStuff::VT_MAYBE_I32, maybe_i32);
+ }
+
+ #[inline]
+ pub fn add_default_i32(&mut self, default_i32: i32) {
+ self.fbb_.push_slot::<i32>(ScalarStuff::VT_DEFAULT_I32, default_i32, 42);
+ }
+
+ #[inline]
+ pub fn add_just_u32(&mut self, just_u32: u32) {
+ self.fbb_.push_slot::<u32>(ScalarStuff::VT_JUST_U32, just_u32, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_u32(&mut self, maybe_u32: u32) {
+ self.fbb_.push_slot_always::<u32>(ScalarStuff::VT_MAYBE_U32, maybe_u32);
+ }
+
+ #[inline]
+ pub fn add_default_u32(&mut self, default_u32: u32) {
+ self.fbb_.push_slot::<u32>(ScalarStuff::VT_DEFAULT_U32, default_u32, 42);
+ }
+
+ #[inline]
+ pub fn add_just_i64(&mut self, just_i64: i64) {
+ self.fbb_.push_slot::<i64>(ScalarStuff::VT_JUST_I64, just_i64, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_i64(&mut self, maybe_i64: i64) {
+ self.fbb_.push_slot_always::<i64>(ScalarStuff::VT_MAYBE_I64, maybe_i64);
+ }
+
+ #[inline]
+ pub fn add_default_i64(&mut self, default_i64: i64) {
+ self.fbb_.push_slot::<i64>(ScalarStuff::VT_DEFAULT_I64, default_i64, 42);
+ }
+
+ #[inline]
+ pub fn add_just_u64(&mut self, just_u64: u64) {
+ self.fbb_.push_slot::<u64>(ScalarStuff::VT_JUST_U64, just_u64, 0);
+ }
+
+ #[inline]
+ pub fn add_maybe_u64(&mut self, maybe_u64: u64) {
+ self.fbb_.push_slot_always::<u64>(ScalarStuff::VT_MAYBE_U64, maybe_u64);
+ }
+
+ #[inline]
+ pub fn add_default_u64(&mut self, default_u64: u64) {
+ self.fbb_.push_slot::<u64>(ScalarStuff::VT_DEFAULT_U64, default_u64, 42);
+ }
+
+ #[inline]
+ pub fn add_just_f32(&mut self, just_f32: f32) {
+ self.fbb_.push_slot::<f32>(ScalarStuff::VT_JUST_F32, just_f32, 0.0);
+ }
+
+ #[inline]
+ pub fn add_maybe_f32(&mut self, maybe_f32: f32) {
+ self.fbb_.push_slot_always::<f32>(ScalarStuff::VT_MAYBE_F32, maybe_f32);
+ }
+
+ #[inline]
+ pub fn add_default_f32(&mut self, default_f32: f32) {
+ self.fbb_.push_slot::<f32>(ScalarStuff::VT_DEFAULT_F32, default_f32, 42.0);
+ }
+
+ #[inline]
+ pub fn add_just_f64(&mut self, just_f64: f64) {
+ self.fbb_.push_slot::<f64>(ScalarStuff::VT_JUST_F64, just_f64, 0.0);
+ }
+
+ #[inline]
+ pub fn add_maybe_f64(&mut self, maybe_f64: f64) {
+ self.fbb_.push_slot_always::<f64>(ScalarStuff::VT_MAYBE_F64, maybe_f64);
+ }
+
+ #[inline]
+ pub fn add_default_f64(&mut self, default_f64: f64) {
+ self.fbb_.push_slot::<f64>(ScalarStuff::VT_DEFAULT_F64, default_f64, 42.0);
+ }
+
+ #[inline]
+ pub fn add_just_bool(&mut self, just_bool: bool) {
+ self.fbb_.push_slot::<bool>(ScalarStuff::VT_JUST_BOOL, just_bool, false);
+ }
+
+ #[inline]
+ pub fn add_maybe_bool(&mut self, maybe_bool: bool) {
+ self.fbb_.push_slot_always::<bool>(ScalarStuff::VT_MAYBE_BOOL, maybe_bool);
+ }
+
+ #[inline]
+ pub fn add_default_bool(&mut self, default_bool: bool) {
+ self.fbb_.push_slot::<bool>(ScalarStuff::VT_DEFAULT_BOOL, default_bool, true);
+ }
+
+ #[inline]
+ pub fn add_just_enum(&mut self, just_enum: OptionalByte) {
+ self.fbb_.push_slot::<OptionalByte>(ScalarStuff::VT_JUST_ENUM, just_enum, OptionalByte::None);
+ }
+
+ #[inline]
+ pub fn add_maybe_enum(&mut self, maybe_enum: OptionalByte) {
+ self.fbb_.push_slot_always::<OptionalByte>(ScalarStuff::VT_MAYBE_ENUM, maybe_enum);
+ }
+
+ #[inline]
+ pub fn add_default_enum(&mut self, default_enum: OptionalByte) {
+ self.fbb_.push_slot::<OptionalByte>(ScalarStuff::VT_DEFAULT_ENUM, default_enum, OptionalByte::One);
+ }
+
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> ScalarStuffBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ ScalarStuffBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<ScalarStuff<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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());
- ds.field("default_i8", &self.default_i8());
- ds.field("just_u8", &self.just_u8());
- ds.field("maybe_u8", &self.maybe_u8());
- ds.field("default_u8", &self.default_u8());
- ds.field("just_i16", &self.just_i16());
- ds.field("maybe_i16", &self.maybe_i16());
- ds.field("default_i16", &self.default_i16());
- ds.field("just_u16", &self.just_u16());
- ds.field("maybe_u16", &self.maybe_u16());
- ds.field("default_u16", &self.default_u16());
- ds.field("just_i32", &self.just_i32());
- ds.field("maybe_i32", &self.maybe_i32());
- ds.field("default_i32", &self.default_i32());
- ds.field("just_u32", &self.just_u32());
- ds.field("maybe_u32", &self.maybe_u32());
- ds.field("default_u32", &self.default_u32());
- ds.field("just_i64", &self.just_i64());
- ds.field("maybe_i64", &self.maybe_i64());
- ds.field("default_i64", &self.default_i64());
- ds.field("just_u64", &self.just_u64());
- ds.field("maybe_u64", &self.maybe_u64());
- ds.field("default_u64", &self.default_u64());
- ds.field("just_f32", &self.just_f32());
- ds.field("maybe_f32", &self.maybe_f32());
- ds.field("default_f32", &self.default_f32());
- ds.field("just_f64", &self.just_f64());
- ds.field("maybe_f64", &self.maybe_f64());
- ds.field("default_f64", &self.default_f64());
- ds.field("just_bool", &self.just_bool());
- ds.field("maybe_bool", &self.maybe_bool());
- ds.field("default_bool", &self.default_bool());
- ds.field("just_enum", &self.just_enum());
- ds.field("maybe_enum", &self.maybe_enum());
- ds.field("default_enum", &self.default_enum());
- ds.finish()
- }
+ 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());
+ ds.field("default_i8", &self.default_i8());
+ ds.field("just_u8", &self.just_u8());
+ ds.field("maybe_u8", &self.maybe_u8());
+ ds.field("default_u8", &self.default_u8());
+ ds.field("just_i16", &self.just_i16());
+ ds.field("maybe_i16", &self.maybe_i16());
+ ds.field("default_i16", &self.default_i16());
+ ds.field("just_u16", &self.just_u16());
+ ds.field("maybe_u16", &self.maybe_u16());
+ ds.field("default_u16", &self.default_u16());
+ ds.field("just_i32", &self.just_i32());
+ ds.field("maybe_i32", &self.maybe_i32());
+ ds.field("default_i32", &self.default_i32());
+ ds.field("just_u32", &self.just_u32());
+ ds.field("maybe_u32", &self.maybe_u32());
+ ds.field("default_u32", &self.default_u32());
+ ds.field("just_i64", &self.just_i64());
+ ds.field("maybe_i64", &self.maybe_i64());
+ ds.field("default_i64", &self.default_i64());
+ ds.field("just_u64", &self.just_u64());
+ ds.field("maybe_u64", &self.maybe_u64());
+ ds.field("default_u64", &self.default_u64());
+ ds.field("just_f32", &self.just_f32());
+ ds.field("maybe_f32", &self.maybe_f32());
+ ds.field("default_f32", &self.default_f32());
+ ds.field("just_f64", &self.just_f64());
+ ds.field("maybe_f64", &self.maybe_f64());
+ ds.field("default_f64", &self.default_f64());
+ ds.field("just_bool", &self.just_bool());
+ ds.field("maybe_bool", &self.maybe_bool());
+ ds.field("default_bool", &self.default_bool());
+ ds.field("just_enum", &self.just_enum());
+ ds.field("maybe_enum", &self.maybe_enum());
+ ds.field("default_enum", &self.default_enum());
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ScalarStuffT {
- pub just_i8: i8,
- pub maybe_i8: Option<i8>,
- pub default_i8: i8,
- pub just_u8: u8,
- pub maybe_u8: Option<u8>,
- pub default_u8: u8,
- pub just_i16: i16,
- pub maybe_i16: Option<i16>,
- pub default_i16: i16,
- pub just_u16: u16,
- pub maybe_u16: Option<u16>,
- pub default_u16: u16,
- pub just_i32: i32,
- pub maybe_i32: Option<i32>,
- pub default_i32: i32,
- pub just_u32: u32,
- pub maybe_u32: Option<u32>,
- pub default_u32: u32,
- pub just_i64: i64,
- pub maybe_i64: Option<i64>,
- pub default_i64: i64,
- pub just_u64: u64,
- pub maybe_u64: Option<u64>,
- pub default_u64: u64,
- pub just_f32: f32,
- pub maybe_f32: Option<f32>,
- pub default_f32: f32,
- pub just_f64: f64,
- pub maybe_f64: Option<f64>,
- pub default_f64: f64,
- pub just_bool: bool,
- pub maybe_bool: Option<bool>,
- pub default_bool: bool,
- pub just_enum: OptionalByte,
- pub maybe_enum: Option<OptionalByte>,
- pub default_enum: OptionalByte,
+ pub just_i8: i8,
+ pub maybe_i8: Option<i8>,
+ pub default_i8: i8,
+ pub just_u8: u8,
+ pub maybe_u8: Option<u8>,
+ pub default_u8: u8,
+ pub just_i16: i16,
+ pub maybe_i16: Option<i16>,
+ pub default_i16: i16,
+ pub just_u16: u16,
+ pub maybe_u16: Option<u16>,
+ pub default_u16: u16,
+ pub just_i32: i32,
+ pub maybe_i32: Option<i32>,
+ pub default_i32: i32,
+ pub just_u32: u32,
+ pub maybe_u32: Option<u32>,
+ pub default_u32: u32,
+ pub just_i64: i64,
+ pub maybe_i64: Option<i64>,
+ pub default_i64: i64,
+ pub just_u64: u64,
+ pub maybe_u64: Option<u64>,
+ pub default_u64: u64,
+ pub just_f32: f32,
+ pub maybe_f32: Option<f32>,
+ pub default_f32: f32,
+ pub just_f64: f64,
+ pub maybe_f64: Option<f64>,
+ pub default_f64: f64,
+ pub just_bool: bool,
+ pub maybe_bool: Option<bool>,
+ pub default_bool: bool,
+ pub just_enum: OptionalByte,
+ pub maybe_enum: Option<OptionalByte>,
+ pub default_enum: OptionalByte,
}
impl Default for ScalarStuffT {
- fn default() -> Self {
- Self {
- just_i8: 0,
- maybe_i8: None,
- default_i8: 42,
- just_u8: 0,
- maybe_u8: None,
- default_u8: 42,
- just_i16: 0,
- maybe_i16: None,
- default_i16: 42,
- just_u16: 0,
- maybe_u16: None,
- default_u16: 42,
- just_i32: 0,
- maybe_i32: None,
- default_i32: 42,
- just_u32: 0,
- maybe_u32: None,
- default_u32: 42,
- just_i64: 0,
- maybe_i64: None,
- default_i64: 42,
- just_u64: 0,
- maybe_u64: None,
- default_u64: 42,
- just_f32: 0.0,
- maybe_f32: None,
- default_f32: 42.0,
- just_f64: 0.0,
- maybe_f64: None,
- default_f64: 42.0,
- just_bool: false,
- maybe_bool: None,
- default_bool: true,
- just_enum: OptionalByte::None,
- maybe_enum: None,
- default_enum: OptionalByte::One,
+ fn default() -> Self {
+ Self {
+ just_i8: 0,
+ maybe_i8: None,
+ default_i8: 42,
+ just_u8: 0,
+ maybe_u8: None,
+ default_u8: 42,
+ just_i16: 0,
+ maybe_i16: None,
+ default_i16: 42,
+ just_u16: 0,
+ maybe_u16: None,
+ default_u16: 42,
+ just_i32: 0,
+ maybe_i32: None,
+ default_i32: 42,
+ just_u32: 0,
+ maybe_u32: None,
+ default_u32: 42,
+ just_i64: 0,
+ maybe_i64: None,
+ default_i64: 42,
+ just_u64: 0,
+ maybe_u64: None,
+ default_u64: 42,
+ just_f32: 0.0,
+ maybe_f32: None,
+ default_f32: 42.0,
+ just_f64: 0.0,
+ maybe_f64: None,
+ default_f64: 42.0,
+ just_bool: false,
+ maybe_bool: None,
+ default_bool: true,
+ just_enum: OptionalByte::None,
+ maybe_enum: None,
+ default_enum: OptionalByte::One,
+ }
}
- }
}
impl ScalarStuffT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<ScalarStuff<'b>> {
- let just_i8 = self.just_i8;
- let maybe_i8 = self.maybe_i8;
- let default_i8 = self.default_i8;
- let just_u8 = self.just_u8;
- let maybe_u8 = self.maybe_u8;
- let default_u8 = self.default_u8;
- let just_i16 = self.just_i16;
- let maybe_i16 = self.maybe_i16;
- let default_i16 = self.default_i16;
- let just_u16 = self.just_u16;
- let maybe_u16 = self.maybe_u16;
- let default_u16 = self.default_u16;
- let just_i32 = self.just_i32;
- let maybe_i32 = self.maybe_i32;
- let default_i32 = self.default_i32;
- let just_u32 = self.just_u32;
- let maybe_u32 = self.maybe_u32;
- let default_u32 = self.default_u32;
- let just_i64 = self.just_i64;
- let maybe_i64 = self.maybe_i64;
- let default_i64 = self.default_i64;
- let just_u64 = self.just_u64;
- let maybe_u64 = self.maybe_u64;
- let default_u64 = self.default_u64;
- let just_f32 = self.just_f32;
- let maybe_f32 = self.maybe_f32;
- let default_f32 = self.default_f32;
- let just_f64 = self.just_f64;
- let maybe_f64 = self.maybe_f64;
- let default_f64 = self.default_f64;
- let just_bool = self.just_bool;
- let maybe_bool = self.maybe_bool;
- let default_bool = self.default_bool;
- let just_enum = self.just_enum;
- let maybe_enum = self.maybe_enum;
- let default_enum = self.default_enum;
- ScalarStuff::create(_fbb, &ScalarStuffArgs{
- just_i8,
- maybe_i8,
- default_i8,
- just_u8,
- maybe_u8,
- default_u8,
- just_i16,
- maybe_i16,
- default_i16,
- just_u16,
- maybe_u16,
- default_u16,
- just_i32,
- maybe_i32,
- default_i32,
- just_u32,
- maybe_u32,
- default_u32,
- just_i64,
- maybe_i64,
- default_i64,
- just_u64,
- maybe_u64,
- default_u64,
- just_f32,
- maybe_f32,
- default_f32,
- just_f64,
- maybe_f64,
- default_f64,
- just_bool,
- maybe_bool,
- default_bool,
- just_enum,
- maybe_enum,
- default_enum,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<ScalarStuff<'b>> {
+ let just_i8 = self.just_i8;
+ let maybe_i8 = self.maybe_i8;
+ let default_i8 = self.default_i8;
+ let just_u8 = self.just_u8;
+ let maybe_u8 = self.maybe_u8;
+ let default_u8 = self.default_u8;
+ let just_i16 = self.just_i16;
+ let maybe_i16 = self.maybe_i16;
+ let default_i16 = self.default_i16;
+ let just_u16 = self.just_u16;
+ let maybe_u16 = self.maybe_u16;
+ let default_u16 = self.default_u16;
+ let just_i32 = self.just_i32;
+ let maybe_i32 = self.maybe_i32;
+ let default_i32 = self.default_i32;
+ let just_u32 = self.just_u32;
+ let maybe_u32 = self.maybe_u32;
+ let default_u32 = self.default_u32;
+ let just_i64 = self.just_i64;
+ let maybe_i64 = self.maybe_i64;
+ let default_i64 = self.default_i64;
+ let just_u64 = self.just_u64;
+ let maybe_u64 = self.maybe_u64;
+ let default_u64 = self.default_u64;
+ let just_f32 = self.just_f32;
+ let maybe_f32 = self.maybe_f32;
+ let default_f32 = self.default_f32;
+ let just_f64 = self.just_f64;
+ let maybe_f64 = self.maybe_f64;
+ let default_f64 = self.default_f64;
+ let just_bool = self.just_bool;
+ let maybe_bool = self.maybe_bool;
+ let default_bool = self.default_bool;
+ let just_enum = self.just_enum;
+ let maybe_enum = self.maybe_enum;
+ let default_enum = self.default_enum;
+ ScalarStuff::create(_fbb, &ScalarStuffArgs{
+ just_i8,
+ maybe_i8,
+ default_i8,
+ just_u8,
+ maybe_u8,
+ default_u8,
+ just_i16,
+ maybe_i16,
+ default_i16,
+ just_u16,
+ maybe_u16,
+ default_u16,
+ just_i32,
+ maybe_i32,
+ default_i32,
+ just_u32,
+ maybe_u32,
+ default_u32,
+ just_i64,
+ maybe_i64,
+ default_i64,
+ just_u64,
+ maybe_u64,
+ default_u64,
+ just_f32,
+ maybe_f32,
+ default_f32,
+ just_f64,
+ maybe_f64,
+ default_f64,
+ just_bool,
+ maybe_bool,
+ default_bool,
+ just_enum,
+ maybe_enum,
+ default_enum,
+ })
+ }
}
/// Verifies that a buffer of bytes contains a `ScalarStuff`
@@ -1026,7 +1026,7 @@
/// `root_as_scalar_stuff_unchecked`.
#[inline]
pub fn root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<ScalarStuff>(buf)
+ ::flatbuffers::root::<ScalarStuff>(buf)
}
/// Verifies that a buffer of bytes contains a size prefixed
@@ -1037,7 +1037,7 @@
/// `size_prefixed_root_as_scalar_stuff_unchecked`.
#[inline]
pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<ScalarStuff>(buf)
+ ::flatbuffers::size_prefixed_root::<ScalarStuff>(buf)
}
/// Verifies, with the given options, that a buffer of bytes
@@ -1048,10 +1048,10 @@
/// `root_as_scalar_stuff_unchecked`.
#[inline]
pub fn root_as_scalar_stuff_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<ScalarStuff<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root_with_opts::<ScalarStuff<'b>>(opts, buf)
+ ::flatbuffers::root_with_opts::<ScalarStuff<'b>>(opts, buf)
}
/// Verifies, with the given verifier options, that a buffer of
@@ -1062,10 +1062,10 @@
/// `root_as_scalar_stuff_unchecked`.
#[inline]
pub fn size_prefixed_root_as_scalar_stuff_with_opts<'b, 'o>(
- opts: &'o ::flatbuffers::VerifierOptions,
- buf: &'b [u8],
+ opts: &'o ::flatbuffers::VerifierOptions,
+ buf: &'b [u8],
) -> Result<ScalarStuff<'b>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root_with_opts::<ScalarStuff<'b>>(opts, buf)
+ ::flatbuffers::size_prefixed_root_with_opts::<ScalarStuff<'b>>(opts, buf)
}
/// Assumes, without verification, that a buffer of bytes contains a ScalarStuff and returns it.
@@ -1073,7 +1073,7 @@
/// Callers must trust the given bytes do indeed contain a valid `ScalarStuff`.
#[inline]
pub unsafe fn root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
- unsafe { ::flatbuffers::root_unchecked::<ScalarStuff>(buf) }
+ unsafe { ::flatbuffers::root_unchecked::<ScalarStuff>(buf) }
}
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ScalarStuff and returns it.
@@ -1081,19 +1081,19 @@
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ScalarStuff`.
#[inline]
pub unsafe fn size_prefixed_root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
- unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ScalarStuff>(buf) }
+ unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ScalarStuff>(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";
@@ -1101,11 +1101,15 @@
#[inline]
pub fn finish_scalar_stuff_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- root: ::flatbuffers::WIPOffset<ScalarStuff<'a>>) {
- fbb.finish(root, Some(SCALAR_STUFF_IDENTIFIER));
+ root: ::flatbuffers::WIPOffset<ScalarStuff<'a>>
+) {
+ 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<ScalarStuff<'a>>) {
- fbb.finish_size_prefixed(root, Some(SCALAR_STUFF_IDENTIFIER));
+pub fn finish_size_prefixed_scalar_stuff_buffer<'a, 'b, A: ::flatbuffers::Allocator + 'a>(
+ fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ root: ::flatbuffers::WIPOffset<ScalarStuff<'a>>
+) {
+ 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 91310b1..099893f 100644
--- a/tests/private_annotation_test/ab_generated.rs
+++ b/tests/private_annotation_test/ab_generated.rs
@@ -12,8 +12,8 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_AB: [AB; 2] = [
- AB::A,
- AB::B,
+ AB::A,
+ AB::B,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -22,44 +22,44 @@
#[allow(non_upper_case_globals)]
impl AB {
- pub const A: Self = Self(0);
- pub const B: Self = Self(1);
+ pub const A: Self = Self(0);
+ pub const B: Self = Self(1);
- pub const ENUM_MIN: i8 = 0;
- pub const ENUM_MAX: i8 = 1;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::A,
- Self::B,
- ];
+ pub const ENUM_MIN: i8 = 0;
+ pub const ENUM_MAX: i8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::A,
+ Self::B,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::A => Some("A"),
- Self::B => Some("B"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::A => Some("A"),
+ Self::B => Some("B"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for AB {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for AB {
@@ -72,28 +72,28 @@
}
impl ::flatbuffers::EndianScalar for AB {
- type Scalar = i8;
+ type Scalar = i8;
- #[inline]
- fn to_little_endian(self) -> i8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> i8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: i8) -> Self {
- let b = i8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: i8) -> Self {
+ let b = i8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for AB {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- i8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ i8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for AB {}
diff --git a/tests/private_annotation_test/annotations_generated.rs b/tests/private_annotation_test/annotations_generated.rs
index ab20393..3c6a7a7 100644
--- a/tests/private_annotation_test/annotations_generated.rs
+++ b/tests/private_annotation_test/annotations_generated.rs
@@ -7,66 +7,66 @@
#[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> {
- type Inner = Annotations<'a>;
+ type Inner = Annotations<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args AnnotationsArgs
- ) -> ::flatbuffers::WIPOffset<Annotations<'bldr>> {
- let mut builder = AnnotationsBuilder::new(_fbb);
- builder.add_value(args.value);
- builder.finish()
- }
-
- pub fn unpack(&self) -> AnnotationsT {
- let value = self.value();
- AnnotationsT {
- value,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Annotations"
}
- }
- #[inline]
- pub fn value(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Annotations::VT_VALUE, Some(0)).unwrap()}
- }
+ #[inline]
+ 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>,
+ args: &'args AnnotationsArgs
+ ) -> ::flatbuffers::WIPOffset<Annotations<'bldr>> {
+ let mut builder = AnnotationsBuilder::new(_fbb);
+ builder.add_value(args.value);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> AnnotationsT {
+ let value = self.value();
+ AnnotationsT {
+ value,
+ }
+ }
+
+ #[inline]
+ pub fn value(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Annotations::VT_VALUE, Some(0)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for Annotations<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i32>("value", Self::VT_VALUE, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i32>("value", Self::VT_VALUE, false)?
+ .finish();
+ Ok(())
+ }
}
pub(crate) struct AnnotationsArgs {
@@ -74,71 +74,71 @@
}
impl<'a> Default for AnnotationsArgs {
- #[inline]
- fn default() -> Self {
- AnnotationsArgs {
- value: 0,
+ #[inline]
+ fn default() -> Self {
+ AnnotationsArgs {
+ value: 0,
+ }
}
- }
}
pub(crate) struct AnnotationsBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i32>(Annotations::VT_VALUE, value, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> AnnotationsBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- AnnotationsBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_value(&mut self, value: i32) {
+ self.fbb_.push_slot::<i32>(Annotations::VT_VALUE, value, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Annotations<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> AnnotationsBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ AnnotationsBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Annotations<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct AnnotationsT {
- pub value: i32,
+ pub value: i32,
}
impl Default for AnnotationsT {
- fn default() -> Self {
- Self {
- value: 0,
+ fn default() -> Self {
+ Self {
+ value: 0,
+ }
}
- }
}
impl AnnotationsT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Annotations<'b>> {
- let value = self.value;
- Annotations::create(_fbb, &AnnotationsArgs{
- value,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Annotations<'b>> {
+ 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 be353bf..33f6764 100644
--- a/tests/private_annotation_test/any_generated.rs
+++ b/tests/private_annotation_test/any_generated.rs
@@ -12,9 +12,9 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_ANY: [Any; 3] = [
- Any::NONE,
- Any::Game,
- Any::Annotations,
+ Any::NONE,
+ Any::Game,
+ Any::Annotations,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -23,47 +23,47 @@
#[allow(non_upper_case_globals)]
impl Any {
- pub const NONE: Self = Self(0);
- pub const Game: Self = Self(1);
- pub const Annotations: Self = Self(2);
+ pub const NONE: Self = Self(0);
+ pub const Game: Self = Self(1);
+ pub const Annotations: Self = Self(2);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 2;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::Game,
- Self::Annotations,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Game,
+ Self::Annotations,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::Game => Some("Game"),
- Self::Annotations => Some("Annotations"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Game => Some("Game"),
+ Self::Annotations => Some("Annotations"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for Any {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for Any {
@@ -76,28 +76,28 @@
}
impl ::flatbuffers::EndianScalar for Any {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for Any {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
@@ -108,80 +108,80 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub(crate) enum AnyT {
- NONE,
- Game(alloc::boxed::Box<GameT>),
- Annotations(alloc::boxed::Box<AnnotationsT>),
+ NONE,
+ Game(alloc::boxed::Box<GameT>),
+ Annotations(alloc::boxed::Box<AnnotationsT>),
}
impl Default for AnyT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl AnyT {
- pub fn any_type(&self) -> Any {
- match self {
- Self::NONE => Any::NONE,
- Self::Game(_) => Any::Game,
- Self::Annotations(_) => Any::Annotations,
+ pub fn any_type(&self) -> Any {
+ match self {
+ Self::NONE => Any::NONE,
+ Self::Game(_) => Any::Game,
+ Self::Annotations(_) => Any::Annotations,
+ }
}
- }
- 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()),
- Self::Annotations(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::Annotations(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned GameT, setting the union to NONE.
- pub fn take_game(&mut self) -> Option<alloc::boxed::Box<GameT>> {
- if let Self::Game(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Game(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned GameT, setting the union to NONE.
+ pub fn take_game(&mut self) -> Option<alloc::boxed::Box<GameT>> {
+ if let Self::Game(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Game(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the GameT.
- pub fn as_game(&self) -> Option<&GameT> {
- if let Self::Game(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the GameT.
- pub fn as_game_mut(&mut self) -> Option<&mut GameT> {
- 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<alloc::boxed::Box<AnnotationsT>> {
- if let Self::Annotations(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::Annotations(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the GameT.
+ pub fn as_game(&self) -> Option<&GameT> {
+ if let Self::Game(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the AnnotationsT.
- pub fn as_annotations(&self) -> Option<&AnnotationsT> {
- if let Self::Annotations(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return a mutable reference to the GameT.
+ pub fn as_game_mut(&mut self) -> Option<&mut GameT> {
+ if let Self::Game(v) = self { Some(v.as_mut()) } else { None }
+ }
- /// If the union variant matches, return a mutable reference to the AnnotationsT.
- pub fn as_annotations_mut(&mut self) -> Option<&mut AnnotationsT> {
- if let Self::Annotations(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<alloc::boxed::Box<AnnotationsT>> {
+ if let Self::Annotations(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::Annotations(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the AnnotationsT.
+ pub fn as_annotations(&self) -> Option<&AnnotationsT> {
+ if let Self::Annotations(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the AnnotationsT.
+ pub fn as_annotations_mut(&mut self) -> Option<&mut AnnotationsT> {
+ if let Self::Annotations(v) = self { Some(v.as_mut()) } else { None }
+ }
}
diff --git a/tests/private_annotation_test/game_generated.rs b/tests/private_annotation_test/game_generated.rs
index 7fa953b..c15574d 100644
--- a/tests/private_annotation_test/game_generated.rs
+++ b/tests/private_annotation_test/game_generated.rs
@@ -7,66 +7,66 @@
#[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> {
- type Inner = Game<'a>;
+ type Inner = Game<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args GameArgs
- ) -> ::flatbuffers::WIPOffset<Game<'bldr>> {
- let mut builder = GameBuilder::new(_fbb);
- builder.add_value(args.value);
- builder.finish()
- }
-
- pub fn unpack(&self) -> GameT {
- let value = self.value();
- GameT {
- value,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Game"
}
- }
- #[inline]
- pub fn value(&self) -> i32 {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<i32>(Game::VT_VALUE, Some(0)).unwrap()}
- }
+ #[inline]
+ 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>,
+ args: &'args GameArgs
+ ) -> ::flatbuffers::WIPOffset<Game<'bldr>> {
+ let mut builder = GameBuilder::new(_fbb);
+ builder.add_value(args.value);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> GameT {
+ let value = self.value();
+ GameT {
+ value,
+ }
+ }
+
+ #[inline]
+ pub fn value(&self) -> i32 {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<i32>(Game::VT_VALUE, Some(0)).unwrap()}
+ }
}
impl ::flatbuffers::Verifiable for Game<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_field::<i32>("value", Self::VT_VALUE, false)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_field::<i32>("value", Self::VT_VALUE, false)?
+ .finish();
+ Ok(())
+ }
}
pub(crate) struct GameArgs {
@@ -74,71 +74,71 @@
}
impl<'a> Default for GameArgs {
- #[inline]
- fn default() -> Self {
- GameArgs {
- value: 0,
+ #[inline]
+ fn default() -> Self {
+ GameArgs {
+ value: 0,
+ }
}
- }
}
pub(crate) struct GameBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<i32>(Game::VT_VALUE, value, 0);
- }
-
- #[inline]
- pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GameBuilder<'a, 'b, A> {
- let start = _fbb.start_table();
- GameBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_value(&mut self, value: i32) {
+ self.fbb_.push_slot::<i32>(Game::VT_VALUE, value, 0);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Game<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> GameBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ GameBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<Game<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ 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()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct GameT {
- pub value: i32,
+ pub value: i32,
}
impl Default for GameT {
- fn default() -> Self {
- Self {
- value: 0,
+ fn default() -> Self {
+ Self {
+ value: 0,
+ }
}
- }
}
impl GameT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<Game<'b>> {
- let value = self.value;
- Game::create(_fbb, &GameArgs{
- value,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<Game<'b>> {
+ 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 3d5106d..07d44cf 100644
--- a/tests/private_annotation_test/object_generated.rs
+++ b/tests/private_annotation_test/object_generated.rs
@@ -8,38 +8,38 @@
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Object(pub [u8; 4]);
-impl Default for Object {
- fn default() -> Self {
- Self([0; 4])
- }
+impl Default for Object {
+ fn default() -> Self {
+ Self([0; 4])
+ }
}
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()
- }
+ 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 {
- type Inner = &'a Object;
+ type Inner = &'a Object;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a Object>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a Object>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a Object {
- type Inner = &'a Object;
+ type Inner = &'a Object;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<Object>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<Object>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for Object {
@@ -58,73 +58,73 @@
}
impl<'a> ::flatbuffers::Verifiable for Object {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> Object {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- value: i32,
- ) -> Self {
- let mut s = Self([0; 4]);
- s.set_value(value);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "Object"
- }
-
- pub fn value(&self) -> i32 {
- let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_value(&mut self, x: i32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ value: i32,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_value(value);
+ s
}
- }
- pub fn unpack(&self) -> ObjectT {
- ObjectT {
- value: self.value(),
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "Object"
}
- }
+
+ pub fn value(&self) -> i32 {
+ let mut mem = ::core::mem::MaybeUninit::<<i32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_value(&mut self, x: i32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<i32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> ObjectT {
+ ObjectT {
+ value: self.value(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub(crate) struct ObjectT {
- pub value: i32,
+ pub value: i32,
}
impl ObjectT {
- pub fn pack(&self) -> Object {
- Object::new(
- self.value,
- )
- }
+ pub fn pack(&self) -> Object {
+ Object::new(
+ self.value,
+ )
+ }
}
diff --git a/tests/rust_namer_test/mod.rs b/tests/rust_namer_test/mod.rs
index f395a50..81c7616 100644
--- a/tests/rust_namer_test/mod.rs
+++ b/tests/rust_namer_test/mod.rs
@@ -1,23 +1,23 @@
// Automatically generated by the Flatbuffers compiler. Do not modify.
// @generated
pub mod rust_namer_test {
- use super::*;
- mod field_union_generated;
- pub use self::field_union_generated::*;
- mod game_message_generated;
- pub use self::game_message_generated::*;
- mod field_table_generated;
- pub use self::field_table_generated::*;
- mod root_table_generated;
- pub use self::root_table_generated::*;
- mod player_stat_event_generated;
- pub use self::player_stat_event_generated::*;
- mod player_spectate_generated;
- pub use self::player_spectate_generated::*;
- mod player_input_change_generated;
- pub use self::player_input_change_generated::*;
- mod game_message_wrapper_generated;
- pub use self::game_message_wrapper_generated::*;
- mod possibly_reserved_words_generated;
- pub use self::possibly_reserved_words_generated::*;
+ use super::*;
+ mod field_union_generated;
+ pub use self::field_union_generated::*;
+ mod game_message_generated;
+ pub use self::game_message_generated::*;
+ mod field_table_generated;
+ pub use self::field_table_generated::*;
+ mod root_table_generated;
+ pub use self::root_table_generated::*;
+ mod player_stat_event_generated;
+ pub use self::player_stat_event_generated::*;
+ mod player_spectate_generated;
+ pub use self::player_spectate_generated::*;
+ mod player_input_change_generated;
+ pub use self::player_input_change_generated::*;
+ mod game_message_wrapper_generated;
+ pub use self::game_message_wrapper_generated::*;
+ mod possibly_reserved_words_generated;
+ pub use self::possibly_reserved_words_generated::*;
} // rust_namer_test
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 88e0da1..5b21b2e 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
@@ -7,92 +7,92 @@
#[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> {
- type Inner = FieldTable<'a>;
+ type Inner = FieldTable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> FieldTable<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "RustNamerTest.FieldTable"
- }
-
- #[inline]
- 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>,
- _args: &'args FieldTableArgs
- ) -> ::flatbuffers::WIPOffset<FieldTable<'bldr>> {
- let mut builder = FieldTableBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> FieldTableT {
- FieldTableT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.FieldTable"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args FieldTableArgs
+ ) -> ::flatbuffers::WIPOffset<FieldTable<'bldr>> {
+ let mut builder = FieldTableBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> FieldTableT {
+ FieldTableT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for FieldTable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct FieldTableArgs {
}
impl<'a> Default for FieldTableArgs {
- #[inline]
- fn default() -> Self {
- FieldTableArgs {
+ #[inline]
+ fn default() -> Self {
+ FieldTableArgs {
+ }
}
- }
}
pub struct FieldTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- FieldTableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> FieldTableBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ FieldTableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<FieldTable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<FieldTable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("FieldTable");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for FieldTableT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl FieldTableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<FieldTable<'b>> {
- FieldTable::create(_fbb, &FieldTableArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<FieldTable<'b>> {
+ 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 7bedafe..22fa546 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
@@ -12,8 +12,8 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FIELD_UNION: [FieldUnion; 2] = [
- FieldUnion::NONE,
- FieldUnion::f,
+ FieldUnion::NONE,
+ FieldUnion::f,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -22,44 +22,44 @@
#[allow(non_upper_case_globals)]
impl FieldUnion {
- pub const NONE: Self = Self(0);
- pub const f: Self = Self(1);
+ pub const NONE: Self = Self(0);
+ pub const f: Self = Self(1);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 1;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::f,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 1;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::f,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::f => Some("f"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::f => Some("f"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for FieldUnion {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for FieldUnion {
@@ -72,28 +72,28 @@
}
impl ::flatbuffers::EndianScalar for FieldUnion {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for FieldUnion {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for FieldUnion {}
@@ -104,53 +104,53 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum FieldUnionT {
- NONE,
- F(alloc::boxed::Box<FieldTableT>),
+ NONE,
+ F(alloc::boxed::Box<FieldTableT>),
}
impl Default for FieldUnionT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl FieldUnionT {
- pub fn field_union_type(&self) -> FieldUnion {
- match self {
- Self::NONE => FieldUnion::NONE,
- Self::F(_) => FieldUnion::f,
+ pub fn field_union_type(&self) -> FieldUnion {
+ match self {
+ Self::NONE => FieldUnion::NONE,
+ Self::F(_) => FieldUnion::f,
+ }
}
- }
- 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()),
+ 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<alloc::boxed::Box<FieldTableT>> {
- if let Self::F(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::F(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned FieldTableT, setting the union to NONE.
+ pub fn take_f(&mut self) -> Option<alloc::boxed::Box<FieldTableT>> {
+ if let Self::F(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::F(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the FieldTableT.
- pub fn as_f(&self) -> Option<&FieldTableT> {
- if let Self::F(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return a reference to the FieldTableT.
+ pub fn as_f(&self) -> Option<&FieldTableT> {
+ if let Self::F(v) = self { Some(v.as_ref()) } else { None }
+ }
- /// If the union variant matches, return a mutable reference to the FieldTableT.
- pub fn as_f_mut(&mut self) -> Option<&mut FieldTableT> {
- if let Self::F(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a mutable reference to the FieldTableT.
+ pub fn as_f_mut(&mut self) -> Option<&mut FieldTableT> {
+ if let Self::F(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 5d4dc48..563cdcd 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
@@ -12,10 +12,10 @@
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_GAME_MESSAGE: [GameMessage; 4] = [
- GameMessage::NONE,
- GameMessage::PlayerStatEvent,
- GameMessage::PlayerSpectate,
- GameMessage::PlayerInputChange,
+ GameMessage::NONE,
+ GameMessage::PlayerStatEvent,
+ GameMessage::PlayerSpectate,
+ GameMessage::PlayerInputChange,
];
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
@@ -24,50 +24,50 @@
#[allow(non_upper_case_globals)]
impl GameMessage {
- pub const NONE: Self = Self(0);
- pub const PlayerStatEvent: Self = Self(1);
- pub const PlayerSpectate: Self = Self(2);
- pub const PlayerInputChange: Self = Self(3);
+ pub const NONE: Self = Self(0);
+ pub const PlayerStatEvent: Self = Self(1);
+ pub const PlayerSpectate: Self = Self(2);
+ pub const PlayerInputChange: Self = Self(3);
- pub const ENUM_MIN: u8 = 0;
- pub const ENUM_MAX: u8 = 3;
- pub const ENUM_VALUES: &'static [Self] = &[
- Self::NONE,
- Self::PlayerStatEvent,
- Self::PlayerSpectate,
- Self::PlayerInputChange,
- ];
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::PlayerStatEvent,
+ Self::PlayerSpectate,
+ Self::PlayerInputChange,
+ ];
- /// Returns the variant's name or "" if unknown.
- pub fn variant_name(self) -> Option<&'static str> {
- match self {
- Self::NONE => Some("NONE"),
- Self::PlayerStatEvent => Some("PlayerStatEvent"),
- Self::PlayerSpectate => Some("PlayerSpectate"),
- Self::PlayerInputChange => Some("PlayerInputChange"),
- _ => None,
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::PlayerStatEvent => Some("PlayerStatEvent"),
+ Self::PlayerSpectate => Some("PlayerSpectate"),
+ Self::PlayerInputChange => Some("PlayerInputChange"),
+ _ => None,
+ }
}
- }
}
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 {
- f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
}
- }
}
impl<'a> ::flatbuffers::Follow<'a> for GameMessage {
- type Inner = Self;
+ type Inner = Self;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
- Self(b)
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
+ Self(b)
+ }
}
impl ::flatbuffers::Push for GameMessage {
@@ -80,28 +80,28 @@
}
impl ::flatbuffers::EndianScalar for GameMessage {
- type Scalar = u8;
+ type Scalar = u8;
- #[inline]
- fn to_little_endian(self) -> u8 {
- self.0.to_le()
- }
+ #[inline]
+ fn to_little_endian(self) -> u8 {
+ self.0.to_le()
+ }
- #[inline]
- #[allow(clippy::wrong_self_convention)]
- fn from_little_endian(v: u8) -> Self {
- let b = u8::from_le(v);
- Self(b)
- }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(v: u8) -> Self {
+ let b = u8::from_le(v);
+ Self(b)
+ }
}
impl<'a> ::flatbuffers::Verifiable for GameMessage {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- u8::run_verifier(v, pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ u8::run_verifier(v, pos)
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for GameMessage {}
@@ -112,107 +112,107 @@
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub enum GameMessageT {
- NONE,
- PlayerStatEvent(alloc::boxed::Box<PlayerStatEventT>),
- PlayerSpectate(alloc::boxed::Box<PlayerSpectateT>),
- PlayerInputChange(alloc::boxed::Box<PlayerInputChangeT>),
+ NONE,
+ PlayerStatEvent(alloc::boxed::Box<PlayerStatEventT>),
+ PlayerSpectate(alloc::boxed::Box<PlayerSpectateT>),
+ PlayerInputChange(alloc::boxed::Box<PlayerInputChangeT>),
}
impl Default for GameMessageT {
- fn default() -> Self {
- Self::NONE
- }
+ fn default() -> Self {
+ Self::NONE
+ }
}
impl GameMessageT {
- pub fn game_message_type(&self) -> GameMessage {
- match self {
- Self::NONE => GameMessage::NONE,
- Self::PlayerStatEvent(_) => GameMessage::PlayerStatEvent,
- Self::PlayerSpectate(_) => GameMessage::PlayerSpectate,
- Self::PlayerInputChange(_) => GameMessage::PlayerInputChange,
+ pub fn game_message_type(&self) -> GameMessage {
+ match self {
+ Self::NONE => GameMessage::NONE,
+ Self::PlayerStatEvent(_) => GameMessage::PlayerStatEvent,
+ Self::PlayerSpectate(_) => GameMessage::PlayerSpectate,
+ Self::PlayerInputChange(_) => GameMessage::PlayerInputChange,
+ }
}
- }
- 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()),
- Self::PlayerSpectate(v) => Some(v.pack(fbb).as_union_value()),
- Self::PlayerInputChange(v) => Some(v.pack(fbb).as_union_value()),
+ 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()),
+ Self::PlayerSpectate(v) => Some(v.pack(fbb).as_union_value()),
+ Self::PlayerInputChange(v) => Some(v.pack(fbb).as_union_value()),
+ }
}
- }
- /// If the union variant matches, return the owned PlayerStatEventT, setting the union to NONE.
- pub fn take_player_stat_event(&mut self) -> Option<alloc::boxed::Box<PlayerStatEventT>> {
- if let Self::PlayerStatEvent(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::PlayerStatEvent(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return the owned PlayerStatEventT, setting the union to NONE.
+ pub fn take_player_stat_event(&mut self) -> Option<alloc::boxed::Box<PlayerStatEventT>> {
+ if let Self::PlayerStatEvent(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::PlayerStatEvent(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
}
- }
- /// If the union variant matches, return a reference to the PlayerStatEventT.
- pub fn as_player_stat_event(&self) -> Option<&PlayerStatEventT> {
- if let Self::PlayerStatEvent(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the PlayerStatEventT.
- pub fn as_player_stat_event_mut(&mut self) -> Option<&mut PlayerStatEventT> {
- 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<alloc::boxed::Box<PlayerSpectateT>> {
- if let Self::PlayerSpectate(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::PlayerSpectate(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a reference to the PlayerStatEventT.
+ pub fn as_player_stat_event(&self) -> Option<&PlayerStatEventT> {
+ if let Self::PlayerStatEvent(v) = self { Some(v.as_ref()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the PlayerSpectateT.
- pub fn as_player_spectate(&self) -> Option<&PlayerSpectateT> {
- if let Self::PlayerSpectate(v) = self { Some(v.as_ref()) } else { None }
- }
-
- /// If the union variant matches, return a mutable reference to the PlayerSpectateT.
- pub fn as_player_spectate_mut(&mut self) -> Option<&mut PlayerSpectateT> {
- 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<alloc::boxed::Box<PlayerInputChangeT>> {
- if let Self::PlayerInputChange(_) = self {
- let v = ::core::mem::replace(self, Self::NONE);
- if let Self::PlayerInputChange(w) = v {
- Some(w)
- } else {
- unreachable!()
- }
- } else {
- None
+ /// If the union variant matches, return a mutable reference to the PlayerStatEventT.
+ pub fn as_player_stat_event_mut(&mut self) -> Option<&mut PlayerStatEventT> {
+ if let Self::PlayerStatEvent(v) = self { Some(v.as_mut()) } else { None }
}
- }
- /// If the union variant matches, return a reference to the PlayerInputChangeT.
- pub fn as_player_input_change(&self) -> Option<&PlayerInputChangeT> {
- if let Self::PlayerInputChange(v) = self { Some(v.as_ref()) } else { None }
- }
+ /// If the union variant matches, return the owned PlayerSpectateT, setting the union to NONE.
+ pub fn take_player_spectate(&mut self) -> Option<alloc::boxed::Box<PlayerSpectateT>> {
+ if let Self::PlayerSpectate(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::PlayerSpectate(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
- /// If the union variant matches, return a mutable reference to the PlayerInputChangeT.
- pub fn as_player_input_change_mut(&mut self) -> Option<&mut PlayerInputChangeT> {
- if let Self::PlayerInputChange(v) = self { Some(v.as_mut()) } else { None }
- }
+ /// If the union variant matches, return a reference to the PlayerSpectateT.
+ pub fn as_player_spectate(&self) -> Option<&PlayerSpectateT> {
+ if let Self::PlayerSpectate(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the PlayerSpectateT.
+ pub fn as_player_spectate_mut(&mut self) -> Option<&mut PlayerSpectateT> {
+ 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<alloc::boxed::Box<PlayerInputChangeT>> {
+ if let Self::PlayerInputChange(_) = self {
+ let v = ::core::mem::replace(self, Self::NONE);
+ if let Self::PlayerInputChange(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+
+ /// If the union variant matches, return a reference to the PlayerInputChangeT.
+ pub fn as_player_input_change(&self) -> Option<&PlayerInputChangeT> {
+ if let Self::PlayerInputChange(v) = self { Some(v.as_ref()) } else { None }
+ }
+
+ /// If the union variant matches, return a mutable reference to the PlayerInputChangeT.
+ pub fn as_player_input_change_mut(&mut self) -> Option<&mut PlayerInputChangeT> {
+ if let Self::PlayerInputChange(v) = self { Some(v.as_mut()) } else { None }
+ }
}
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 6132c77..a72cbc5 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
@@ -7,146 +7,146 @@
#[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> {
- type Inner = GameMessageWrapper<'a>;
+ type Inner = GameMessageWrapper<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args GameMessageWrapperArgs
- ) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'bldr>> {
- let mut builder = GameMessageWrapperBuilder::new(_fbb);
- if let Some(x) = args.Message { builder.add_Message(x); }
- builder.add_Message_type(args.Message_type);
- builder.finish()
- }
-
- pub fn unpack(&self) -> GameMessageWrapperT {
- let Message = match self.Message_type() {
- GameMessage::NONE => GameMessageT::NONE,
- 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(alloc::boxed::Box::new(
- self.Message_as_player_spectate()
- .expect("Invalid union table, expected `GameMessage::PlayerSpectate`.")
- .unpack()
- )),
- GameMessage::PlayerInputChange => GameMessageT::PlayerInputChange(alloc::boxed::Box::new(
- self.Message_as_player_input_change()
- .expect("Invalid union table, expected `GameMessage::PlayerInputChange`.")
- .unpack()
- )),
- _ => GameMessageT::NONE,
- };
- GameMessageWrapperT {
- Message,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.GameMessageWrapper"
}
- }
- #[inline]
- pub fn Message_type(&self) -> GameMessage {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<GameMessage>(GameMessageWrapper::VT_MESSAGE_TYPE, Some(GameMessage::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(GameMessageWrapper::VT_MESSAGE, None)}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn Message_as_player_stat_event(&self) -> Option<PlayerStatEvent<'a>> {
- if self.Message_type() == GameMessage::PlayerStatEvent {
- self.Message().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { PlayerStatEvent::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ pub unsafe fn init_from_table(table: ::flatbuffers::Table<'a>) -> Self {
+ GameMessageWrapper { _tab: table }
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn Message_as_player_spectate(&self) -> Option<PlayerSpectate<'a>> {
- if self.Message_type() == GameMessage::PlayerSpectate {
- self.Message().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { PlayerSpectate::init_from_table(t) }
- })
- } else {
- None
+ #[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>,
+ args: &'args GameMessageWrapperArgs
+ ) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'bldr>> {
+ let mut builder = GameMessageWrapperBuilder::new(_fbb);
+ if let Some(x) = args.Message { builder.add_Message(x); }
+ builder.add_Message_type(args.Message_type);
+ builder.finish()
}
- }
- #[inline]
- #[allow(non_snake_case)]
- pub fn Message_as_player_input_change(&self) -> Option<PlayerInputChange<'a>> {
- if self.Message_type() == GameMessage::PlayerInputChange {
- self.Message().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { PlayerInputChange::init_from_table(t) }
- })
- } else {
- None
+ pub fn unpack(&self) -> GameMessageWrapperT {
+ let Message = match self.Message_type() {
+ GameMessage::NONE => GameMessageT::NONE,
+ 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(alloc::boxed::Box::new(
+ self.Message_as_player_spectate()
+ .expect("Invalid union table, expected `GameMessage::PlayerSpectate`.")
+ .unpack()
+ )),
+ GameMessage::PlayerInputChange => GameMessageT::PlayerInputChange(alloc::boxed::Box::new(
+ self.Message_as_player_input_change()
+ .expect("Invalid union table, expected `GameMessage::PlayerInputChange`.")
+ .unpack()
+ )),
+ _ => GameMessageT::NONE,
+ };
+ GameMessageWrapperT {
+ Message,
+ }
}
- }
+
+ #[inline]
+ pub fn Message_type(&self) -> GameMessage {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<GameMessage>(GameMessageWrapper::VT_MESSAGE_TYPE, Some(GameMessage::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(GameMessageWrapper::VT_MESSAGE, None)}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn Message_as_player_stat_event(&self) -> Option<PlayerStatEvent<'a>> {
+ if self.Message_type() == GameMessage::PlayerStatEvent {
+ self.Message().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { PlayerStatEvent::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn Message_as_player_spectate(&self) -> Option<PlayerSpectate<'a>> {
+ if self.Message_type() == GameMessage::PlayerSpectate {
+ self.Message().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { PlayerSpectate::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn Message_as_player_input_change(&self) -> Option<PlayerInputChange<'a>> {
+ if self.Message_type() == GameMessage::PlayerInputChange {
+ self.Message().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { PlayerInputChange::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for GameMessageWrapper<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_union::<GameMessage, _>("Message_type", Self::VT_MESSAGE_TYPE, "Message", Self::VT_MESSAGE, false, |key, v, pos| {
- match key {
- GameMessage::PlayerStatEvent => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerStatEvent>>("GameMessage::PlayerStatEvent", pos),
- GameMessage::PlayerSpectate => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerSpectate>>("GameMessage::PlayerSpectate", pos),
- GameMessage::PlayerInputChange => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerInputChange>>("GameMessage::PlayerInputChange", pos),
- _ => Ok(()),
- }
- })?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_union::<GameMessage, _>("Message_type", Self::VT_MESSAGE_TYPE, "Message", Self::VT_MESSAGE, false, |key, v, pos| {
+ match key {
+ GameMessage::PlayerStatEvent => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerStatEvent>>("GameMessage::PlayerStatEvent", pos),
+ GameMessage::PlayerSpectate => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerSpectate>>("GameMessage::PlayerSpectate", pos),
+ GameMessage::PlayerInputChange => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<PlayerInputChange>>("GameMessage::PlayerInputChange", pos),
+ _ => Ok(()),
+ }
+ })?
+ .finish();
+ Ok(())
+ }
}
pub struct GameMessageWrapperArgs {
@@ -155,106 +155,106 @@
}
impl<'a> Default for GameMessageWrapperArgs {
- #[inline]
- fn default() -> Self {
- GameMessageWrapperArgs {
- Message_type: GameMessage::NONE,
- Message: None,
+ #[inline]
+ fn default() -> Self {
+ GameMessageWrapperArgs {
+ Message_type: GameMessage::NONE,
+ Message: None,
+ }
}
- }
}
pub struct GameMessageWrapperBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<GameMessage>(GameMessageWrapper::VT_MESSAGE_TYPE, Message_type, GameMessage::NONE);
- }
-
- #[inline]
- 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> {
- let start = _fbb.start_table();
- GameMessageWrapperBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_Message_type(&mut self, Message_type: GameMessage) {
+ self.fbb_.push_slot::<GameMessage>(GameMessageWrapper::VT_MESSAGE_TYPE, Message_type, GameMessage::NONE);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ 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> {
+ let start = _fbb.start_table();
+ GameMessageWrapperBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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() {
- GameMessage::PlayerStatEvent => {
- if let Some(x) = self.Message_as_player_stat_event() {
- ds.field("Message", &x)
- } else {
- ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- GameMessage::PlayerSpectate => {
- if let Some(x) = self.Message_as_player_spectate() {
- ds.field("Message", &x)
- } else {
- ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- GameMessage::PlayerInputChange => {
- if let Some(x) = self.Message_as_player_input_change() {
- ds.field("Message", &x)
- } else {
- ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("Message", &x)
- },
- };
- ds.finish()
- }
+ 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() {
+ GameMessage::PlayerStatEvent => {
+ if let Some(x) = self.Message_as_player_stat_event() {
+ ds.field("Message", &x)
+ } else {
+ ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ GameMessage::PlayerSpectate => {
+ if let Some(x) = self.Message_as_player_spectate() {
+ ds.field("Message", &x)
+ } else {
+ ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ GameMessage::PlayerInputChange => {
+ if let Some(x) = self.Message_as_player_input_change() {
+ ds.field("Message", &x)
+ } else {
+ ds.field("Message", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("Message", &x)
+ },
+ };
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct GameMessageWrapperT {
- pub Message: GameMessageT,
+ pub Message: GameMessageT,
}
impl Default for GameMessageWrapperT {
- fn default() -> Self {
- Self {
- Message: GameMessageT::NONE,
+ fn default() -> Self {
+ Self {
+ Message: GameMessageT::NONE,
+ }
}
- }
}
impl GameMessageWrapperT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'b>> {
- let Message_type = self.Message.game_message_type();
- let Message = self.Message.pack(_fbb);
- GameMessageWrapper::create(_fbb, &GameMessageWrapperArgs{
- Message_type,
- Message,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'b>> {
+ let Message_type = self.Message.game_message_type();
+ let Message = self.Message.pack(_fbb);
+ GameMessageWrapper::create(_fbb, &GameMessageWrapperArgs{
+ Message_type,
+ Message,
+ })
+ }
}
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 75fb6e4..ede5f7f 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
@@ -7,92 +7,92 @@
#[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> {
- type Inner = PlayerInputChange<'a>;
+ type Inner = PlayerInputChange<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> PlayerInputChange<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "RustNamerTest.PlayerInputChange"
- }
-
- #[inline]
- 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>,
- _args: &'args PlayerInputChangeArgs
- ) -> ::flatbuffers::WIPOffset<PlayerInputChange<'bldr>> {
- let mut builder = PlayerInputChangeBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> PlayerInputChangeT {
- PlayerInputChangeT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.PlayerInputChange"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args PlayerInputChangeArgs
+ ) -> ::flatbuffers::WIPOffset<PlayerInputChange<'bldr>> {
+ let mut builder = PlayerInputChangeBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> PlayerInputChangeT {
+ PlayerInputChangeT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for PlayerInputChange<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct PlayerInputChangeArgs {
}
impl<'a> Default for PlayerInputChangeArgs {
- #[inline]
- fn default() -> Self {
- PlayerInputChangeArgs {
+ #[inline]
+ fn default() -> Self {
+ PlayerInputChangeArgs {
+ }
}
- }
}
pub struct PlayerInputChangeBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- PlayerInputChangeBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerInputChangeBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ PlayerInputChangeBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerInputChange<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerInputChange<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("PlayerInputChange");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for PlayerInputChangeT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl PlayerInputChangeT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<PlayerInputChange<'b>> {
- PlayerInputChange::create(_fbb, &PlayerInputChangeArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<PlayerInputChange<'b>> {
+ 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 df9fbd9..13b9de4 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
@@ -7,92 +7,92 @@
#[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> {
- type Inner = PlayerSpectate<'a>;
+ type Inner = PlayerSpectate<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> PlayerSpectate<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "RustNamerTest.PlayerSpectate"
- }
-
- #[inline]
- 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>,
- _args: &'args PlayerSpectateArgs
- ) -> ::flatbuffers::WIPOffset<PlayerSpectate<'bldr>> {
- let mut builder = PlayerSpectateBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> PlayerSpectateT {
- PlayerSpectateT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.PlayerSpectate"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args PlayerSpectateArgs
+ ) -> ::flatbuffers::WIPOffset<PlayerSpectate<'bldr>> {
+ let mut builder = PlayerSpectateBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> PlayerSpectateT {
+ PlayerSpectateT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for PlayerSpectate<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct PlayerSpectateArgs {
}
impl<'a> Default for PlayerSpectateArgs {
- #[inline]
- fn default() -> Self {
- PlayerSpectateArgs {
+ #[inline]
+ fn default() -> Self {
+ PlayerSpectateArgs {
+ }
}
- }
}
pub struct PlayerSpectateBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- PlayerSpectateBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerSpectateBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ PlayerSpectateBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerSpectate<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerSpectate<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("PlayerSpectate");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for PlayerSpectateT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl PlayerSpectateT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<PlayerSpectate<'b>> {
- PlayerSpectate::create(_fbb, &PlayerSpectateArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<PlayerSpectate<'b>> {
+ 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 4ed80f0..ba57cc2 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
@@ -7,92 +7,92 @@
#[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> {
- type Inner = PlayerStatEvent<'a>;
+ type Inner = PlayerStatEvent<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
+ }
}
impl<'a> PlayerStatEvent<'a> {
- pub const fn get_fully_qualified_name() -> &'static str {
- "RustNamerTest.PlayerStatEvent"
- }
-
- #[inline]
- 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>,
- _args: &'args PlayerStatEventArgs
- ) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'bldr>> {
- let mut builder = PlayerStatEventBuilder::new(_fbb);
- builder.finish()
- }
-
- pub fn unpack(&self) -> PlayerStatEventT {
- PlayerStatEventT {
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.PlayerStatEvent"
}
- }
+
+ #[inline]
+ 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>,
+ _args: &'args PlayerStatEventArgs
+ ) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'bldr>> {
+ let mut builder = PlayerStatEventBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> PlayerStatEventT {
+ PlayerStatEventT {
+ }
+ }
}
impl ::flatbuffers::Verifiable for PlayerStatEvent<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
}
pub struct PlayerStatEventArgs {
}
impl<'a> Default for PlayerStatEventArgs {
- #[inline]
- fn default() -> Self {
- PlayerStatEventArgs {
+ #[inline]
+ fn default() -> Self {
+ PlayerStatEventArgs {
+ }
}
- }
}
pub struct PlayerStatEventBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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> {
- let start = _fbb.start_table();
- PlayerStatEventBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn new(_fbb: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>) -> PlayerStatEventBuilder<'a, 'b, A> {
+ let start = _fbb.start_table();
+ PlayerStatEventBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter<'_>) -> ::core::fmt::Result {
+ let mut ds = f.debug_struct("PlayerStatEvent");
+ ds.finish()
+ }
}
#[non_exhaustive]
@@ -101,18 +101,18 @@
}
impl Default for PlayerStatEventT {
- fn default() -> Self {
- Self {
+ fn default() -> Self {
+ Self {
+ }
}
- }
}
impl PlayerStatEventT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'b>> {
- PlayerStatEvent::create(_fbb, &PlayerStatEventArgs{
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'b>> {
+ 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 bff14ad..36bdc38 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
@@ -8,41 +8,41 @@
#[derive(Clone, Copy, PartialEq)]
pub struct PossiblyReservedWords(pub [u8; 16]);
-impl Default for PossiblyReservedWords {
- fn default() -> Self {
- Self([0; 16])
- }
+impl Default for PossiblyReservedWords {
+ fn default() -> Self {
+ Self([0; 16])
+ }
}
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_())
- .field("size", &self.size())
- .field("alignment", &self.alignment())
- .finish()
- }
+ fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
+ f.debug_struct("PossiblyReservedWords")
+ .field("follow_", &self.follow_())
+ .field("push_", &self.push_())
+ .field("size", &self.size())
+ .field("alignment", &self.alignment())
+ .finish()
+ }
}
impl ::flatbuffers::SimpleToVerifyInSlice for PossiblyReservedWords {}
impl<'a> ::flatbuffers::Follow<'a> for PossiblyReservedWords {
- type Inner = &'a PossiblyReservedWords;
+ type Inner = &'a PossiblyReservedWords;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { <&'a PossiblyReservedWords>::follow(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { <&'a PossiblyReservedWords>::follow(buf, loc) }
+ }
}
impl<'a> ::flatbuffers::Follow<'a> for &'a PossiblyReservedWords {
- type Inner = &'a PossiblyReservedWords;
+ type Inner = &'a PossiblyReservedWords;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- unsafe { ::flatbuffers::follow_cast_ref::<PossiblyReservedWords>(buf, loc) }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ unsafe { ::flatbuffers::follow_cast_ref::<PossiblyReservedWords>(buf, loc) }
+ }
}
impl<'b> ::flatbuffers::Push for PossiblyReservedWords {
@@ -61,175 +61,175 @@
}
impl<'a> ::flatbuffers::Verifiable for PossiblyReservedWords {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.in_buffer::<Self>(pos)
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.in_buffer::<Self>(pos)
+ }
}
impl<'a> PossiblyReservedWords {
- #[allow(clippy::too_many_arguments)]
- pub fn new(
- follow_: f32,
- push_: f32,
- size: f32,
- alignment: f32,
- ) -> Self {
- let mut s = Self([0; 16]);
- s.set_follow_(follow_);
- s.set_push_(push_);
- s.set_size(size);
- s.set_alignment(alignment);
- s
- }
-
- pub const fn get_fully_qualified_name() -> &'static str {
- "RustNamerTest.PossiblyReservedWords"
- }
-
- pub fn follow_(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[0..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_follow_(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[0..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ follow_: f32,
+ push_: f32,
+ size: f32,
+ alignment: f32,
+ ) -> Self {
+ let mut s = Self([0; 16]);
+ s.set_follow_(follow_);
+ s.set_push_(push_);
+ s.set_size(size);
+ s.set_alignment(alignment);
+ s
}
- }
- pub fn push_(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[4..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_push_(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[4..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.PossiblyReservedWords"
}
- }
- pub fn size(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::flatbuffers::EndianScalar::from_little_endian(unsafe {
- ::core::ptr::copy_nonoverlapping(
- self.0[8..].as_ptr(),
- mem.as_mut_ptr() as *mut u8,
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_size(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[8..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn follow_(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
- pub fn alignment(&self) -> f32 {
- let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid value in this slot
- ::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::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
- mem.assume_init()
- })
- }
-
- pub fn set_alignment(&mut self, x: f32) {
- 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(
- &x_le as *const _ as *const u8,
- self.0[12..].as_mut_ptr(),
- ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
- );
+ pub fn set_follow_(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[0..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
}
- }
- pub fn unpack(&self) -> PossiblyReservedWordsT {
- PossiblyReservedWordsT {
- follow_: self.follow_(),
- push_: self.push_(),
- size: self.size(),
- alignment: self.alignment(),
+ pub fn push_(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
}
- }
+
+ pub fn set_push_(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[4..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn size(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::flatbuffers::EndianScalar::from_little_endian(unsafe {
+ ::core::ptr::copy_nonoverlapping(
+ self.0[8..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_size(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[8..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn alignment(&self) -> f32 {
+ let mut mem = ::core::mem::MaybeUninit::<<f32 as ::flatbuffers::EndianScalar>::Scalar>::uninit();
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid value in this slot
+ ::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::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ mem.assume_init()
+ })
+ }
+
+ pub fn set_alignment(&mut self, x: f32) {
+ 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(
+ &x_le as *const _ as *const u8,
+ self.0[12..].as_mut_ptr(),
+ ::core::mem::size_of::<<f32 as ::flatbuffers::EndianScalar>::Scalar>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> PossiblyReservedWordsT {
+ PossiblyReservedWordsT {
+ follow_: self.follow_(),
+ push_: self.push_(),
+ size: self.size(),
+ alignment: self.alignment(),
+ }
+ }
}
#[derive(Debug, Clone, PartialEq, Default)]
pub struct PossiblyReservedWordsT {
- pub follow_: f32,
- pub push_: f32,
- pub size: f32,
- pub alignment: f32,
+ pub follow_: f32,
+ pub push_: f32,
+ pub size: f32,
+ pub alignment: f32,
}
impl PossiblyReservedWordsT {
- pub fn pack(&self) -> PossiblyReservedWords {
- PossiblyReservedWords::new(
- self.follow_,
- self.push_,
- self.size,
- self.alignment,
- )
- }
+ pub fn pack(&self) -> PossiblyReservedWords {
+ PossiblyReservedWords::new(
+ self.follow_,
+ self.push_,
+ self.size,
+ self.alignment,
+ )
+ }
}
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 7677de0..0ff2e5c 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
@@ -7,104 +7,104 @@
#[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> {
- type Inner = RootTable<'a>;
+ type Inner = RootTable<'a>;
- #[inline]
- unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
- Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
- }
+ #[inline]
+ unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: unsafe { ::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 {
- 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>,
- args: &'args RootTableArgs
- ) -> ::flatbuffers::WIPOffset<RootTable<'bldr>> {
- let mut builder = RootTableBuilder::new(_fbb);
- if let Some(x) = args.field42 { builder.add_field42(x); }
- builder.add_field42_type(args.field42_type);
- builder.finish()
- }
-
- pub fn unpack(&self) -> RootTableT {
- let field42 = match self.field42_type() {
- FieldUnion::NONE => FieldUnionT::NONE,
- FieldUnion::f => FieldUnionT::F(alloc::boxed::Box::new(
- self.field42_as_f()
- .expect("Invalid union table, expected `FieldUnion::f`.")
- .unpack()
- )),
- _ => FieldUnionT::NONE,
- };
- RootTableT {
- field42,
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "RustNamerTest.RootTable"
}
- }
- #[inline]
- pub fn field42_type(&self) -> FieldUnion {
- // Safety:
- // Created from valid Table for this object
- // which contains a valid value in this slot
- unsafe { self._tab.get::<FieldUnion>(RootTable::VT_FIELD42_TYPE, Some(FieldUnion::NONE)).unwrap()}
- }
-
- #[inline]
- 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(RootTable::VT_FIELD42, None)}
- }
-
- #[inline]
- #[allow(non_snake_case)]
- pub fn field42_as_f(&self) -> Option<FieldTable<'a>> {
- if self.field42_type() == FieldUnion::f {
- self.field42().map(|t| {
- // Safety:
- // Created from a valid Table for this object
- // Which contains a valid union in this slot
- unsafe { FieldTable::init_from_table(t) }
- })
- } else {
- None
+ #[inline]
+ 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>,
+ args: &'args RootTableArgs
+ ) -> ::flatbuffers::WIPOffset<RootTable<'bldr>> {
+ let mut builder = RootTableBuilder::new(_fbb);
+ if let Some(x) = args.field42 { builder.add_field42(x); }
+ builder.add_field42_type(args.field42_type);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> RootTableT {
+ let field42 = match self.field42_type() {
+ FieldUnion::NONE => FieldUnionT::NONE,
+ FieldUnion::f => FieldUnionT::F(alloc::boxed::Box::new(
+ self.field42_as_f()
+ .expect("Invalid union table, expected `FieldUnion::f`.")
+ .unpack()
+ )),
+ _ => FieldUnionT::NONE,
+ };
+ RootTableT {
+ field42,
+ }
+ }
+
+ #[inline]
+ pub fn field42_type(&self) -> FieldUnion {
+ // Safety:
+ // Created from valid Table for this object
+ // which contains a valid value in this slot
+ unsafe { self._tab.get::<FieldUnion>(RootTable::VT_FIELD42_TYPE, Some(FieldUnion::NONE)).unwrap()}
+ }
+
+ #[inline]
+ 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::<::flatbuffers::ForwardsUOffset<::flatbuffers::Table<'a>>>(RootTable::VT_FIELD42, None)}
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn field42_as_f(&self) -> Option<FieldTable<'a>> {
+ if self.field42_type() == FieldUnion::f {
+ self.field42().map(|t| {
+ // Safety:
+ // Created from a valid Table for this object
+ // Which contains a valid union in this slot
+ unsafe { FieldTable::init_from_table(t) }
+ })
+ } else {
+ None
+ }
+ }
}
impl ::flatbuffers::Verifiable for RootTable<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
- .visit_union::<FieldUnion, _>("field42_type", Self::VT_FIELD42_TYPE, "field42", Self::VT_FIELD42, false, |key, v, pos| {
- match key {
- FieldUnion::f => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<FieldTable>>("FieldUnion::f", pos),
- _ => Ok(()),
- }
- })?
- .finish();
- Ok(())
- }
+ #[inline]
+ fn run_verifier(
+ v: &mut ::flatbuffers::Verifier, pos: usize
+ ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
+ v.visit_table(pos)?
+ .visit_union::<FieldUnion, _>("field42_type", Self::VT_FIELD42_TYPE, "field42", Self::VT_FIELD42, false, |key, v, pos| {
+ match key {
+ FieldUnion::f => v.verify_union_variant::<::flatbuffers::ForwardsUOffset<FieldTable>>("FieldUnion::f", pos),
+ _ => Ok(()),
+ }
+ })?
+ .finish();
+ Ok(())
+ }
}
pub struct RootTableArgs {
@@ -113,92 +113,92 @@
}
impl<'a> Default for RootTableArgs {
- #[inline]
- fn default() -> Self {
- RootTableArgs {
- field42_type: FieldUnion::NONE,
- field42: None,
+ #[inline]
+ fn default() -> Self {
+ RootTableArgs {
+ field42_type: FieldUnion::NONE,
+ field42: None,
+ }
}
- }
}
pub struct RootTableBuilder<'a: 'b, 'b, A: ::flatbuffers::Allocator + 'a> {
- fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
- start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
+ fbb_: &'b mut ::flatbuffers::FlatBufferBuilder<'a, A>,
+ start_: ::flatbuffers::WIPOffset<::flatbuffers::TableUnfinishedWIPOffset>,
}
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::<FieldUnion>(RootTable::VT_FIELD42_TYPE, field42_type, FieldUnion::NONE);
- }
-
- #[inline]
- 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> {
- let start = _fbb.start_table();
- RootTableBuilder {
- fbb_: _fbb,
- start_: start,
+ #[inline]
+ pub fn add_field42_type(&mut self, field42_type: FieldUnion) {
+ self.fbb_.push_slot::<FieldUnion>(RootTable::VT_FIELD42_TYPE, field42_type, FieldUnion::NONE);
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<RootTable<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
+ #[inline]
+ 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> {
+ let start = _fbb.start_table();
+ RootTableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+
+ #[inline]
+ pub fn finish(self) -> ::flatbuffers::WIPOffset<RootTable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
}
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() {
- FieldUnion::f => {
- if let Some(x) = self.field42_as_f() {
- ds.field("field42", &x)
- } else {
- ds.field("field42", &"InvalidFlatbuffer: Union discriminant does not match value.")
- }
- },
- _ => {
- let x: Option<()> = None;
- ds.field("field42", &x)
- },
- };
- ds.finish()
- }
+ 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() {
+ FieldUnion::f => {
+ if let Some(x) = self.field42_as_f() {
+ ds.field("field42", &x)
+ } else {
+ ds.field("field42", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("field42", &x)
+ },
+ };
+ ds.finish()
+ }
}
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct RootTableT {
- pub field42: FieldUnionT,
+ pub field42: FieldUnionT,
}
impl Default for RootTableT {
- fn default() -> Self {
- Self {
- field42: FieldUnionT::NONE,
+ fn default() -> Self {
+ Self {
+ field42: FieldUnionT::NONE,
+ }
}
- }
}
impl RootTableT {
- pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
- &self,
- _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
- ) -> ::flatbuffers::WIPOffset<RootTable<'b>> {
- let field42_type = self.field42.field_union_type();
- let field42 = self.field42.pack(_fbb);
- RootTable::create(_fbb, &RootTableArgs{
- field42_type,
- field42,
- })
- }
+ pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
+ &self,
+ _fbb: &mut ::flatbuffers::FlatBufferBuilder<'b, A>
+ ) -> ::flatbuffers::WIPOffset<RootTable<'b>> {
+ let field42_type = self.field42.field_union_type();
+ let field42 = self.field42.pack(_fbb);
+ RootTable::create(_fbb, &RootTableArgs{
+ field42_type,
+ field42,
+ })
+ }
}