Generate better formatted Rust code (#8919)
* Cleans up Rust formatting
* Regenerates generated schemas
diff --git a/goldens/rust/basic_generated.rs b/goldens/rust/basic_generated.rs
index aa251d1..941408d 100644
--- a/goldens/rust/basic_generated.rs
+++ b/goldens/rust/basic_generated.rs
@@ -1,297 +1,318 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
-
extern crate alloc;
#[allow(unused_imports, dead_code)]
pub mod flatbuffers {
+ extern crate alloc;
-extern crate alloc;
-#[allow(unused_imports, dead_code)]
-pub mod goldens {
+ #[allow(unused_imports, dead_code)]
+ pub mod goldens {
+ extern crate alloc;
-extern crate alloc;
+ pub enum GalaxyOffset {}
-pub enum GalaxyOffset {}
-#[derive(Copy, Clone, PartialEq)]
+ #[derive(Copy, Clone, PartialEq)]
+ pub struct Galaxy<'a> {
+ pub _tab: ::flatbuffers::Table<'a>,
+ }
-pub struct Galaxy<'a> {
- pub _tab: ::flatbuffers::Table<'a>,
-}
+ impl<'a> ::flatbuffers::Follow<'a> for Galaxy<'a> {
+ type Inner = Galaxy<'a>;
-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) } }
- }
-}
+ #[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;
+ 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 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()}
- }
-}
+ #[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)?
+ 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,
+ Ok(())
+ }
}
- }
-}
-pub struct GalaxyBuilder<'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> 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,
+ pub struct GalaxyArgs {
+ pub num_stars: i64,
}
- }
- #[inline]
- pub fn finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
- let o = self.fbb_.end_table(self.start_);
- ::flatbuffers::WIPOffset::new(o.value())
- }
-}
-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()
- }
-}
-pub enum UniverseOffset {}
-#[derive(Copy, Clone, PartialEq)]
+ impl<'a> Default for GalaxyArgs {
+ #[inline]
+ fn default() -> Self {
+ GalaxyArgs {
+ num_stars: 0,
+ }
+ }
+ }
-pub struct Universe<'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 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: '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);
+ }
-impl<'a> Universe<'a> {
- pub const VT_AGE: ::flatbuffers::VOffsetT = 4;
- pub const VT_GALAXIES: ::flatbuffers::VOffsetT = 6;
+ #[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]
- 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 finish(self) -> ::flatbuffers::WIPOffset<Galaxy<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ ::flatbuffers::WIPOffset::new(o.value())
+ }
+ }
+
+ 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()
+ }
+ }
+
+ 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()
+ }
- #[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)}
- }
-}
+ #[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()}
+ }
-impl ::flatbuffers::Verifiable for Universe<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
+ #[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,
+ Ok(())
+ }
}
- }
-}
-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,
+ pub struct UniverseArgs<'a> {
+ pub age: f64,
+ pub galaxies: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ::flatbuffers::ForwardsUOffset<Galaxy<'a>>>>>,
}
- }
- #[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()
- }
-}
-#[inline]
-/// 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`.
-pub fn root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::root::<Universe>(buf)
-}
-#[inline]
-/// 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`.
-pub fn size_prefixed_root_as_universe(buf: &[u8]) -> Result<Universe<'_>, ::flatbuffers::InvalidFlatbuffer> {
- ::flatbuffers::size_prefixed_root::<Universe>(buf)
-}
-#[inline]
-/// 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`.
-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]
-/// 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`.
-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]
-/// 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`.
-pub unsafe fn root_as_universe_unchecked(buf: &[u8]) -> Universe<'_> {
- unsafe { ::flatbuffers::root_unchecked::<Universe>(buf) }
-}
-#[inline]
-/// 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`.
-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);
-}
+ impl<'a> Default for UniverseArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ UniverseArgs {
+ age: 0.0,
+ galaxies: 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
+ 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/my_game/sample/color_generated.rs b/samples/rust_generated/my_game/sample/color_generated.rs
index 34b82ac..88ed9ea 100644
--- a/samples/rust_generated/my_game/sample/color_generated.rs
+++ b/samples/rust_generated/my_game/sample/color_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_COLOR: i8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_COLOR: i8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Color(pub i8);
+
#[allow(non_upper_case_globals)]
impl Color {
pub const Red: Self = Self(0);
@@ -30,6 +34,7 @@
Self::Green,
Self::Blue,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for Color {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for Color {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for Color {
type Output = Color;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for Color {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
diff --git a/samples/rust_generated/my_game/sample/equipment_generated.rs b/samples/rust_generated/my_game/sample/equipment_generated.rs
index f53f8f2..de61cf7 100644
--- a/samples/rust_generated/my_game/sample/equipment_generated.rs
+++ b/samples/rust_generated/my_game/sample/equipment_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_EQUIPMENT: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_EQUIPMENT: u8 = 1;
+
#[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] = [
@@ -16,6 +19,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Equipment(pub u8);
+
#[allow(non_upper_case_globals)]
impl Equipment {
pub const NONE: Self = Self(0);
@@ -27,6 +31,7 @@
Self::NONE,
Self::Weapon,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -36,6 +41,7 @@
}
}
}
+
impl ::core::fmt::Debug for Equipment {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -45,8 +51,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for Equipment {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -56,6 +64,7 @@
impl ::flatbuffers::Push for Equipment {
type Output = Equipment;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -64,10 +73,12 @@
impl ::flatbuffers::EndianScalar for Equipment {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -86,6 +97,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Equipment {}
+
pub struct EquipmentUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -95,11 +107,13 @@
NONE,
Weapon(alloc::boxed::Box<WeaponT>),
}
+
impl Default for EquipmentT {
fn default() -> Self {
Self::NONE
}
}
+
impl EquipmentT {
pub fn equipment_type(&self) -> Equipment {
match self {
@@ -107,12 +121,14 @@
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()),
}
}
+
/// 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 {
@@ -126,12 +142,15 @@
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 }
}
}
+
diff --git a/samples/rust_generated/my_game/sample/monster_generated.rs b/samples/rust_generated/my_game/sample/monster_generated.rs
index 381091d..645c1c2 100644
--- a/samples/rust_generated/my_game/sample/monster_generated.rs
+++ b/samples/rust_generated/my_game/sample/monster_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum MonsterOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum MonsterOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Monster<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -37,6 +39,7 @@
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>,
@@ -104,6 +107,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
+
#[inline]
pub fn mana(&self) -> i16 {
// Safety:
@@ -111,6 +115,7 @@
// 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:
@@ -118,6 +123,7 @@
// 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:
@@ -125,6 +131,7 @@
// 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:
@@ -132,6 +139,7 @@
// 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:
@@ -139,6 +147,7 @@
// 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:
@@ -146,6 +155,7 @@
// 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:
@@ -153,6 +163,7 @@
// 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:
@@ -160,6 +171,7 @@
// 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:
@@ -167,6 +179,7 @@
// 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>> {
@@ -181,7 +194,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for Monster<'_> {
@@ -208,6 +220,7 @@
Ok(())
}
}
+
pub struct MonsterArgs<'a> {
pub pos: Option<&'a Vec3>,
pub mana: i16,
@@ -220,6 +233,7 @@
pub equipped: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
pub path: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, Vec3>>>,
}
+
impl<'a> Default for MonsterArgs<'a> {
#[inline]
fn default() -> Self {
@@ -242,47 +256,58 @@
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();
@@ -291,6 +316,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -326,6 +352,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
@@ -339,6 +366,7 @@
pub equipped: EquipmentT,
pub path: Option<alloc::vec::Vec<Vec3T>>,
}
+
impl Default for MonsterT {
fn default() -> Self {
Self {
@@ -354,6 +382,7 @@
}
}
}
+
impl MonsterT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -392,66 +421,73 @@
})
}
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a `Monster`
/// 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root::<Monster>(buf)
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a size prefixed
/// `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root::<Monster>(buf)
}
-#[inline]
+
/// Verifies, with the given options, that a buffer of bytes
/// contains a `Monster` 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
+#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
+#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
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>,
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 5162468..cc2c5c1 100644
--- a/samples/rust_generated/my_game/sample/vec_3_generated.rs
+++ b/samples/rust_generated/my_game/sample/vec_3_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct Vec3, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 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")
@@ -22,27 +25,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
+
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
type Inner = &'a Vec3;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Vec3>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
type Inner = &'a Vec3;
+
#[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 {
type Output = Vec3;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -178,6 +188,7 @@
pub y: f32,
pub z: f32,
}
+
impl Vec3T {
pub fn pack(&self) -> Vec3 {
Vec3::new(
@@ -187,4 +198,3 @@
)
}
}
-
diff --git a/samples/rust_generated/my_game/sample/weapon_generated.rs b/samples/rust_generated/my_game/sample/weapon_generated.rs
index 7a4c2e7..d11525f 100644
--- a/samples/rust_generated/my_game/sample/weapon_generated.rs
+++ b/samples/rust_generated/my_game/sample/weapon_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum WeaponOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum WeaponOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Weapon<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Weapon<'a> {
type Inner = Weapon<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@
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>,
@@ -58,6 +61,7 @@
// 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:
@@ -79,10 +83,12 @@
Ok(())
}
}
+
pub struct WeaponArgs<'a> {
pub name: Option<::flatbuffers::WIPOffset<&'a str>>,
pub damage: i16,
}
+
impl<'a> Default for WeaponArgs<'a> {
#[inline]
fn default() -> Self {
@@ -97,15 +103,18 @@
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();
@@ -114,6 +123,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Weapon<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -129,12 +139,14 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct WeaponT {
pub name: Option<alloc::string::String>,
pub damage: i16,
}
+
impl Default for WeaponT {
fn default() -> Self {
Self {
@@ -143,6 +155,7 @@
}
}
}
+
impl WeaponT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/src/idl_gen_rust.cpp b/src/idl_gen_rust.cpp
index b7a565d..398475f 100644
--- a/src/idl_gen_rust.cpp
+++ b/src/idl_gen_rust.cpp
@@ -429,8 +429,7 @@
// Generate imports for the global scope in case no namespace is used
// in the schema file.
- GenNamespaceImports(0);
- code_ += "";
+ GenNamespaceImports();
// Generate all code in their namespaces, once, because Rust does not
// permit re-opening modules.
@@ -708,6 +707,8 @@
// an enum match function,
// and an enum array of values
void GenEnum(const EnumDef& enum_def) {
+ code_ += "";
+
const bool is_private = parser_.opts.no_leak_private_annotations &&
(enum_def.attributes.Lookup("private") != nullptr);
code_.SetValue("ACCESS_TYPE", is_private ? "pub(crate)" : "pub");
@@ -739,6 +740,8 @@
code_ += " }";
code_ += " }";
code_ += "}";
+ code_ += "";
+
code_ += "pub use self::bitflags_{{ENUM_NAMESPACE}}::{{ENUM_TY}};";
code_ += "";
@@ -753,10 +756,14 @@
code_ +=
"pub const ENUM_MIN_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
" = {{ENUM_MIN_BASE_VALUE}};";
+ code_ += "";
+
code_ += deprecation_warning;
code_ +=
"pub const ENUM_MAX_{{ENUM_CONSTANT}}: {{BASE_TYPE}}"
" = {{ENUM_MAX_BASE_VALUE}};";
+ code_ += "";
+
auto num_fields = NumToString(enum_def.size());
code_ += deprecation_warning;
code_ += "#[allow(non_camel_case_types)]";
@@ -777,6 +784,8 @@
"Default)]";
code_ += "#[repr(transparent)]";
code_ += "{{ACCESS_TYPE}} struct {{ENUM_TY}}(pub {{BASE_TYPE}});";
+ code_ += "";
+
code_ += "#[allow(non_upper_case_globals)]";
code_ += "impl {{ENUM_TY}} {";
ForAllEnumValues1(enum_def, [&](const EnumVal& ev) {
@@ -790,6 +799,8 @@
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 {";
@@ -800,6 +811,7 @@
code_ += " }";
code_ += " }";
code_ += "}";
+ code_ += "";
// Generate Debug. Unknown variants are printed like "<UNKNOWN 42>".
code_ += "impl ::core::fmt::Debug for {{ENUM_TY}} {";
@@ -813,6 +825,7 @@
code_ += " }";
code_ += " }";
code_ += "}";
+ code_ += "";
code_.SetValue("INTO_BASE", "self.0");
}
@@ -864,6 +877,7 @@
// Generate Follow and Push so we can serialize and stuff.
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{ENUM_TY}} {";
code_ += " type Inner = Self;";
+ code_ += "";
code_ += " #[inline]";
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
@@ -879,6 +893,7 @@
code_ += "";
code_ += "impl ::flatbuffers::Push for {{ENUM_TY}} {";
code_ += " type Output = {{ENUM_TY}};";
+ code_ += "";
code_ += " #[inline]";
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
code_ +=
@@ -889,10 +904,12 @@
code_ += "";
code_ += "impl ::flatbuffers::EndianScalar for {{ENUM_TY}} {";
code_ += " type Scalar = {{BASE_TYPE}};";
+ 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 {";
@@ -922,8 +939,8 @@
if (enum_def.is_union) {
// Generate typesafe offset(s) for unions
code_.SetValue("UNION_TYPE", namer_.Type(enum_def));
- code_ += "{{ACCESS_TYPE}} struct {{UNION_TYPE}}UnionTableOffset {}";
code_ += "";
+ code_ += "{{ACCESS_TYPE}} struct {{UNION_TYPE}}UnionTableOffset {}";
if (parser_.opts.generate_object_based_api) {
GenUnionObject(enum_def);
}
@@ -955,6 +972,7 @@
code_.SetValue("ENUM_OTY", namer_.ObjectType(enum_def));
// Generate native union.
+ code_ += "";
code_ += "#[allow(clippy::upper_case_acronyms)]"; // NONE's spelling is
// intended.
code_ += "#[non_exhaustive]";
@@ -966,12 +984,15 @@
"{{NATIVE_VARIANT}}(alloc::boxed::Box<{{U_ELEMENT_TABLE_TYPE}}>),";
});
code_ += "}";
+ code_ += "";
+
// Generate Default (NONE).
code_ += "impl Default for {{ENUM_OTY}} {";
code_ += " fn default() -> Self {";
code_ += " Self::NONE";
code_ += " }";
code_ += "}";
+ code_ += "";
// Generate native union methods.
code_ += "impl {{ENUM_OTY}} {";
@@ -988,6 +1009,8 @@
});
code_ += " }";
code_ += " }";
+ code_ += "";
+
// Pack flatbuffers union value
code_ +=
" pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(&self, fbb: &mut "
@@ -1006,6 +1029,7 @@
// Generate some accessors;
ForAllUnionObjectVariantsBesidesNone(enum_def, [&] {
// Move accessor.
+ code_ += "";
code_ +=
"/// If the union variant matches, return the owned "
"{{U_ELEMENT_TABLE_TYPE}}, setting the union to NONE.";
@@ -1023,7 +1047,9 @@
code_ += " None";
code_ += " }";
code_ += "}";
+
// Immutable reference accessor.
+ code_ += "";
code_ +=
"/// If the union variant matches, return a reference to the "
"{{U_ELEMENT_TABLE_TYPE}}.";
@@ -1034,7 +1060,9 @@
" if let Self::{{NATIVE_VARIANT}}(v) = self "
"{ Some(v.as_ref()) } else { None }";
code_ += "}";
+
// Mutable reference accessor.
+ code_ += "";
code_ +=
"/// If the union variant matches, return a mutable reference"
" to the {{U_ELEMENT_TABLE_TYPE}}.";
@@ -1046,7 +1074,9 @@
"{ Some(v.as_mut()) } else { None }";
code_ += "}";
});
+
code_ += "}"; // End union methods impl.
+ code_ += "";
}
enum DefaultContext { kBuilder, kAccessor, kObject };
@@ -1673,6 +1703,8 @@
// Generate an accessor struct, builder struct, and create function for a
// table.
void GenTable(const StructDef& struct_def) {
+ code_ += "";
+
const bool is_private =
parser_.opts.no_leak_private_annotations &&
(struct_def.attributes.Lookup("private") != nullptr);
@@ -1683,17 +1715,18 @@
// Generate an offset type, the base type, the Follow impl, and the
// init_from_table impl.
code_ += "{{ACCESS_TYPE}} enum {{STRUCT_TY}}Offset {}";
- code_ += "#[derive(Copy, Clone, PartialEq)]";
code_ += "";
GenComment(struct_def.doc_comment);
+ code_ += "#[derive(Copy, Clone, PartialEq)]";
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_TY}}<'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_ += "";
code_ += " #[inline]";
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
@@ -1710,7 +1743,8 @@
"pub const {{OFFSET_NAME}}: ::flatbuffers::VOffsetT = "
"{{OFFSET_VALUE}};";
});
- code_ += "";
+
+ if (struct_def.fields.vec.size() > 0) { code_ += ""; }
if (parser_.opts.generate_name_strings) {
GenFullyQualifiedNameGetter(struct_def, struct_def.name);
@@ -1722,6 +1756,7 @@
"Self {";
code_ += " {{STRUCT_TY}} { _tab: table }";
code_ += " }";
+ code_ += "";
// Generate a convenient create* function that uses the above builder
// to create a table in one function call.
@@ -1759,6 +1794,7 @@
code_ += " builder.finish()";
code_ += " }";
code_ += "";
+
// Generate Object API Packer function.
if (parser_.opts.generate_object_based_api) {
// TODO(cneo): Replace more for loops with ForAllX stuff.
@@ -1858,6 +1894,7 @@
code_ += " };";
}
});
+
code_ += " {{STRUCT_OTY}} {";
ForAllObjectTableFields(struct_def, [&](const FieldDef& field) {
if (field.value.type.base_type == BASE_TYPE_UTYPE) return;
@@ -1867,8 +1904,6 @@
code_ += " }";
}
- if (struct_def.fields.vec.size() > 0) code_ += "";
-
// Generate the accessors. Each has one of two forms:
//
// If a value can be None:
@@ -1881,6 +1916,7 @@
// self._tab.get::<internal_type>(offset, defaultval).unwrap()
// }
ForAllTableFields(struct_def, [&](const FieldDef& field) {
+ code_ += "";
code_.SetValue("RETURN_TYPE",
GenTableAccessorFuncReturnType(field, "'a"));
@@ -1911,6 +1947,7 @@
FLATBUFFERS_ASSERT(nested_root); // Guaranteed to exist by parser.
code_.SetValue("NESTED", WrapInNameSpace(*nested_root));
+ code_ += "";
code_ += "pub fn {{FIELD}}_nested_flatbuffer(&'a self) -> \\";
if (field.IsRequired()) {
code_ += "{{NESTED}}<'a> {";
@@ -1944,6 +1981,7 @@
ForAllUnionVariantsBesidesNone(
*field.value.type.enum_def, [&](const EnumVal& unused) {
(void)unused;
+ code_ += "";
code_ += "#[inline]";
code_ += "#[allow(non_snake_case)]";
code_ +=
@@ -1987,7 +2025,6 @@
code_ += " None";
code_ += " }";
code_ += "}";
- code_ += "";
});
});
code_ += "}"; // End of table impl.
@@ -2042,6 +2079,7 @@
code_ += " Ok(())";
code_ += " }";
code_ += "}";
+ code_ += "";
// Generate an args struct:
code_.SetValue("MAYBE_LT",
@@ -2052,6 +2090,7 @@
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}} {";
@@ -2145,6 +2184,7 @@
" start_: ::flatbuffers::WIPOffset<"
"::flatbuffers::TableUnfinishedWIPOffset>,";
code_ += "}";
+ code_ += "";
// Generate builder functions:
code_ +=
@@ -2180,6 +2220,7 @@
code_ += " {{FUNC_BODY}}({{FIELD_OFFSET}}, {{FIELD}});";
}
code_ += "}";
+ code_ += "";
});
// Struct initializer (all fields required);
@@ -2195,6 +2236,7 @@
code_ += " start_: start,";
code_ += " }";
code_ += " }";
+ code_ += "";
// finish() function.
code_ += " #[inline]";
@@ -2258,6 +2300,8 @@
}
void GenTableObject(const StructDef& table) {
+ code_ += "";
+
code_.SetValue("STRUCT_OTY", namer_.ObjectType(table));
code_.SetValue("STRUCT_TY", namer_.Type(table));
@@ -2272,6 +2316,7 @@
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
});
code_ += "}";
+ code_ += "";
code_ += "impl Default for {{STRUCT_OTY}} {";
code_ += " fn default() -> Self {";
@@ -2284,6 +2329,7 @@
code_ += " }";
code_ += " }";
code_ += "}";
+ code_ += "";
// TODO(cneo): Generate defaults for Native tables. However, since structs
// may be required, they, and therefore enums need defaults.
@@ -2430,6 +2476,8 @@
code_.SetValue("KEY_TYPE", GenTableAccessorFuncReturnType(field, ""));
code_.SetValue("REF", IsString(field.value.type) ? "" : "&");
+ code_ += "";
+
code_ += "#[inline]";
code_ +=
"pub fn key_compare_less_than(&self, o: &{{STRUCT_TY}}) -> "
@@ -2437,6 +2485,7 @@
code_ += " self.{{FIELD}}() < o.{{FIELD}}()";
code_ += "}";
code_ += "";
+
code_ += "#[inline]";
code_ +=
"pub fn key_compare_with_value(&self, val: {{KEY_TYPE}}) -> "
@@ -2449,45 +2498,51 @@
// Generate functions for accessing the root table object. This function
// must only be called if the root table is defined.
void GenRootTableFuncs(const StructDef& struct_def) {
+ code_ += "";
+
FLATBUFFERS_ASSERT(parser_.root_struct_def_ && "root table not defined");
code_.SetValue("STRUCT_TY", namer_.Type(struct_def));
code_.SetValue("STRUCT_FN", namer_.Function(struct_def));
code_.SetValue("STRUCT_CONST", namer_.Constant(struct_def.name));
// Default verifier root fns.
- code_ += "#[inline]";
code_ += "/// Verifies that a buffer of bytes contains a `{{STRUCT_TY}}`";
code_ += "/// and returns it.";
code_ += "/// Note that verification is still experimental and may not";
code_ += "/// catch every error, or be maximally performant. For the";
code_ += "/// previous, unchecked, behavior use";
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
+ code_ += "#[inline]";
code_ +=
"pub fn root_as_{{STRUCT_FN}}(buf: &[u8]) "
"-> Result<{{STRUCT_TY}}<'_>, ::flatbuffers::InvalidFlatbuffer> {";
code_ += " ::flatbuffers::root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
- code_ += "#[inline]";
+ code_ += "";
+
code_ += "/// Verifies that a buffer of bytes contains a size prefixed";
code_ += "/// `{{STRUCT_TY}}` and returns it.";
code_ += "/// Note that verification is still experimental and may not";
code_ += "/// catch every error, or be maximally performant. For the";
code_ += "/// previous, unchecked, behavior use";
code_ += "/// `size_prefixed_root_as_{{STRUCT_FN}}_unchecked`.";
+ code_ += "#[inline]";
code_ +=
"pub fn size_prefixed_root_as_{{STRUCT_FN}}"
"(buf: &[u8]) -> Result<{{STRUCT_TY}}<'_>, "
"::flatbuffers::InvalidFlatbuffer> {";
code_ += " ::flatbuffers::size_prefixed_root::<{{STRUCT_TY}}>(buf)";
code_ += "}";
+ code_ += "";
+
// Verifier with options root fns.
- code_ += "#[inline]";
code_ += "/// Verifies, with the given options, that a buffer of bytes";
code_ += "/// contains a `{{STRUCT_TY}}` and returns it.";
code_ += "/// Note that verification is still experimental and may not";
code_ += "/// catch every error, or be maximally performant. For the";
code_ += "/// previous, unchecked, behavior use";
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],";
@@ -2496,13 +2551,15 @@
" {";
code_ += " ::flatbuffers::root_with_opts::<{{STRUCT_TY}}<'b>>(opts, buf)";
code_ += "}";
- code_ += "#[inline]";
+ code_ += "";
+
code_ += "/// Verifies, with the given verifier options, that a buffer of";
code_ += "/// bytes contains a size prefixed `{{STRUCT_TY}}` and returns";
code_ += "/// it. Note that verification is still experimental and may not";
code_ += "/// catch every error, or be maximally performant. For the";
code_ += "/// previous, unchecked, behavior use";
code_ += "/// `root_as_{{STRUCT_FN}}_unchecked`.";
+ code_ += "#[inline]";
code_ +=
"pub fn size_prefixed_root_as_{{STRUCT_FN}}_with_opts"
"<'b, 'o>(";
@@ -2515,8 +2572,9 @@
" ::flatbuffers::size_prefixed_root_with_opts::<{{STRUCT_TY}}"
"<'b>>(opts, buf)";
code_ += "}";
+ code_ += "";
+
// Unchecked root fns.
- code_ += "#[inline]";
code_ +=
"/// Assumes, without verification, that a buffer of bytes "
"contains a {{STRUCT_TY}} and returns it.";
@@ -2524,12 +2582,14 @@
code_ +=
"/// Callers must trust the given bytes do indeed contain a valid"
" `{{STRUCT_TY}}`.";
+ code_ += "#[inline]";
code_ +=
"pub unsafe fn root_as_{{STRUCT_FN}}_unchecked"
"(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
code_ += " unsafe { ::flatbuffers::root_unchecked::<{{STRUCT_TY}}>(buf) }";
code_ += "}";
- code_ += "#[inline]";
+ code_ += "";
+
code_ +=
"/// Assumes, without verification, that a buffer of bytes "
"contains a size prefixed {{STRUCT_TY}} and returns it.";
@@ -2537,6 +2597,7 @@
code_ +=
"/// Callers must trust the given bytes do indeed contain a valid"
" size prefixed `{{STRUCT_TY}}`.";
+ code_ += "#[inline]";
code_ +=
"pub unsafe fn size_prefixed_root_as_{{STRUCT_FN}}"
"_unchecked(buf: &[u8]) -> {{STRUCT_TY}}<'_> {";
@@ -2545,6 +2606,7 @@
"::flatbuffers::size_prefixed_root_unchecked::<{{STRUCT_TY}}>"
"(buf) }";
code_ += "}";
+ code_ += "";
if (parser_.file_identifier_.length()) {
// Declare the identifier
@@ -2652,6 +2714,8 @@
}
// Generate an accessor struct with constructor for a flatbuffers struct.
void GenStruct(const StructDef& struct_def) {
+ code_ += "";
+
const bool is_private =
parser_.opts.no_leak_private_annotations &&
(struct_def.attributes.Lookup("private") != nullptr);
@@ -2674,11 +2738,14 @@
code_ += "#[repr(transparent)]";
code_ += "#[derive(Clone, Copy, PartialEq)]";
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_ += "}";
+ code_ += "";
// Debug for structs.
code_ += "impl ::core::fmt::Debug for {{STRUCT_TY}} {";
@@ -2699,15 +2766,21 @@
// Follow for the value type, Follow for the reference type, Push for the
// value type, and Push for the reference type.
code_ += "impl ::flatbuffers::SimpleToVerifyInSlice for {{STRUCT_TY}} {}";
+ code_ += "";
+
code_ += "impl<'a> ::flatbuffers::Follow<'a> for {{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_ += "}";
+ code_ += "";
+
code_ += "impl<'a> ::flatbuffers::Follow<'a> for &'a {{STRUCT_TY}} {";
code_ += " type Inner = &'a {{STRUCT_TY}};";
+ code_ += "";
code_ += " #[inline]";
code_ += " unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {";
code_ +=
@@ -2715,8 +2788,11 @@
"loc) }";
code_ += " }";
code_ += "}";
+ code_ += "";
+
code_ += "impl<'b> ::flatbuffers::Push for {{STRUCT_TY}} {";
code_ += " type Output = {{STRUCT_TY}};";
+ code_ += "";
code_ += " #[inline]";
code_ += " unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {";
code_ +=
@@ -2725,6 +2801,8 @@
"{{STRUCT_TY}} as *const u8, <Self as ::flatbuffers::Push>::size()) };";
code_ += " dst.copy_from_slice(src);";
code_ += " }";
+ code_ += "";
+
code_ += " #[inline]";
code_ += " fn alignment() -> ::flatbuffers::PushAlignment {";
code_ += " ::flatbuffers::PushAlignment::new({{ALIGN}})";
@@ -2934,11 +3012,11 @@
}
code_ += "}"; // End impl Struct methods.
- code_ += "";
// Generate Struct Object.
if (parser_.opts.generate_object_based_api) {
// Struct declaration
+ code_ += "";
code_ += "#[derive(Debug, Clone, PartialEq, Default)]";
code_ += "{{ACCESS_TYPE}} struct {{STRUCT_OTY}} {";
ForAllStructFields(struct_def, [&](const FieldDef& field) {
@@ -2946,6 +3024,8 @@
code_ += "pub {{FIELD}}: {{FIELD_OTY}},";
});
code_ += "}";
+ code_ += "";
+
// The `pack` method that turns the native struct into its Flatbuffers
// counterpart.
code_ += "impl {{STRUCT_OTY}} {";
@@ -2969,16 +3049,13 @@
code_ += " )";
code_ += " }";
code_ += "}";
- code_ += "";
}
}
- void GenNamespaceImports(const int white_spaces) {
+ void GenNamespaceImports() {
// DO not use global attributes (i.e. #![...]) since it interferes
// with users who include! generated files.
// See: https://github.com/google/flatbuffers/issues/6261
- std::string indent = std::string(white_spaces, ' ');
- code_ += "";
if (!parser_.opts.generate_all) {
for (auto it = parser_.included_files_.begin();
it != parser_.included_files_.end(); ++it) {
@@ -2987,23 +3064,22 @@
auto basename = flatbuffers::StripPath(noext);
if (parser_.opts.include_prefix.empty()) {
- code_ += indent + "use crate::" + basename +
- parser_.opts.filename_suffix + "::*;";
+ code_ +=
+ "use crate::" + basename + parser_.opts.filename_suffix + "::*;";
} else {
auto prefix = parser_.opts.include_prefix;
prefix.pop_back();
- code_ += indent + "use crate::" + prefix + "::" + basename +
+ code_ += "use crate::" + prefix + "::" + basename +
parser_.opts.filename_suffix + "::*;";
}
}
}
+
if (parser_.opts.rust_serialize) {
- code_ += indent + "extern crate serde;";
+ code_ += "extern crate serde;";
code_ +=
- indent +
"use self::serde::ser::{Serialize, Serializer, SerializeStruct};";
- code_ += "";
}
code_ += "extern crate alloc;";
}
@@ -3036,22 +3112,18 @@
// Close cur_name_space in reverse order to reach the common prefix.
// In the previous example, D then C are closed.
for (size_t j = old_size; j > common_prefix_size; --j) {
- code_ += "} // pub mod " + cur_name_space_->components[j - 1];
- }
- if (old_size != common_prefix_size) {
- code_ += "";
+ code_.DecrementIdentLevel();
+ code_ += "} // pub mod " + cur_name_space_->components[j - 1];
}
// open namespace parts to reach the ns namespace
// in the previous example, E, then F, then G are opened
for (auto j = common_prefix_size; j != new_size; ++j) {
+ code_ += "";
code_ += "#[allow(unused_imports, dead_code)]";
code_ += "pub mod " + namer_.Namespace(ns->components[j]) + " {";
- // Generate local namespace imports.
- GenNamespaceImports(2);
- }
- if (new_size != common_prefix_size) {
- code_ += "";
+ code_.IncrementIdentLevel();
+ GenNamespaceImports();
}
cur_name_space_ = ns;
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 834fec3..2f446d4 100644
--- a/tests/arrays_test/my_game/example/array_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/array_struct_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct ArrayStruct, aligned to 8
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct ArrayStruct(pub [u8; 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")
@@ -25,27 +28,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for ArrayStruct {}
+
impl<'a> ::flatbuffers::Follow<'a> for ArrayStruct {
type Inner = &'a ArrayStruct;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a ArrayStruct>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for ArrayStruct {
type Output = ArrayStruct;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const ArrayStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(8)
@@ -244,6 +254,7 @@
pub e: i32,
pub f: [i64; 2],
}
+
impl ArrayStructT {
pub fn pack(&self) -> ArrayStruct {
ArrayStruct::new(
@@ -256,4 +267,3 @@
)
}
}
-
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 b0260f6..449f187 100644
--- a/tests/arrays_test/my_game/example/array_table_generated.rs
+++ b/tests/arrays_test/my_game/example/array_table_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum ArrayTableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum ArrayTableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct ArrayTable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for ArrayTable<'a> {
type Inner = ArrayTable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct ArrayTableArgs<'a> {
pub a: Option<&'a ArrayStruct>,
}
+
impl<'a> Default for ArrayTableArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<ArrayTable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ArrayTableT {
pub a: Option<ArrayStructT>,
}
+
impl Default for ArrayTableT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@
}
}
}
+
impl ArrayTableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -134,66 +145,73 @@
})
}
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a `ArrayTable`
/// 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_array_table_unchecked`.
+#[inline]
pub fn root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root::<ArrayTable>(buf)
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a size prefixed
/// `ArrayTable` 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_array_table_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_array_table(buf: &[u8]) -> Result<ArrayTable<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root::<ArrayTable>(buf)
}
-#[inline]
+
/// Verifies, with the given options, that a buffer of bytes
/// contains a `ArrayTable` 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_array_table_unchecked`.
+#[inline]
pub fn root_as_array_table_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root_with_opts::<ArrayTable<'b>>(opts, buf)
}
-#[inline]
+
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `ArrayTable` 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_array_table_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_array_table_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<ArrayTable<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root_with_opts::<ArrayTable<'b>>(opts, buf)
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a ArrayTable and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `ArrayTable`.
+#[inline]
pub unsafe fn root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
unsafe { ::flatbuffers::root_unchecked::<ArrayTable>(buf) }
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ArrayTable and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ArrayTable`.
+#[inline]
pub unsafe fn size_prefixed_root_as_array_table_unchecked(buf: &[u8]) -> ArrayTable<'_> {
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ArrayTable>(buf) }
}
+
pub const ARRAY_TABLE_IDENTIFIER: &str = "ARRT";
#[inline]
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 db538c2..40134ea 100644
--- a/tests/arrays_test/my_game/example/nested_struct_generated.rs
+++ b/tests/arrays_test/my_game/example/nested_struct_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct NestedStruct, aligned to 8
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct NestedStruct(pub [u8; 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")
@@ -23,27 +26,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for NestedStruct {}
+
impl<'a> ::flatbuffers::Follow<'a> for NestedStruct {
type Inner = &'a NestedStruct;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a NestedStruct>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for NestedStruct {
type Output = NestedStruct;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const NestedStruct as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(8)
@@ -176,6 +186,7 @@
pub c: [TestEnum; 2],
pub d: [i64; 2],
}
+
impl NestedStructT {
pub fn pack(&self) -> NestedStruct {
NestedStruct::new(
@@ -186,4 +197,3 @@
)
}
}
-
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 572bdae..de750a1 100644
--- a/tests/arrays_test/my_game/example/test_enum_generated.rs
+++ b/tests/arrays_test/my_game/example/test_enum_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_TEST_ENUM: i8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_TEST_ENUM: i8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct TestEnum(pub i8);
+
#[allow(non_upper_case_globals)]
impl TestEnum {
pub const A: Self = Self(0);
@@ -30,6 +34,7 @@
Self::B,
Self::C,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for TestEnum {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for TestEnum {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for TestEnum {
type Output = TestEnum;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for TestEnum {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
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 5eb9adc..4e03e2d 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
+
#[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.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
@@ -15,6 +18,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FromInclude(pub i64);
+
#[allow(non_upper_case_globals)]
impl FromInclude {
pub const IncludeVal: Self = Self(0);
@@ -24,6 +28,7 @@
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 {
@@ -32,6 +37,7 @@
}
}
}
+
impl ::core::fmt::Debug for FromInclude {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -41,8 +47,10 @@
}
}
}
+
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) };
@@ -52,6 +60,7 @@
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) };
@@ -60,10 +69,12 @@
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 {
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 19a3e66..5e969c2 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableBOffset {}
-#[derive(Copy, Clone, PartialEq)]
+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) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableBArgs<'a> {
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
+
impl<'a> Default for TableBArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
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 {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableBT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 b90fb89..e8639ac 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// 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")
@@ -20,27 +23,34 @@
}
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)
@@ -110,6 +120,7 @@
pub struct UnusedT {
pub a: i32,
}
+
impl UnusedT {
pub fn pack(&self) -> Unused {
Unused::new(
@@ -117,4 +128,3 @@
)
}
}
-
diff --git a/tests/include_test1/table_a_generated.rs b/tests/include_test1/table_a_generated.rs
index ca29250..2558b84 100644
--- a/tests/include_test1/table_a_generated.rs
+++ b/tests/include_test1/table_a_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableAOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/include_test1_generated.rs b/tests/include_test1_generated.rs
index c4575b8..bb00aa8 100644
--- a/tests/include_test1_generated.rs
+++ b/tests/include_test1_generated.rs
@@ -1,17 +1,17 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
-
extern crate alloc;
pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +29,7 @@
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>,
@@ -68,9 +69,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -84,11 +87,13 @@
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();
@@ -97,6 +102,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -111,11 +117,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -123,6 +131,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -136,344 +145,374 @@
})
}
}
+
#[allow(unused_imports, dead_code)]
pub mod my_game {
+ extern crate alloc;
-extern crate alloc;
-#[allow(unused_imports, dead_code)]
-pub mod other_name_space {
+ #[allow(unused_imports, dead_code)]
+ pub mod other_name_space {
+ extern crate alloc;
-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;
-#[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.")]
-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.")]
-#[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);
-#[allow(non_upper_case_globals)]
-impl FromInclude {
- pub const IncludeVal: Self = Self(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,
+ ];
- 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,
+ #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+ #[repr(transparent)]
+ pub struct FromInclude(pub i64);
+
+ #[allow(non_upper_case_globals)]
+ impl FromInclude {
+ 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,
+ ];
+
+ /// 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))
+
+ 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<'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::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 ::flatbuffers::Push for FromInclude {
+ type Output = FromInclude;
-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);
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
+ }
}
- #[inline]
- fn alignment() -> ::flatbuffers::PushAlignment {
- ::flatbuffers::PushAlignment::new(4)
+
+ 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 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>(),
- );
+ 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 fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ 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])
+ }
}
- }
-}
-#[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,
+ 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()
+ }
}
- }
- #[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::SimpleToVerifyInSlice for Unused {}
-impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
+ 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,
+ Ok(())
+ }
}
- }
-}
-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,
+ pub struct TableBArgs<'a> {
+ pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
- }
- #[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<'a> Default for TableBArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ 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
+ 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/my_game/other_name_space/from_include_generated.rs b/tests/include_test2/my_game/other_name_space/from_include_generated.rs
index 5eb9adc..4e03e2d 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
+
#[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.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
@@ -15,6 +18,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FromInclude(pub i64);
+
#[allow(non_upper_case_globals)]
impl FromInclude {
pub const IncludeVal: Self = Self(0);
@@ -24,6 +28,7 @@
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 {
@@ -32,6 +37,7 @@
}
}
}
+
impl ::core::fmt::Debug for FromInclude {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -41,8 +47,10 @@
}
}
}
+
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) };
@@ -52,6 +60,7 @@
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) };
@@ -60,10 +69,12 @@
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 {
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 19a3e66..5e969c2 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableBOffset {}
-#[derive(Copy, Clone, PartialEq)]
+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) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableBArgs<'a> {
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
+
impl<'a> Default for TableBArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
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 {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableBT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 b90fb89..e8639ac 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// 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")
@@ -20,27 +23,34 @@
}
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)
@@ -110,6 +120,7 @@
pub struct UnusedT {
pub a: i32,
}
+
impl UnusedT {
pub fn pack(&self) -> Unused {
Unused::new(
@@ -117,4 +128,3 @@
)
}
}
-
diff --git a/tests/include_test2/table_a_generated.rs b/tests/include_test2/table_a_generated.rs
index ca29250..2558b84 100644
--- a/tests/include_test2/table_a_generated.rs
+++ b/tests/include_test2/table_a_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableAOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/include_test2_generated.rs b/tests/include_test2_generated.rs
index c4575b8..bb00aa8 100644
--- a/tests/include_test2_generated.rs
+++ b/tests/include_test2_generated.rs
@@ -1,17 +1,17 @@
// automatically generated by the FlatBuffers compiler, do not modify
// @generated
-
extern crate alloc;
pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +29,7 @@
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>,
@@ -68,9 +69,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -84,11 +87,13 @@
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();
@@ -97,6 +102,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -111,11 +117,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -123,6 +131,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -136,344 +145,374 @@
})
}
}
+
#[allow(unused_imports, dead_code)]
pub mod my_game {
+ extern crate alloc;
-extern crate alloc;
-#[allow(unused_imports, dead_code)]
-pub mod other_name_space {
+ #[allow(unused_imports, dead_code)]
+ pub mod other_name_space {
+ extern crate alloc;
-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;
-#[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.")]
-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.")]
-#[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);
-#[allow(non_upper_case_globals)]
-impl FromInclude {
- pub const IncludeVal: Self = Self(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,
+ ];
- 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,
+ #[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
+ #[repr(transparent)]
+ pub struct FromInclude(pub i64);
+
+ #[allow(non_upper_case_globals)]
+ impl FromInclude {
+ 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,
+ ];
+
+ /// 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))
+
+ 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<'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::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 ::flatbuffers::Push for FromInclude {
+ type Output = FromInclude;
-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);
+ #[inline]
+ unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
+ unsafe { ::flatbuffers::emplace_scalar::<i64>(dst, self.0) };
+ }
}
- #[inline]
- fn alignment() -> ::flatbuffers::PushAlignment {
- ::flatbuffers::PushAlignment::new(4)
+
+ 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 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>(),
- );
+ 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 fn unpack(&self) -> UnusedT {
- UnusedT {
- a: self.a(),
+ 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])
+ }
}
- }
-}
-#[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,
+ 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()
+ }
}
- }
- #[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::SimpleToVerifyInSlice for Unused {}
-impl ::flatbuffers::Verifiable for TableB<'_> {
- #[inline]
- fn run_verifier(
- v: &mut ::flatbuffers::Verifier, pos: usize
- ) -> Result<(), ::flatbuffers::InvalidFlatbuffer> {
- v.visit_table(pos)?
+ 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,
+ Ok(())
+ }
}
- }
-}
-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,
+ pub struct TableBArgs<'a> {
+ pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
- }
- #[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<'a> Default for TableBArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ 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
+ 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 43df27b..a8da058 100644
--- a/tests/keyword_test/keyword_test/abc_generated.rs
+++ b/tests/keyword_test/keyword_test/abc_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ABC: i32 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ABC: i32 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct ABC(pub i32);
+
#[allow(non_upper_case_globals)]
impl ABC {
pub const void: Self = Self(0);
@@ -30,6 +34,7 @@
Self::where_,
Self::stackalloc,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for ABC {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for ABC {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for ABC {
type Output = ABC;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for ABC {
type Scalar = i32;
+
#[inline]
fn to_little_endian(self) -> i32 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i32) -> Self {
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 1ff91e1..f8c0505 100644
--- a/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_table_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum KeywordsInTableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum KeywordsInTableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct KeywordsInTable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInTable<'a> {
type Inner = KeywordsInTable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -31,6 +33,7 @@
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>,
@@ -64,6 +67,7 @@
// 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:
@@ -71,6 +75,7 @@
// 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:
@@ -78,6 +83,7 @@
// 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:
@@ -101,12 +107,14 @@
Ok(())
}
}
+
pub struct KeywordsInTableArgs {
pub is: ABC,
pub private: public,
pub type_: i32,
pub default: bool,
}
+
impl<'a> Default for KeywordsInTableArgs {
#[inline]
fn default() -> Self {
@@ -123,23 +131,28 @@
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();
@@ -148,6 +161,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<KeywordsInTable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -165,6 +179,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct KeywordsInTableT {
@@ -173,6 +188,7 @@
pub type_: i32,
pub default: bool,
}
+
impl Default for KeywordsInTableT {
fn default() -> Self {
Self {
@@ -183,6 +199,7 @@
}
}
}
+
impl KeywordsInTableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 88dac0e..fe31141 100644
--- a/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
+++ b/tests/keyword_test/keyword_test/keywords_in_union_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_KEYWORDS_IN_UNION: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_KEYWORDS_IN_UNION: u8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct KeywordsInUnion(pub u8);
+
#[allow(non_upper_case_globals)]
impl KeywordsInUnion {
pub const NONE: Self = Self(0);
@@ -30,6 +34,7 @@
Self::static_,
Self::internal,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for KeywordsInUnion {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for KeywordsInUnion {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for KeywordsInUnion {
type Output = KeywordsInUnion;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for KeywordsInUnion {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -90,6 +101,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for KeywordsInUnion {}
+
pub struct KeywordsInUnionUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -100,11 +112,13 @@
Static_(alloc::boxed::Box<KeywordsInTableT>),
Internal(alloc::boxed::Box<KeywordsInTableT>),
}
+
impl Default for KeywordsInUnionT {
fn default() -> Self {
Self::NONE
}
}
+
impl KeywordsInUnionT {
pub fn keywords_in_union_type(&self) -> KeywordsInUnion {
match self {
@@ -113,6 +127,7 @@
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,
@@ -120,6 +135,7 @@
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 {
@@ -133,14 +149,17 @@
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 {
@@ -154,12 +173,15 @@
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 be9570c..a4a449e 100644
--- a/tests/keyword_test/keyword_test/public_generated.rs
+++ b/tests/keyword_test/keyword_test/public_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_PUBLIC: i32 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_PUBLIC: i32 = 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_PUBLIC: [public; 1] = [
@@ -15,6 +18,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct public(pub i32);
+
#[allow(non_upper_case_globals)]
impl public {
pub const NONE: Self = Self(0);
@@ -24,6 +28,7 @@
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 {
@@ -32,6 +37,7 @@
}
}
}
+
impl ::core::fmt::Debug for public {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -41,8 +47,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for public {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
@@ -52,6 +60,7 @@
impl ::flatbuffers::Push for public {
type Output = public;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
@@ -60,10 +69,12 @@
impl ::flatbuffers::EndianScalar for public {
type Scalar = i32;
+
#[inline]
fn to_little_endian(self) -> i32 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i32) -> Self {
diff --git a/tests/keyword_test/keyword_test/table_2_generated.rs b/tests/keyword_test/keyword_test/table_2_generated.rs
index a8e72bd..4436a0f 100644
--- a/tests/keyword_test/keyword_test/table_2_generated.rs
+++ b/tests/keyword_test/keyword_test/table_2_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum Table2Offset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum Table2Offset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Table2<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Table2<'a> {
type Inner = Table2<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@
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>,
@@ -67,6 +70,7 @@
// 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:
@@ -74,6 +78,7 @@
// 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>> {
@@ -103,7 +108,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for Table2<'_> {
@@ -123,10 +127,12 @@
Ok(())
}
}
+
pub struct Table2Args {
pub type_type: KeywordsInUnion,
pub type_: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
}
+
impl<'a> Default for Table2Args {
#[inline]
fn default() -> Self {
@@ -141,15 +147,18 @@
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();
@@ -158,6 +167,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Table2<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -192,11 +202,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct Table2T {
pub type_: KeywordsInUnionT,
}
+
impl Default for Table2T {
fn default() -> Self {
Self {
@@ -204,6 +216,7 @@
}
}
}
+
impl Table2T {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs
index add3b47..6cd6f90 100644
--- a/tests/monster_test/my_game/example/ability_generated.rs
+++ b/tests/monster_test/my_game/example/ability_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct Ability, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Ability(pub [u8; 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")
@@ -21,27 +24,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
+
impl<'a> ::flatbuffers::Follow<'a> for Ability {
type Inner = &'a Ability;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Ability>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for Ability {
type Output = Ability;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Ability as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -102,6 +112,7 @@
}
}
+
#[inline]
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
self.id() < o.id()
@@ -154,6 +165,7 @@
pub id: u32,
pub distance: u32,
}
+
impl AbilityT {
pub fn pack(&self) -> Ability {
Ability::new(
@@ -162,4 +174,3 @@
)
}
}
-
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 af7835d..1363d0e 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY_AMBIGUOUS_ALIASES: u8 = 3;
+
#[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] = [
@@ -18,6 +21,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct AnyAmbiguousAliases(pub u8);
+
#[allow(non_upper_case_globals)]
impl AnyAmbiguousAliases {
pub const NONE: Self = Self(0);
@@ -33,6 +37,7 @@
Self::M2,
Self::M3,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -44,6 +49,7 @@
}
}
}
+
impl ::core::fmt::Debug for AnyAmbiguousAliases {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -53,8 +59,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -64,6 +72,7 @@
impl ::flatbuffers::Push for AnyAmbiguousAliases {
type Output = AnyAmbiguousAliases;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -72,10 +81,12 @@
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -94,6 +105,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
+
pub struct AnyAmbiguousAliasesUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -105,11 +117,13 @@
M2(alloc::boxed::Box<MonsterT>),
M3(alloc::boxed::Box<MonsterT>),
}
+
impl Default for AnyAmbiguousAliasesT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyAmbiguousAliasesT {
pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
match self {
@@ -119,6 +133,7 @@
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,
@@ -127,6 +142,7 @@
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 {
@@ -140,14 +156,17 @@
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 {
@@ -161,14 +180,17 @@
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 {
@@ -182,12 +204,15 @@
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 a1da437..268d316 100644
--- a/tests/monster_test/my_game/example/any_generated.rs
+++ b/tests/monster_test/my_game/example/any_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY: u8 = 3;
+
#[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] = [
@@ -18,6 +21,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Any(pub u8);
+
#[allow(non_upper_case_globals)]
impl Any {
pub const NONE: Self = Self(0);
@@ -33,6 +37,7 @@
Self::TestSimpleTableWithEnum,
Self::MyGame_Example2_Monster,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -44,6 +49,7 @@
}
}
}
+
impl ::core::fmt::Debug for Any {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -53,8 +59,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for Any {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -64,6 +72,7 @@
impl ::flatbuffers::Push for Any {
type Output = Any;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -72,10 +81,12 @@
impl ::flatbuffers::EndianScalar for Any {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -94,6 +105,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
+
pub struct AnyUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -105,11 +117,13 @@
TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
}
+
impl Default for AnyT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyT {
pub fn any_type(&self) -> Any {
match self {
@@ -119,6 +133,7 @@
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,
@@ -127,6 +142,7 @@
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 {
@@ -140,14 +156,17 @@
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 {
@@ -161,14 +180,17 @@
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 {
@@ -182,12 +204,15 @@
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 741f573..f4d8592 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY_UNIQUE_ALIASES: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY_UNIQUE_ALIASES: u8 = 3;
+
#[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] = [
@@ -18,6 +21,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct AnyUniqueAliases(pub u8);
+
#[allow(non_upper_case_globals)]
impl AnyUniqueAliases {
pub const NONE: Self = Self(0);
@@ -33,6 +37,7 @@
Self::TS,
Self::M2,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -44,6 +49,7 @@
}
}
}
+
impl ::core::fmt::Debug for AnyUniqueAliases {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -53,8 +59,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -64,6 +72,7 @@
impl ::flatbuffers::Push for AnyUniqueAliases {
type Output = AnyUniqueAliases;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -72,10 +81,12 @@
impl ::flatbuffers::EndianScalar for AnyUniqueAliases {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -94,6 +105,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {}
+
pub struct AnyUniqueAliasesUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -105,11 +117,13 @@
TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
M2(alloc::boxed::Box<super::example_2::MonsterT>),
}
+
impl Default for AnyUniqueAliasesT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyUniqueAliasesT {
pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
match self {
@@ -119,6 +133,7 @@
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,
@@ -127,6 +142,7 @@
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 {
@@ -140,14 +156,17 @@
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 {
@@ -161,14 +180,17 @@
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 {
@@ -182,12 +204,15 @@
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 5bade50..c4b5842 100644
--- a/tests/monster_test/my_game/example/color_generated.rs
+++ b/tests/monster_test/my_game/example/color_generated.rs
@@ -2,6 +2,7 @@
// @generated
extern crate alloc;
use super::*;
+
#[allow(non_upper_case_globals)]
mod bitflags_color {
::flatbuffers::bitflags::bitflags! {
@@ -17,10 +18,12 @@
}
}
}
+
pub use self::bitflags_color::Color;
impl<'a> ::flatbuffers::Follow<'a> for Color {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -30,6 +33,7 @@
impl ::flatbuffers::Push for Color {
type Output = Color;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.bits()) };
@@ -38,10 +42,12 @@
impl ::flatbuffers::EndianScalar for Color {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.bits().to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
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 efa8f87..b690f44 100644
--- a/tests/monster_test/my_game/example/long_enum_generated.rs
+++ b/tests/monster_test/my_game/example/long_enum_generated.rs
@@ -2,6 +2,7 @@
// @generated
extern crate alloc;
use super::*;
+
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
::flatbuffers::bitflags::bitflags! {
@@ -13,10 +14,12 @@
}
}
}
+
pub use self::bitflags_long_enum::LongEnum;
impl<'a> ::flatbuffers::Follow<'a> for LongEnum {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
@@ -26,6 +29,7 @@
impl ::flatbuffers::Push for LongEnum {
type Output = LongEnum;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u64>(dst, self.bits()) };
@@ -34,10 +38,12 @@
impl ::flatbuffers::EndianScalar for LongEnum {
type Scalar = u64;
+
#[inline]
fn to_little_endian(self) -> u64 {
self.bits().to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u64) -> Self {
diff --git a/tests/monster_test/my_game/example/monster_generated.rs b/tests/monster_test/my_game/example/monster_generated.rs
index db44ea5..34aaac6 100644
--- a/tests/monster_test/my_game/example/monster_generated.rs
+++ b/tests/monster_test/my_game/example/monster_generated.rs
@@ -2,16 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
pub enum MonsterOffset {}
-#[derive(Copy, Clone, PartialEq)]
/// an example documentation comment: "monster object"
+#[derive(Copy, Clone, PartialEq)]
pub struct Monster<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -89,6 +91,7 @@
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>,
@@ -394,6 +397,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
+
#[inline]
pub fn mana(&self) -> i16 {
// Safety:
@@ -401,6 +405,7 @@
// 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:
@@ -408,6 +413,7 @@
// 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:
@@ -415,6 +421,7 @@
// 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()
@@ -425,6 +432,7 @@
let key = self.name();
key.cmp(val)
}
+
#[inline]
pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
// Safety:
@@ -432,6 +440,7 @@
// 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:
@@ -439,6 +448,7 @@
// 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:
@@ -446,6 +456,7 @@
// 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:
@@ -453,6 +464,7 @@
// 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:
@@ -460,6 +472,7 @@
// 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:
@@ -467,6 +480,7 @@
// 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]
@@ -476,6 +490,7 @@
// 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:
@@ -483,6 +498,7 @@
// 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:
@@ -490,6 +506,7 @@
// 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;
@@ -499,6 +516,7 @@
unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
})
}
+
#[inline]
pub fn testempty(&self) -> Option<Stat<'a>> {
// Safety:
@@ -506,6 +524,7 @@
// 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:
@@ -513,6 +532,7 @@
// 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:
@@ -520,6 +540,7 @@
// 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:
@@ -527,6 +548,7 @@
// 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:
@@ -534,6 +556,7 @@
// 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:
@@ -541,6 +564,7 @@
// 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:
@@ -548,6 +572,7 @@
// 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:
@@ -555,6 +580,7 @@
// 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:
@@ -562,6 +588,7 @@
// 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:
@@ -569,6 +596,7 @@
// 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:
@@ -576,6 +604,7 @@
// 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:
@@ -583,6 +612,7 @@
// 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:
@@ -590,6 +620,7 @@
// 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:
@@ -597,6 +628,7 @@
// 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:
@@ -604,6 +636,7 @@
// 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:
@@ -611,6 +644,7 @@
// 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:
@@ -618,6 +652,7 @@
// 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:
@@ -625,6 +660,7 @@
// 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:
@@ -632,6 +668,7 @@
// 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:
@@ -639,6 +676,7 @@
// 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:
@@ -646,6 +684,7 @@
// 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:
@@ -653,6 +692,7 @@
// 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:
@@ -660,6 +700,7 @@
// 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:
@@ -667,6 +708,7 @@
// 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:
@@ -674,6 +716,7 @@
// 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:
@@ -681,6 +724,7 @@
// 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:
@@ -688,6 +732,7 @@
// 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:
@@ -695,6 +740,7 @@
// 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:
@@ -702,6 +748,7 @@
// 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:
@@ -709,6 +756,7 @@
// 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:
@@ -716,6 +764,7 @@
// 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:
@@ -723,6 +772,7 @@
// 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:
@@ -730,6 +780,7 @@
// 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:
@@ -737,6 +788,7 @@
// 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:
@@ -744,6 +796,7 @@
// 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:
@@ -751,6 +804,7 @@
// 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;
@@ -760,6 +814,7 @@
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:
@@ -767,6 +822,7 @@
// 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:
@@ -774,6 +830,7 @@
// 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:
@@ -781,6 +838,7 @@
// 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:
@@ -788,6 +846,7 @@
// 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:
@@ -795,6 +854,7 @@
// 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:
@@ -802,6 +862,7 @@
// 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:
@@ -809,6 +870,7 @@
// 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:
@@ -816,6 +878,7 @@
// 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:
@@ -823,6 +886,7 @@
// 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:
@@ -830,6 +894,7 @@
// 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:
@@ -837,6 +902,7 @@
// 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:
@@ -844,6 +910,7 @@
// 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>> {
@@ -978,7 +1045,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for Monster<'_> {
@@ -1070,6 +1136,7 @@
Ok(())
}
}
+
pub struct MonsterArgs<'a> {
pub pos: Option<&'a Vec3>,
pub mana: i16,
@@ -1133,6 +1200,7 @@
pub negative_infinity_default: f32,
pub double_inf_default: f64,
}
+
impl<'a> Default for MonsterArgs<'a> {
#[inline]
fn default() -> Self {
@@ -1206,251 +1274,313 @@
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();
@@ -1459,6 +1589,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -1612,6 +1743,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
@@ -1674,6 +1806,7 @@
pub negative_infinity_default: f32,
pub double_inf_default: f64,
}
+
impl Default for MonsterT {
fn default() -> Self {
Self {
@@ -1738,6 +1871,7 @@
}
}
}
+
impl MonsterT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -1920,66 +2054,73 @@
})
}
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a `Monster`
/// 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root::<Monster>(buf)
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a size prefixed
/// `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root::<Monster>(buf)
}
-#[inline]
+
/// Verifies, with the given options, that a buffer of bytes
/// contains a `Monster` 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
+#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
+#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
+
pub const MONSTER_IDENTIFIER: &str = "MONS";
#[inline]
diff --git a/tests/monster_test/my_game/example/race_generated.rs b/tests/monster_test/my_game/example/race_generated.rs
index 095647f..013ceb3 100644
--- a/tests/monster_test/my_game/example/race_generated.rs
+++ b/tests/monster_test/my_game/example/race_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_RACE: i8 = -1;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_RACE: i8 = 2;
+
#[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] = [
@@ -18,6 +21,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Race(pub i8);
+
#[allow(non_upper_case_globals)]
impl Race {
pub const None: Self = Self(-1);
@@ -33,6 +37,7 @@
Self::Dwarf,
Self::Elf,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -44,6 +49,7 @@
}
}
}
+
impl ::core::fmt::Debug for Race {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -53,8 +59,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for Race {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -64,6 +72,7 @@
impl ::flatbuffers::Push for Race {
type Output = Race;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -72,10 +81,12 @@
impl ::flatbuffers::EndianScalar for Race {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
diff --git a/tests/monster_test/my_game/example/referrable_generated.rs b/tests/monster_test/my_game/example/referrable_generated.rs
index 08e1f84..09832db 100644
--- a/tests/monster_test/my_game/example/referrable_generated.rs
+++ b/tests/monster_test/my_game/example/referrable_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum ReferrableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum ReferrableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Referrable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Referrable<'a> {
type Inner = Referrable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -52,6 +55,7 @@
// 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()
@@ -75,9 +79,11 @@
Ok(())
}
}
+
pub struct ReferrableArgs {
pub id: u64,
}
+
impl<'a> Default for ReferrableArgs {
#[inline]
fn default() -> Self {
@@ -91,11 +97,13 @@
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();
@@ -104,6 +112,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -118,11 +127,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ReferrableT {
pub id: u64,
}
+
impl Default for ReferrableT {
fn default() -> Self {
Self {
@@ -130,6 +141,7 @@
}
}
}
+
impl ReferrableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/monster_test/my_game/example/stat_generated.rs b/tests/monster_test/my_game/example/stat_generated.rs
index 5f33035..223631b 100644
--- a/tests/monster_test/my_game/example/stat_generated.rs
+++ b/tests/monster_test/my_game/example/stat_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum StatOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum StatOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Stat<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Stat<'a> {
type Inner = Stat<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -30,6 +32,7 @@
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>,
@@ -62,6 +65,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
}
+
#[inline]
pub fn val(&self) -> i64 {
// Safety:
@@ -69,6 +73,7 @@
// 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:
@@ -76,6 +81,7 @@
// 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()
@@ -101,11 +107,13 @@
Ok(())
}
}
+
pub struct StatArgs<'a> {
pub id: Option<::flatbuffers::WIPOffset<&'a str>>,
pub val: i64,
pub count: u16,
}
+
impl<'a> Default for StatArgs<'a> {
#[inline]
fn default() -> Self {
@@ -121,19 +129,23 @@
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();
@@ -142,6 +154,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -158,6 +171,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct StatT {
@@ -165,6 +179,7 @@
pub val: i64,
pub count: u16,
}
+
impl Default for StatT {
fn default() -> Self {
Self {
@@ -174,6 +189,7 @@
}
}
}
+
impl StatT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 05d1a4f..b957d26 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct StructOfStructs, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructs(pub [u8; 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")
@@ -22,27 +25,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
+
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs {
type Inner = &'a StructOfStructs;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructOfStructs>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for StructOfStructs {
type Output = StructOfStructs;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -127,6 +137,7 @@
pub b: TestT,
pub c: AbilityT,
}
+
impl StructOfStructsT {
pub fn pack(&self) -> StructOfStructs {
StructOfStructs::new(
@@ -136,4 +147,3 @@
)
}
}
-
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 a0fd055..34a4832 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct StructOfStructsOfStructs, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructsOfStructs(pub [u8; 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")
@@ -20,27 +23,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {}
+
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructsOfStructs {
type Inner = &'a StructOfStructsOfStructs;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs {
type Output = StructOfStructsOfStructs;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -93,6 +103,7 @@
pub struct StructOfStructsOfStructsT {
pub a: StructOfStructsT,
}
+
impl StructOfStructsOfStructsT {
pub fn pack(&self) -> StructOfStructsOfStructs {
StructOfStructsOfStructs::new(
@@ -100,4 +111,3 @@
)
}
}
-
diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs
index 178cbe9..a5984a9 100644
--- a/tests/monster_test/my_game/example/test_generated.rs
+++ b/tests/monster_test/my_game/example/test_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct Test, aligned to 2
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Test(pub [u8; 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")
@@ -21,27 +24,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Test {}
+
impl<'a> ::flatbuffers::Follow<'a> for Test {
type Inner = &'a Test;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Test>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for Test {
type Output = Test;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Test as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(2)
@@ -144,6 +154,7 @@
pub a: i16,
pub b: i8,
}
+
impl TestT {
pub fn pack(&self) -> Test {
Test::new(
@@ -152,4 +163,3 @@
)
}
}
-
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 c264d49..d00ad65 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TestSimpleTableWithEnumOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TestSimpleTableWithEnumOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TestSimpleTableWithEnum<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> {
type Inner = TestSimpleTableWithEnum<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -65,9 +68,11 @@
Ok(())
}
}
+
pub struct TestSimpleTableWithEnumArgs {
pub color: Color,
}
+
impl<'a> Default for TestSimpleTableWithEnumArgs {
#[inline]
fn default() -> Self {
@@ -81,11 +86,13 @@
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();
@@ -94,6 +101,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -108,11 +116,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TestSimpleTableWithEnumT {
pub color: Color,
}
+
impl Default for TestSimpleTableWithEnumT {
fn default() -> Self {
Self {
@@ -120,6 +130,7 @@
}
}
}
+
impl TestSimpleTableWithEnumT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 b7788eb..9ef6c10 100644
--- a/tests/monster_test/my_game/example/type_aliases_generated.rs
+++ b/tests/monster_test/my_game/example/type_aliases_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TypeAliasesOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TypeAliasesOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TypeAliases<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TypeAliases<'a> {
type Inner = TypeAliases<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -39,6 +41,7 @@
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>,
@@ -100,6 +103,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u8_(&self) -> u8 {
// Safety:
@@ -107,6 +111,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i16_(&self) -> i16 {
// Safety:
@@ -114,6 +119,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u16_(&self) -> u16 {
// Safety:
@@ -121,6 +127,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i32_(&self) -> i32 {
// Safety:
@@ -128,6 +135,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u32_(&self) -> u32 {
// Safety:
@@ -135,6 +143,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i64_(&self) -> i64 {
// Safety:
@@ -142,6 +151,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u64_(&self) -> u64 {
// Safety:
@@ -149,6 +159,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
}
+
#[inline]
pub fn f32_(&self) -> f32 {
// Safety:
@@ -156,6 +167,7 @@
// 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:
@@ -163,6 +175,7 @@
// 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:
@@ -170,6 +183,7 @@
// 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:
@@ -201,6 +215,7 @@
Ok(())
}
}
+
pub struct TypeAliasesArgs<'a> {
pub i8_: i8,
pub u8_: u8,
@@ -215,6 +230,7 @@
pub v8: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>,
pub vf64: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>,
}
+
impl<'a> Default for TypeAliasesArgs<'a> {
#[inline]
fn default() -> Self {
@@ -239,55 +255,68 @@
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();
@@ -296,6 +325,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -321,6 +351,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TypeAliasesT {
@@ -337,6 +368,7 @@
pub v8: Option<alloc::vec::Vec<i8>>,
pub vf64: Option<alloc::vec::Vec<f64>>,
}
+
impl Default for TypeAliasesT {
fn default() -> Self {
Self {
@@ -355,6 +387,7 @@
}
}
}
+
impl TypeAliasesT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 2b2872b..1a2c4cd 100644
--- a/tests/monster_test/my_game/example/vec_3_generated.rs
+++ b/tests/monster_test/my_game/example/vec_3_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct Vec3, aligned to 8
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 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")
@@ -25,27 +28,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
+
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
type Inner = &'a Vec3;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Vec3>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
type Inner = &'a Vec3;
+
#[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 {
type Output = Vec3;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(8)
@@ -263,6 +273,7 @@
pub test2: Color,
pub test3: TestT,
}
+
impl Vec3T {
pub fn pack(&self) -> Vec3 {
Vec3::new(
@@ -275,4 +286,3 @@
)
}
}
-
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 7e2409f..6e142f1 100644
--- a/tests/monster_test/my_game/example_2/monster_generated.rs
+++ b/tests/monster_test/my_game/example_2/monster_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum MonsterOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum MonsterOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Monster<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> Monster<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"MyGame.Example2.Monster"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct MonsterArgs {
}
+
impl<'a> Default for MonsterArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
}
+
impl Default for MonsterT {
fn default() -> Self {
Self {
}
}
}
+
impl MonsterT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 7bcb4be..9911d3d 100644
--- a/tests/monster_test/my_game/in_parent_namespace_generated.rs
+++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum InParentNamespaceOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum InParentNamespaceOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct InParentNamespace<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for InParentNamespace<'a> {
type Inner = InParentNamespace<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> InParentNamespace<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"MyGame.InParentNamespace"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct InParentNamespaceArgs {
}
+
impl<'a> Default for InParentNamespaceArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct InParentNamespaceT {
}
+
impl Default for InParentNamespaceT {
fn default() -> Self {
Self {
}
}
}
+
impl InParentNamespaceT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 5eb9adc..4e03e2d 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
+
#[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.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
@@ -15,6 +18,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FromInclude(pub i64);
+
#[allow(non_upper_case_globals)]
impl FromInclude {
pub const IncludeVal: Self = Self(0);
@@ -24,6 +28,7 @@
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 {
@@ -32,6 +37,7 @@
}
}
}
+
impl ::core::fmt::Debug for FromInclude {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -41,8 +47,10 @@
}
}
}
+
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) };
@@ -52,6 +60,7 @@
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) };
@@ -60,10 +69,12 @@
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 {
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 19a3e66..5e969c2 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableBOffset {}
-#[derive(Copy, Clone, PartialEq)]
+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) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableBArgs<'a> {
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
+
impl<'a> Default for TableBArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
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 {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableBT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 b90fb89..e8639ac 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// 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")
@@ -20,27 +23,34 @@
}
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)
@@ -110,6 +120,7 @@
pub struct UnusedT {
pub a: i32,
}
+
impl UnusedT {
pub fn pack(&self) -> Unused {
Unused::new(
@@ -117,4 +128,3 @@
)
}
}
-
diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs
index ca29250..2558b84 100644
--- a/tests/monster_test/table_a_generated.rs
+++ b/tests/monster_test/table_a_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableAOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 eb98460..1e1aebc 100644
--- a/tests/monster_test_serialize/my_game/example/ability_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/ability_generated.rs
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// struct Ability, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Ability(pub [u8; 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")
@@ -23,27 +26,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Ability {}
+
impl<'a> ::flatbuffers::Follow<'a> for Ability {
type Inner = &'a Ability;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Ability>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for Ability {
type Output = Ability;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Ability as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -116,6 +126,7 @@
}
}
+
#[inline]
pub fn key_compare_less_than(&self, o: &Ability) -> bool {
self.id() < o.id()
@@ -168,6 +179,7 @@
pub id: u32,
pub distance: u32,
}
+
impl AbilityT {
pub fn pack(&self) -> Ability {
Ability::new(
@@ -176,4 +188,3 @@
)
}
}
-
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 647e854..ec6c62c 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
@@ -4,10 +4,13 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY_AMBIGUOUS_ALIASES: u8 = 3;
+
#[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] = [
@@ -20,6 +23,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct AnyAmbiguousAliases(pub u8);
+
#[allow(non_upper_case_globals)]
impl AnyAmbiguousAliases {
pub const NONE: Self = Self(0);
@@ -35,6 +39,7 @@
Self::M2,
Self::M3,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -46,6 +51,7 @@
}
}
}
+
impl ::core::fmt::Debug for AnyAmbiguousAliases {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -55,6 +61,7 @@
}
}
}
+
impl Serialize for AnyAmbiguousAliases {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -85,6 +92,7 @@
impl<'a> ::flatbuffers::Follow<'a> for AnyAmbiguousAliases {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -94,6 +102,7 @@
impl ::flatbuffers::Push for AnyAmbiguousAliases {
type Output = AnyAmbiguousAliases;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -102,10 +111,12 @@
impl ::flatbuffers::EndianScalar for AnyAmbiguousAliases {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -124,6 +135,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
+
pub struct AnyAmbiguousAliasesUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -135,11 +147,13 @@
M2(alloc::boxed::Box<MonsterT>),
M3(alloc::boxed::Box<MonsterT>),
}
+
impl Default for AnyAmbiguousAliasesT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyAmbiguousAliasesT {
pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
match self {
@@ -149,6 +163,7 @@
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,
@@ -157,6 +172,7 @@
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 {
@@ -170,14 +186,17 @@
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 {
@@ -191,14 +210,17 @@
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 {
@@ -212,12 +234,15 @@
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 f5b40b5..0f5be1a 100644
--- a/tests/monster_test_serialize/my_game/example/any_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/any_generated.rs
@@ -4,10 +4,13 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY: u8 = 3;
+
#[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] = [
@@ -20,6 +23,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Any(pub u8);
+
#[allow(non_upper_case_globals)]
impl Any {
pub const NONE: Self = Self(0);
@@ -35,6 +39,7 @@
Self::TestSimpleTableWithEnum,
Self::MyGame_Example2_Monster,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -46,6 +51,7 @@
}
}
}
+
impl ::core::fmt::Debug for Any {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -55,6 +61,7 @@
}
}
}
+
impl Serialize for Any {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -85,6 +92,7 @@
impl<'a> ::flatbuffers::Follow<'a> for Any {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -94,6 +102,7 @@
impl ::flatbuffers::Push for Any {
type Output = Any;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -102,10 +111,12 @@
impl ::flatbuffers::EndianScalar for Any {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -124,6 +135,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
+
pub struct AnyUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -135,11 +147,13 @@
TestSimpleTableWithEnum(alloc::boxed::Box<TestSimpleTableWithEnumT>),
MyGameExample2Monster(alloc::boxed::Box<super::example_2::MonsterT>),
}
+
impl Default for AnyT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyT {
pub fn any_type(&self) -> Any {
match self {
@@ -149,6 +163,7 @@
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,
@@ -157,6 +172,7 @@
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 {
@@ -170,14 +186,17 @@
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 {
@@ -191,14 +210,17 @@
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 {
@@ -212,12 +234,15 @@
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 2128e47..067f2f6 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
@@ -4,10 +4,13 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY_UNIQUE_ALIASES: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY_UNIQUE_ALIASES: u8 = 3;
+
#[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] = [
@@ -20,6 +23,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct AnyUniqueAliases(pub u8);
+
#[allow(non_upper_case_globals)]
impl AnyUniqueAliases {
pub const NONE: Self = Self(0);
@@ -35,6 +39,7 @@
Self::TS,
Self::M2,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -46,6 +51,7 @@
}
}
}
+
impl ::core::fmt::Debug for AnyUniqueAliases {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -55,6 +61,7 @@
}
}
}
+
impl Serialize for AnyUniqueAliases {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -85,6 +92,7 @@
impl<'a> ::flatbuffers::Follow<'a> for AnyUniqueAliases {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -94,6 +102,7 @@
impl ::flatbuffers::Push for AnyUniqueAliases {
type Output = AnyUniqueAliases;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -102,10 +111,12 @@
impl ::flatbuffers::EndianScalar for AnyUniqueAliases {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -124,6 +135,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {}
+
pub struct AnyUniqueAliasesUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -135,11 +147,13 @@
TS(alloc::boxed::Box<TestSimpleTableWithEnumT>),
M2(alloc::boxed::Box<super::example_2::MonsterT>),
}
+
impl Default for AnyUniqueAliasesT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyUniqueAliasesT {
pub fn any_unique_aliases_type(&self) -> AnyUniqueAliases {
match self {
@@ -149,6 +163,7 @@
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,
@@ -157,6 +172,7 @@
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 {
@@ -170,14 +186,17 @@
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 {
@@ -191,14 +210,17 @@
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 {
@@ -212,12 +234,15 @@
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 5a54061..bfcfd83 100644
--- a/tests/monster_test_serialize/my_game/example/color_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/color_generated.rs
@@ -4,6 +4,7 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[allow(non_upper_case_globals)]
mod bitflags_color {
::flatbuffers::bitflags::bitflags! {
@@ -19,6 +20,7 @@
}
}
}
+
pub use self::bitflags_color::Color;
impl Serialize for Color {
@@ -32,6 +34,7 @@
impl<'a> ::flatbuffers::Follow<'a> for Color {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -41,6 +44,7 @@
impl ::flatbuffers::Push for Color {
type Output = Color;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.bits()) };
@@ -49,10 +53,12 @@
impl ::flatbuffers::EndianScalar for Color {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.bits().to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
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 bff530a..0d00716 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
@@ -4,6 +4,7 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[allow(non_upper_case_globals)]
mod bitflags_long_enum {
::flatbuffers::bitflags::bitflags! {
@@ -15,6 +16,7 @@
}
}
}
+
pub use self::bitflags_long_enum::LongEnum;
impl Serialize for LongEnum {
@@ -28,6 +30,7 @@
impl<'a> ::flatbuffers::Follow<'a> for LongEnum {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u64>(buf, loc) };
@@ -37,6 +40,7 @@
impl ::flatbuffers::Push for LongEnum {
type Output = LongEnum;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u64>(dst, self.bits()) };
@@ -45,10 +49,12 @@
impl ::flatbuffers::EndianScalar for LongEnum {
type Scalar = u64;
+
#[inline]
fn to_little_endian(self) -> u64 {
self.bits().to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u64) -> Self {
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 749098f..1f8128c 100644
--- a/tests/monster_test_serialize/my_game/example/monster_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/monster_generated.rs
@@ -4,16 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
pub enum MonsterOffset {}
-#[derive(Copy, Clone, PartialEq)]
/// an example documentation comment: "monster object"
+#[derive(Copy, Clone, PartialEq)]
pub struct Monster<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -91,6 +93,7 @@
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>,
@@ -396,6 +399,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<Vec3>(Monster::VT_POS, None)}
}
+
#[inline]
pub fn mana(&self) -> i16 {
// Safety:
@@ -403,6 +407,7 @@
// 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:
@@ -410,6 +415,7 @@
// 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:
@@ -417,6 +423,7 @@
// 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()
@@ -427,6 +434,7 @@
let key = self.name();
key.cmp(val)
}
+
#[inline]
pub fn inventory(&self) -> Option<::flatbuffers::Vector<'a, u8>> {
// Safety:
@@ -434,6 +442,7 @@
// 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:
@@ -441,6 +450,7 @@
// 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:
@@ -448,6 +458,7 @@
// 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:
@@ -455,6 +466,7 @@
// 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:
@@ -462,6 +474,7 @@
// 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:
@@ -469,6 +482,7 @@
// 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]
@@ -478,6 +492,7 @@
// 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:
@@ -485,6 +500,7 @@
// 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:
@@ -492,6 +508,7 @@
// 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;
@@ -501,6 +518,7 @@
unsafe { <::flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data.bytes(), 0) }
})
}
+
#[inline]
pub fn testempty(&self) -> Option<Stat<'a>> {
// Safety:
@@ -508,6 +526,7 @@
// 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:
@@ -515,6 +534,7 @@
// 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:
@@ -522,6 +542,7 @@
// 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:
@@ -529,6 +550,7 @@
// 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:
@@ -536,6 +558,7 @@
// 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:
@@ -543,6 +566,7 @@
// 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:
@@ -550,6 +574,7 @@
// 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:
@@ -557,6 +582,7 @@
// 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:
@@ -564,6 +590,7 @@
// 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:
@@ -571,6 +598,7 @@
// 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:
@@ -578,6 +606,7 @@
// 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:
@@ -585,6 +614,7 @@
// 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:
@@ -592,6 +622,7 @@
// 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:
@@ -599,6 +630,7 @@
// 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:
@@ -606,6 +638,7 @@
// 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:
@@ -613,6 +646,7 @@
// 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:
@@ -620,6 +654,7 @@
// 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:
@@ -627,6 +662,7 @@
// 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:
@@ -634,6 +670,7 @@
// 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:
@@ -641,6 +678,7 @@
// 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:
@@ -648,6 +686,7 @@
// 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:
@@ -655,6 +694,7 @@
// 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:
@@ -662,6 +702,7 @@
// 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:
@@ -669,6 +710,7 @@
// 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:
@@ -676,6 +718,7 @@
// 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:
@@ -683,6 +726,7 @@
// 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:
@@ -690,6 +734,7 @@
// 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:
@@ -697,6 +742,7 @@
// 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:
@@ -704,6 +750,7 @@
// 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:
@@ -711,6 +758,7 @@
// 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:
@@ -718,6 +766,7 @@
// 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:
@@ -725,6 +774,7 @@
// 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:
@@ -732,6 +782,7 @@
// 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:
@@ -739,6 +790,7 @@
// 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:
@@ -746,6 +798,7 @@
// 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:
@@ -753,6 +806,7 @@
// 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;
@@ -762,6 +816,7 @@
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:
@@ -769,6 +824,7 @@
// 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:
@@ -776,6 +832,7 @@
// 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:
@@ -783,6 +840,7 @@
// 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:
@@ -790,6 +848,7 @@
// 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:
@@ -797,6 +856,7 @@
// 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:
@@ -804,6 +864,7 @@
// 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:
@@ -811,6 +872,7 @@
// 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:
@@ -818,6 +880,7 @@
// 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:
@@ -825,6 +888,7 @@
// 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:
@@ -832,6 +896,7 @@
// 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:
@@ -839,6 +904,7 @@
// 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:
@@ -846,6 +912,7 @@
// 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>> {
@@ -980,7 +1047,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for Monster<'_> {
@@ -1072,6 +1138,7 @@
Ok(())
}
}
+
pub struct MonsterArgs<'a> {
pub pos: Option<&'a Vec3>,
pub mana: i16,
@@ -1135,6 +1202,7 @@
pub negative_infinity_default: f32,
pub double_inf_default: f64,
}
+
impl<'a> Default for MonsterArgs<'a> {
#[inline]
fn default() -> Self {
@@ -1433,251 +1501,313 @@
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();
@@ -1686,6 +1816,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -1839,6 +1970,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
@@ -1901,6 +2033,7 @@
pub negative_infinity_default: f32,
pub double_inf_default: f64,
}
+
impl Default for MonsterT {
fn default() -> Self {
Self {
@@ -1965,6 +2098,7 @@
}
}
}
+
impl MonsterT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -2147,66 +2281,73 @@
})
}
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a `Monster`
/// 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root::<Monster>(buf)
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a size prefixed
/// `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster(buf: &[u8]) -> Result<Monster<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root::<Monster>(buf)
}
-#[inline]
+
/// Verifies, with the given options, that a buffer of bytes
/// contains a `Monster` 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_monster_unchecked`.
+#[inline]
pub fn root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `Monster` 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_monster_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_monster_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<Monster<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root_with_opts::<Monster<'b>>(opts, buf)
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `Monster`.
+#[inline]
pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { ::flatbuffers::root_unchecked::<Monster>(buf) }
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
+#[inline]
pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster<'_> {
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<Monster>(buf) }
}
+
pub const MONSTER_IDENTIFIER: &str = "MONS";
#[inline]
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 c91c401..1f6de1d 100644
--- a/tests/monster_test_serialize/my_game/example/race_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/race_generated.rs
@@ -4,10 +4,13 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_RACE: i8 = -1;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_RACE: i8 = 2;
+
#[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] = [
@@ -20,6 +23,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct Race(pub i8);
+
#[allow(non_upper_case_globals)]
impl Race {
pub const None: Self = Self(-1);
@@ -35,6 +39,7 @@
Self::Dwarf,
Self::Elf,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -46,6 +51,7 @@
}
}
}
+
impl ::core::fmt::Debug for Race {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -55,6 +61,7 @@
}
}
}
+
impl Serialize for Race {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -85,6 +92,7 @@
impl<'a> ::flatbuffers::Follow<'a> for Race {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -94,6 +102,7 @@
impl ::flatbuffers::Push for Race {
type Output = Race;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -102,10 +111,12 @@
impl ::flatbuffers::EndianScalar for Race {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
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 eed359a..c861df0 100644
--- a/tests/monster_test_serialize/my_game/example/referrable_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/referrable_generated.rs
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum ReferrableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum ReferrableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Referrable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Referrable<'a> {
type Inner = Referrable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -30,6 +32,7 @@
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>,
@@ -54,6 +57,7 @@
// 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()
@@ -77,9 +81,11 @@
Ok(())
}
}
+
pub struct ReferrableArgs {
pub id: u64,
}
+
impl<'a> Default for ReferrableArgs {
#[inline]
fn default() -> Self {
@@ -104,11 +110,13 @@
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();
@@ -117,6 +125,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Referrable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -131,11 +140,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ReferrableT {
pub id: u64,
}
+
impl Default for ReferrableT {
fn default() -> Self {
Self {
@@ -143,6 +154,7 @@
}
}
}
+
impl ReferrableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 af34edb..1d4d43f 100644
--- a/tests/monster_test_serialize/my_game/example/stat_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/stat_generated.rs
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum StatOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum StatOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Stat<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Stat<'a> {
type Inner = Stat<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -32,6 +34,7 @@
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>,
@@ -64,6 +67,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<::flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)}
}
+
#[inline]
pub fn val(&self) -> i64 {
// Safety:
@@ -71,6 +75,7 @@
// 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:
@@ -78,6 +83,7 @@
// 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()
@@ -103,11 +109,13 @@
Ok(())
}
}
+
pub struct StatArgs<'a> {
pub id: Option<::flatbuffers::WIPOffset<&'a str>>,
pub val: i64,
pub count: u16,
}
+
impl<'a> Default for StatArgs<'a> {
#[inline]
fn default() -> Self {
@@ -140,19 +148,23 @@
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();
@@ -161,6 +173,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Stat<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -177,6 +190,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct StatT {
@@ -184,6 +198,7 @@
pub val: i64,
pub count: u16,
}
+
impl Default for StatT {
fn default() -> Self {
Self {
@@ -193,6 +208,7 @@
}
}
}
+
impl StatT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 23236d7..8706562 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
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// struct StructOfStructs, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructs(pub [u8; 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")
@@ -24,27 +27,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
+
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructs {
type Inner = &'a StructOfStructs;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructOfStructs>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for StructOfStructs {
type Output = StructOfStructs;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructOfStructs as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -142,6 +152,7 @@
pub b: TestT,
pub c: AbilityT,
}
+
impl StructOfStructsT {
pub fn pack(&self) -> StructOfStructs {
StructOfStructs::new(
@@ -151,4 +162,3 @@
)
}
}
-
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 0751e5b..dae0180 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
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// struct StructOfStructsOfStructs, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct StructOfStructsOfStructs(pub [u8; 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")
@@ -22,27 +25,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructOfStructsOfStructs {}
+
impl<'a> ::flatbuffers::Follow<'a> for StructOfStructsOfStructs {
type Inner = &'a StructOfStructsOfStructs;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructOfStructsOfStructs>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for StructOfStructsOfStructs {
type Output = StructOfStructsOfStructs;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructOfStructsOfStructs as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -106,6 +116,7 @@
pub struct StructOfStructsOfStructsT {
pub a: StructOfStructsT,
}
+
impl StructOfStructsOfStructsT {
pub fn pack(&self) -> StructOfStructsOfStructs {
StructOfStructsOfStructs::new(
@@ -113,4 +124,3 @@
)
}
}
-
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 b8c2e04..b1e4e2c 100644
--- a/tests/monster_test_serialize/my_game/example/test_generated.rs
+++ b/tests/monster_test_serialize/my_game/example/test_generated.rs
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// struct Test, aligned to 2
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Test(pub [u8; 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")
@@ -23,27 +26,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Test {}
+
impl<'a> ::flatbuffers::Follow<'a> for Test {
type Inner = &'a Test;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Test>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for Test {
type Output = Test;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Test as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(2)
@@ -158,6 +168,7 @@
pub a: i16,
pub b: i8,
}
+
impl TestT {
pub fn pack(&self) -> Test {
Test::new(
@@ -166,4 +177,3 @@
)
}
}
-
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 df0a468..c55e1cb 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
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum TestSimpleTableWithEnumOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TestSimpleTableWithEnumOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TestSimpleTableWithEnum<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> {
type Inner = TestSimpleTableWithEnum<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -30,6 +32,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct TestSimpleTableWithEnumArgs {
pub color: Color,
}
+
impl<'a> Default for TestSimpleTableWithEnumArgs {
#[inline]
fn default() -> Self {
@@ -94,11 +99,13 @@
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();
@@ -107,6 +114,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -121,11 +129,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TestSimpleTableWithEnumT {
pub color: Color,
}
+
impl Default for TestSimpleTableWithEnumT {
fn default() -> Self {
Self {
@@ -133,6 +143,7 @@
}
}
}
+
impl TestSimpleTableWithEnumT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 7ec1728..5c6393f 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
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum TypeAliasesOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TypeAliasesOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TypeAliases<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TypeAliases<'a> {
type Inner = TypeAliases<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -41,6 +43,7 @@
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>,
@@ -102,6 +105,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u8_(&self) -> u8 {
// Safety:
@@ -109,6 +113,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i16_(&self) -> i16 {
// Safety:
@@ -116,6 +121,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u16_(&self) -> u16 {
// Safety:
@@ -123,6 +129,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i32_(&self) -> i32 {
// Safety:
@@ -130,6 +137,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u32_(&self) -> u32 {
// Safety:
@@ -137,6 +145,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()}
}
+
#[inline]
pub fn i64_(&self) -> i64 {
// Safety:
@@ -144,6 +153,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()}
}
+
#[inline]
pub fn u64_(&self) -> u64 {
// Safety:
@@ -151,6 +161,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()}
}
+
#[inline]
pub fn f32_(&self) -> f32 {
// Safety:
@@ -158,6 +169,7 @@
// 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:
@@ -165,6 +177,7 @@
// 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:
@@ -172,6 +185,7 @@
// 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:
@@ -203,6 +217,7 @@
Ok(())
}
}
+
pub struct TypeAliasesArgs<'a> {
pub i8_: i8,
pub u8_: u8,
@@ -217,6 +232,7 @@
pub v8: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i8>>>,
pub vf64: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f64>>>,
}
+
impl<'a> Default for TypeAliasesArgs<'a> {
#[inline]
fn default() -> Self {
@@ -271,55 +287,68 @@
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();
@@ -328,6 +357,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TypeAliases<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -353,6 +383,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TypeAliasesT {
@@ -369,6 +400,7 @@
pub v8: Option<alloc::vec::Vec<i8>>,
pub vf64: Option<alloc::vec::Vec<f64>>,
}
+
impl Default for TypeAliasesT {
fn default() -> Self {
Self {
@@ -387,6 +419,7 @@
}
}
}
+
impl TypeAliasesT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 a1afa82..f92107d 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
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// struct Vec3, aligned to 8
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct Vec3(pub [u8; 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")
@@ -27,27 +30,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Vec3 {}
+
impl<'a> ::flatbuffers::Follow<'a> for Vec3 {
type Inner = &'a Vec3;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Vec3>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'a Vec3 {
type Inner = &'a Vec3;
+
#[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 {
type Output = Vec3;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Vec3 as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(8)
@@ -281,6 +291,7 @@
pub test2: Color,
pub test3: TestT,
}
+
impl Vec3T {
pub fn pack(&self) -> Vec3 {
Vec3::new(
@@ -293,4 +304,3 @@
)
}
}
-
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 4faf310..cef325d 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
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum MonsterOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum MonsterOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct Monster<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Monster<'a> {
type Inner = Monster<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -20,7 +22,6 @@
}
impl<'a> Monster<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"MyGame.Example2.Monster"
}
@@ -29,6 +30,7 @@
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>,
@@ -54,8 +56,10 @@
Ok(())
}
}
+
pub struct MonsterArgs {
}
+
impl<'a> Default for MonsterArgs {
#[inline]
fn default() -> Self {
@@ -78,6 +82,7 @@
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> {
@@ -87,6 +92,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Monster<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -100,16 +106,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MonsterT {
}
+
impl Default for MonsterT {
fn default() -> Self {
Self {
}
}
}
+
impl MonsterT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 2f3723e..19d3fdf 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
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum InParentNamespaceOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum InParentNamespaceOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct InParentNamespace<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for InParentNamespace<'a> {
type Inner = InParentNamespace<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -20,7 +22,6 @@
}
impl<'a> InParentNamespace<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"MyGame.InParentNamespace"
}
@@ -29,6 +30,7 @@
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>,
@@ -54,8 +56,10 @@
Ok(())
}
}
+
pub struct InParentNamespaceArgs {
}
+
impl<'a> Default for InParentNamespaceArgs {
#[inline]
fn default() -> Self {
@@ -78,6 +82,7 @@
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> {
@@ -87,6 +92,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<InParentNamespace<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -100,16 +106,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct InParentNamespaceT {
}
+
impl Default for InParentNamespaceT {
fn default() -> Self {
Self {
}
}
}
+
impl InParentNamespaceT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 84d5602..fb89543 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
@@ -4,10 +4,13 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
+
#[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.")]
#[allow(non_camel_case_types)]
pub const ENUM_VALUES_FROM_INCLUDE: [FromInclude; 1] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FromInclude(pub i64);
+
#[allow(non_upper_case_globals)]
impl FromInclude {
pub const IncludeVal: Self = Self(0);
@@ -26,6 +30,7 @@
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 {
@@ -34,6 +39,7 @@
}
}
}
+
impl ::core::fmt::Debug for FromInclude {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -43,6 +49,7 @@
}
}
}
+
impl Serialize for FromInclude {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
@@ -73,6 +80,7 @@
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) };
@@ -82,6 +90,7 @@
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) };
@@ -90,10 +99,12 @@
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 {
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 ecb57c5..9a7eb88 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
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum TableBOffset {}
-#[derive(Copy, Clone, PartialEq)]
+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) } }
@@ -30,6 +32,7 @@
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>,
@@ -69,9 +72,11 @@
Ok(())
}
}
+
pub struct TableBArgs<'a> {
pub a: Option<::flatbuffers::WIPOffset<super::super::TableA<'a>>>,
}
+
impl<'a> Default for TableBArgs<'a> {
#[inline]
fn default() -> Self {
@@ -100,11 +105,13 @@
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();
@@ -113,6 +120,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableB<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -127,11 +135,13 @@
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 {
@@ -139,6 +149,7 @@
}
}
}
+
impl TableBT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 0d5f224..03491e2 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
@@ -4,15 +4,18 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
+
// 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")
@@ -22,27 +25,34 @@
}
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)
@@ -123,6 +133,7 @@
pub struct UnusedT {
pub a: i32,
}
+
impl UnusedT {
pub fn pack(&self) -> Unused {
Unused::new(
@@ -130,4 +141,3 @@
)
}
}
-
diff --git a/tests/monster_test_serialize/table_a_generated.rs b/tests/monster_test_serialize/table_a_generated.rs
index a3c1ba6..1f8a709 100644
--- a/tests/monster_test_serialize/table_a_generated.rs
+++ b/tests/monster_test_serialize/table_a_generated.rs
@@ -4,15 +4,17 @@
extern crate serde;
use self::serde::ser::{Serialize, Serializer, SerializeStruct};
use super::*;
-pub enum TableAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableAOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableA<'a> {
type Inner = TableA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -30,6 +32,7 @@
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>,
@@ -69,9 +72,11 @@
Ok(())
}
}
+
pub struct TableAArgs<'a> {
pub b: Option<::flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
}
+
impl<'a> Default for TableAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -100,11 +105,13 @@
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();
@@ -113,6 +120,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -127,11 +135,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableAT {
pub b: Option<alloc::boxed::Box<my_game::other_name_space::TableBT>>,
}
+
impl Default for TableAT {
fn default() -> Self {
Self {
@@ -139,6 +149,7 @@
}
}
}
+
impl TableAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/more_defaults/abc_generated.rs b/tests/more_defaults/abc_generated.rs
index c41b406..a3c54fb 100644
--- a/tests/more_defaults/abc_generated.rs
+++ b/tests/more_defaults/abc_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ABC: i32 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ABC: i32 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct ABC(pub i32);
+
#[allow(non_upper_case_globals)]
impl ABC {
pub const A: Self = Self(0);
@@ -30,6 +34,7 @@
Self::B,
Self::C,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for ABC {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for ABC {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i32>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for ABC {
type Output = ABC;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i32>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for ABC {
type Scalar = i32;
+
#[inline]
fn to_little_endian(self) -> i32 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i32) -> Self {
diff --git a/tests/more_defaults/more_defaults_generated.rs b/tests/more_defaults/more_defaults_generated.rs
index 72dd9db..784297c 100644
--- a/tests/more_defaults/more_defaults_generated.rs
+++ b/tests/more_defaults/more_defaults_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum MoreDefaultsOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum MoreDefaultsOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct MoreDefaults<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for MoreDefaults<'a> {
type Inner = MoreDefaults<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -33,6 +35,7 @@
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>,
@@ -90,6 +93,7 @@
// 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 floats(&self) -> ::flatbuffers::Vector<'a, f32> {
// Safety:
@@ -97,6 +101,7 @@
// 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 empty_string(&self) -> &'a str {
// Safety:
@@ -104,6 +109,7 @@
// 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:
@@ -111,6 +117,7 @@
// 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:
@@ -118,6 +125,7 @@
// 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:
@@ -143,6 +151,7 @@
Ok(())
}
}
+
pub struct MoreDefaultsArgs<'a> {
pub ints: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, i32>>>,
pub floats: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, f32>>>,
@@ -151,6 +160,7 @@
pub abcs: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, ABC>>>,
pub bools: Option<::flatbuffers::WIPOffset<::flatbuffers::Vector<'a, bool>>>,
}
+
impl<'a> Default for MoreDefaultsArgs<'a> {
#[inline]
fn default() -> Self {
@@ -169,31 +179,38 @@
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();
@@ -202,6 +219,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<MoreDefaults<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -221,6 +239,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct MoreDefaultsT {
@@ -231,6 +250,7 @@
pub abcs: alloc::vec::Vec<ABC>,
pub bools: alloc::vec::Vec<bool>,
}
+
impl Default for MoreDefaultsT {
fn default() -> Self {
Self {
@@ -243,6 +263,7 @@
}
}
}
+
impl MoreDefaultsT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 51724c6..54b79c1 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ENUM_IN_NESTED_NS: i8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ENUM_IN_NESTED_NS: i8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct EnumInNestedNS(pub i8);
+
#[allow(non_upper_case_globals)]
impl EnumInNestedNS {
pub const A: Self = Self(0);
@@ -30,6 +34,7 @@
Self::B,
Self::C,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for EnumInNestedNS {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for EnumInNestedNS {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for EnumInNestedNS {
type Output = EnumInNestedNS;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for EnumInNestedNS {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
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 b6b8c38..75d1909 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct StructInNestedNS, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct StructInNestedNS(pub [u8; 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")
@@ -21,27 +24,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for StructInNestedNS {}
+
impl<'a> ::flatbuffers::Follow<'a> for StructInNestedNS {
type Inner = &'a StructInNestedNS;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a StructInNestedNS>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for StructInNestedNS {
type Output = StructInNestedNS;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const StructInNestedNS as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -144,6 +154,7 @@
pub a: i32,
pub b: i32,
}
+
impl StructInNestedNST {
pub fn pack(&self) -> StructInNestedNS {
StructInNestedNS::new(
@@ -152,4 +163,3 @@
)
}
}
-
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 e90a749..856ae6e 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableInNestedNSOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableInNestedNSOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableInNestedNS<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableInNestedNS<'a> {
type Inner = TableInNestedNS<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -65,9 +68,11 @@
Ok(())
}
}
+
pub struct TableInNestedNSArgs {
pub foo: i32,
}
+
impl<'a> Default for TableInNestedNSArgs {
#[inline]
fn default() -> Self {
@@ -81,11 +86,13 @@
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();
@@ -94,6 +101,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInNestedNS<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -108,11 +116,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInNestedNST {
pub foo: i32,
}
+
impl Default for TableInNestedNST {
fn default() -> Self {
Self {
@@ -120,6 +130,7 @@
}
}
}
+
impl TableInNestedNST {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 3e636d1..87ea03a 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_UNION_IN_NESTED_NS: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_UNION_IN_NESTED_NS: u8 = 1;
+
#[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] = [
@@ -16,6 +19,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct UnionInNestedNS(pub u8);
+
#[allow(non_upper_case_globals)]
impl UnionInNestedNS {
pub const NONE: Self = Self(0);
@@ -27,6 +31,7 @@
Self::NONE,
Self::TableInNestedNS,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -36,6 +41,7 @@
}
}
}
+
impl ::core::fmt::Debug for UnionInNestedNS {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -45,8 +51,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for UnionInNestedNS {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -56,6 +64,7 @@
impl ::flatbuffers::Push for UnionInNestedNS {
type Output = UnionInNestedNS;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -64,10 +73,12 @@
impl ::flatbuffers::EndianScalar for UnionInNestedNS {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -86,6 +97,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for UnionInNestedNS {}
+
pub struct UnionInNestedNSUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -95,11 +107,13 @@
NONE,
TableInNestedNS(alloc::boxed::Box<TableInNestedNST>),
}
+
impl Default for UnionInNestedNST {
fn default() -> Self {
Self::NONE
}
}
+
impl UnionInNestedNST {
pub fn union_in_nested_ns_type(&self) -> UnionInNestedNS {
match self {
@@ -107,12 +121,14 @@
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()),
}
}
+
/// 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 {
@@ -126,12 +142,15 @@
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 }
}
}
+
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 d4a2abf..2e30045 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum SecondTableInAOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum SecondTableInAOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct SecondTableInA<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for SecondTableInA<'a> {
type Inner = SecondTableInA<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -67,9 +70,11 @@
Ok(())
}
}
+
pub struct SecondTableInAArgs<'a> {
pub refer_to_c: Option<::flatbuffers::WIPOffset<super::namespace_c::TableInC<'a>>>,
}
+
impl<'a> Default for SecondTableInAArgs<'a> {
#[inline]
fn default() -> Self {
@@ -83,11 +88,13 @@
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();
@@ -96,6 +103,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<SecondTableInA<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -110,11 +118,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct SecondTableInAT {
pub refer_to_c: Option<alloc::boxed::Box<super::namespace_c::TableInCT>>,
}
+
impl Default for SecondTableInAT {
fn default() -> Self {
Self {
@@ -122,6 +132,7 @@
}
}
}
+
impl SecondTableInAT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 b3d0cfe..3ff5ee2 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableInFirstNSOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableInFirstNSOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableInFirstNS<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableInFirstNS<'a> {
type Inner = TableInFirstNS<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -32,6 +34,7 @@
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>,
@@ -78,6 +81,7 @@
// 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:
@@ -85,6 +89,7 @@
// 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:
@@ -92,6 +97,7 @@
// 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:
@@ -99,6 +105,7 @@
// 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:
@@ -106,6 +113,7 @@
// 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>> {
@@ -120,7 +128,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for TableInFirstNS<'_> {
@@ -142,6 +149,7 @@
Ok(())
}
}
+
pub struct TableInFirstNSArgs<'a> {
pub foo_table: Option<::flatbuffers::WIPOffset<namespace_b::TableInNestedNS<'a>>>,
pub foo_enum: namespace_b::EnumInNestedNS,
@@ -149,6 +157,7 @@
pub foo_union: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
pub foo_struct: Option<&'a namespace_b::StructInNestedNS>,
}
+
impl<'a> Default for TableInFirstNSArgs<'a> {
#[inline]
fn default() -> Self {
@@ -166,27 +175,33 @@
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();
@@ -195,6 +210,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInFirstNS<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -225,6 +241,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct TableInFirstNST {
@@ -233,6 +250,7 @@
pub foo_union: namespace_b::UnionInNestedNST,
pub foo_struct: Option<namespace_b::StructInNestedNST>,
}
+
impl Default for TableInFirstNST {
fn default() -> Self {
Self {
@@ -243,6 +261,7 @@
}
}
}
+
impl TableInFirstNST {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 f1e2e66..df3c80e 100644
--- a/tests/namespace_test/namespace_c/table_in_c_generated.rs
+++ b/tests/namespace_test/namespace_c/table_in_c_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum TableInCOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum TableInCOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct TableInC<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for TableInC<'a> {
type Inner = TableInC<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@
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>,
@@ -60,6 +63,7 @@
// 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:
@@ -81,10 +85,12 @@
Ok(())
}
}
+
pub struct TableInCArgs<'a> {
pub refer_to_a1: Option<::flatbuffers::WIPOffset<super::namespace_a::TableInFirstNS<'a>>>,
pub refer_to_a2: Option<::flatbuffers::WIPOffset<super::namespace_a::SecondTableInA<'a>>>,
}
+
impl<'a> Default for TableInCArgs<'a> {
#[inline]
fn default() -> Self {
@@ -99,15 +105,18 @@
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();
@@ -116,6 +125,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<TableInC<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -131,12 +141,14 @@
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>>,
}
+
impl Default for TableInCT {
fn default() -> Self {
Self {
@@ -145,6 +157,7 @@
}
}
}
+
impl TableInCT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
index a0b1c4d..72026c4 100644
--- a/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
+++ b/tests/optional_scalars/optional_scalars/optional_byte_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_OPTIONAL_BYTE: i8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_OPTIONAL_BYTE: i8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct OptionalByte(pub i8);
+
#[allow(non_upper_case_globals)]
impl OptionalByte {
pub const None: Self = Self(0);
@@ -30,6 +34,7 @@
Self::One,
Self::Two,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for OptionalByte {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for OptionalByte {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for OptionalByte {
type Output = OptionalByte;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for OptionalByte {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
diff --git a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
index 79052ff..fe3d8fe 100644
--- a/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
+++ b/tests/optional_scalars/optional_scalars/scalar_stuff_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum ScalarStuffOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum ScalarStuffOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct ScalarStuff<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for ScalarStuff<'a> {
type Inner = ScalarStuff<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -63,6 +65,7 @@
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>,
@@ -192,6 +195,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i8>(ScalarStuff::VT_JUST_I8, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_i8(&self) -> Option<i8> {
// Safety:
@@ -199,6 +203,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i8>(ScalarStuff::VT_MAYBE_I8, None)}
}
+
#[inline]
pub fn default_i8(&self) -> i8 {
// Safety:
@@ -206,6 +211,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i8>(ScalarStuff::VT_DEFAULT_I8, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_u8(&self) -> u8 {
// Safety:
@@ -213,6 +219,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u8>(ScalarStuff::VT_JUST_U8, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_u8(&self) -> Option<u8> {
// Safety:
@@ -220,6 +227,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u8>(ScalarStuff::VT_MAYBE_U8, None)}
}
+
#[inline]
pub fn default_u8(&self) -> u8 {
// Safety:
@@ -227,6 +235,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u8>(ScalarStuff::VT_DEFAULT_U8, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_i16(&self) -> i16 {
// Safety:
@@ -234,6 +243,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i16>(ScalarStuff::VT_JUST_I16, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_i16(&self) -> Option<i16> {
// Safety:
@@ -241,6 +251,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i16>(ScalarStuff::VT_MAYBE_I16, None)}
}
+
#[inline]
pub fn default_i16(&self) -> i16 {
// Safety:
@@ -248,6 +259,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i16>(ScalarStuff::VT_DEFAULT_I16, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_u16(&self) -> u16 {
// Safety:
@@ -255,6 +267,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u16>(ScalarStuff::VT_JUST_U16, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_u16(&self) -> Option<u16> {
// Safety:
@@ -262,6 +275,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u16>(ScalarStuff::VT_MAYBE_U16, None)}
}
+
#[inline]
pub fn default_u16(&self) -> u16 {
// Safety:
@@ -269,6 +283,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u16>(ScalarStuff::VT_DEFAULT_U16, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_i32(&self) -> i32 {
// Safety:
@@ -276,6 +291,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(ScalarStuff::VT_JUST_I32, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_i32(&self) -> Option<i32> {
// Safety:
@@ -283,6 +299,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(ScalarStuff::VT_MAYBE_I32, None)}
}
+
#[inline]
pub fn default_i32(&self) -> i32 {
// Safety:
@@ -290,6 +307,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i32>(ScalarStuff::VT_DEFAULT_I32, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_u32(&self) -> u32 {
// Safety:
@@ -297,6 +315,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u32>(ScalarStuff::VT_JUST_U32, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_u32(&self) -> Option<u32> {
// Safety:
@@ -304,6 +323,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u32>(ScalarStuff::VT_MAYBE_U32, None)}
}
+
#[inline]
pub fn default_u32(&self) -> u32 {
// Safety:
@@ -311,6 +331,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u32>(ScalarStuff::VT_DEFAULT_U32, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_i64(&self) -> i64 {
// Safety:
@@ -318,6 +339,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(ScalarStuff::VT_JUST_I64, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_i64(&self) -> Option<i64> {
// Safety:
@@ -325,6 +347,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(ScalarStuff::VT_MAYBE_I64, None)}
}
+
#[inline]
pub fn default_i64(&self) -> i64 {
// Safety:
@@ -332,6 +355,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<i64>(ScalarStuff::VT_DEFAULT_I64, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_u64(&self) -> u64 {
// Safety:
@@ -339,6 +363,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u64>(ScalarStuff::VT_JUST_U64, Some(0)).unwrap()}
}
+
#[inline]
pub fn maybe_u64(&self) -> Option<u64> {
// Safety:
@@ -346,6 +371,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u64>(ScalarStuff::VT_MAYBE_U64, None)}
}
+
#[inline]
pub fn default_u64(&self) -> u64 {
// Safety:
@@ -353,6 +379,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<u64>(ScalarStuff::VT_DEFAULT_U64, Some(42)).unwrap()}
}
+
#[inline]
pub fn just_f32(&self) -> f32 {
// Safety:
@@ -360,6 +387,7 @@
// 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_f32(&self) -> Option<f32> {
// Safety:
@@ -367,6 +395,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<f32>(ScalarStuff::VT_MAYBE_F32, None)}
}
+
#[inline]
pub fn default_f32(&self) -> f32 {
// Safety:
@@ -374,6 +403,7 @@
// 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_f64(&self) -> f64 {
// Safety:
@@ -381,6 +411,7 @@
// 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_f64(&self) -> Option<f64> {
// Safety:
@@ -388,6 +419,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<f64>(ScalarStuff::VT_MAYBE_F64, None)}
}
+
#[inline]
pub fn default_f64(&self) -> f64 {
// Safety:
@@ -395,6 +427,7 @@
// 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_bool(&self) -> bool {
// Safety:
@@ -402,6 +435,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<bool>(ScalarStuff::VT_JUST_BOOL, Some(false)).unwrap()}
}
+
#[inline]
pub fn maybe_bool(&self) -> Option<bool> {
// Safety:
@@ -409,6 +443,7 @@
// which contains a valid value in this slot
unsafe { self._tab.get::<bool>(ScalarStuff::VT_MAYBE_BOOL, None)}
}
+
#[inline]
pub fn default_bool(&self) -> bool {
// Safety:
@@ -416,6 +451,7 @@
// 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:
@@ -423,6 +459,7 @@
// 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:
@@ -430,6 +467,7 @@
// 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:
@@ -485,6 +523,7 @@
Ok(())
}
}
+
pub struct ScalarStuffArgs {
pub just_i8: i8,
pub maybe_i8: Option<i8>,
@@ -523,6 +562,7 @@
pub maybe_enum: Option<OptionalByte>,
pub default_enum: OptionalByte,
}
+
impl<'a> Default for ScalarStuffArgs {
#[inline]
fn default() -> Self {
@@ -571,151 +611,188 @@
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();
@@ -724,6 +801,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<ScalarStuff<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -773,6 +851,7 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct ScalarStuffT {
@@ -813,6 +892,7 @@
pub maybe_enum: Option<OptionalByte>,
pub default_enum: OptionalByte,
}
+
impl Default for ScalarStuffT {
fn default() -> Self {
Self {
@@ -855,6 +935,7 @@
}
}
}
+
impl ScalarStuffT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
@@ -936,66 +1017,73 @@
})
}
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a `ScalarStuff`
/// 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_scalar_stuff_unchecked`.
+#[inline]
pub fn root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root::<ScalarStuff>(buf)
}
-#[inline]
+
/// Verifies that a buffer of bytes contains a size prefixed
/// `ScalarStuff` 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_scalar_stuff_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_scalar_stuff(buf: &[u8]) -> Result<ScalarStuff<'_>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root::<ScalarStuff>(buf)
}
-#[inline]
+
/// Verifies, with the given options, that a buffer of bytes
/// contains a `ScalarStuff` 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_scalar_stuff_unchecked`.
+#[inline]
pub fn root_as_scalar_stuff_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<ScalarStuff<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::root_with_opts::<ScalarStuff<'b>>(opts, buf)
}
-#[inline]
+
/// Verifies, with the given verifier options, that a buffer of
/// bytes contains a size prefixed `ScalarStuff` 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_scalar_stuff_unchecked`.
+#[inline]
pub fn size_prefixed_root_as_scalar_stuff_with_opts<'b, 'o>(
opts: &'o ::flatbuffers::VerifierOptions,
buf: &'b [u8],
) -> Result<ScalarStuff<'b>, ::flatbuffers::InvalidFlatbuffer> {
::flatbuffers::size_prefixed_root_with_opts::<ScalarStuff<'b>>(opts, buf)
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a ScalarStuff and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid `ScalarStuff`.
+#[inline]
pub unsafe fn root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
unsafe { ::flatbuffers::root_unchecked::<ScalarStuff>(buf) }
}
-#[inline]
+
/// Assumes, without verification, that a buffer of bytes contains a size prefixed ScalarStuff and returns it.
/// # Safety
/// Callers must trust the given bytes do indeed contain a valid size prefixed `ScalarStuff`.
+#[inline]
pub unsafe fn size_prefixed_root_as_scalar_stuff_unchecked(buf: &[u8]) -> ScalarStuff<'_> {
unsafe { ::flatbuffers::size_prefixed_root_unchecked::<ScalarStuff>(buf) }
}
+
pub const SCALAR_STUFF_IDENTIFIER: &str = "NULL";
#[inline]
diff --git a/tests/private_annotation_test/ab_generated.rs b/tests/private_annotation_test/ab_generated.rs
index c8fd77c..91310b1 100644
--- a/tests/private_annotation_test/ab_generated.rs
+++ b/tests/private_annotation_test/ab_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_AB: i8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_AB: i8 = 1;
+
#[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] = [
@@ -16,6 +19,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub(crate) struct AB(pub i8);
+
#[allow(non_upper_case_globals)]
impl AB {
pub const A: Self = Self(0);
@@ -27,6 +31,7 @@
Self::A,
Self::B,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -36,6 +41,7 @@
}
}
}
+
impl ::core::fmt::Debug for AB {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -45,8 +51,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for AB {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<i8>(buf, loc) };
@@ -56,6 +64,7 @@
impl ::flatbuffers::Push for AB {
type Output = AB;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<i8>(dst, self.0) };
@@ -64,10 +73,12 @@
impl ::flatbuffers::EndianScalar for AB {
type Scalar = i8;
+
#[inline]
fn to_little_endian(self) -> i8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: i8) -> Self {
diff --git a/tests/private_annotation_test/annotations_generated.rs b/tests/private_annotation_test/annotations_generated.rs
index 3db01a9..ab20393 100644
--- a/tests/private_annotation_test/annotations_generated.rs
+++ b/tests/private_annotation_test/annotations_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub(crate) enum AnnotationsOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub(crate) enum AnnotationsOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub(crate) struct Annotations<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Annotations<'a> {
type Inner = Annotations<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -65,9 +68,11 @@
Ok(())
}
}
+
pub(crate) struct AnnotationsArgs {
pub value: i32,
}
+
impl<'a> Default for AnnotationsArgs {
#[inline]
fn default() -> Self {
@@ -81,11 +86,13 @@
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();
@@ -94,6 +101,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Annotations<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -108,11 +116,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct AnnotationsT {
pub value: i32,
}
+
impl Default for AnnotationsT {
fn default() -> Self {
Self {
@@ -120,6 +130,7 @@
}
}
}
+
impl AnnotationsT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/private_annotation_test/any_generated.rs b/tests/private_annotation_test/any_generated.rs
index dd6aed8..be353bf 100644
--- a/tests/private_annotation_test/any_generated.rs
+++ b/tests/private_annotation_test/any_generated.rs
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_ANY: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_ANY: u8 = 2;
+
#[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] = [
@@ -17,6 +20,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub(crate) struct Any(pub u8);
+
#[allow(non_upper_case_globals)]
impl Any {
pub const NONE: Self = Self(0);
@@ -30,6 +34,7 @@
Self::Game,
Self::Annotations,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -40,6 +45,7 @@
}
}
}
+
impl ::core::fmt::Debug for Any {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -49,8 +55,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for Any {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -60,6 +68,7 @@
impl ::flatbuffers::Push for Any {
type Output = Any;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -68,10 +77,12 @@
impl ::flatbuffers::EndianScalar for Any {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -90,6 +101,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Any {}
+
pub(crate) struct AnyUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -100,11 +112,13 @@
Game(alloc::boxed::Box<GameT>),
Annotations(alloc::boxed::Box<AnnotationsT>),
}
+
impl Default for AnyT {
fn default() -> Self {
Self::NONE
}
}
+
impl AnyT {
pub fn any_type(&self) -> Any {
match self {
@@ -113,6 +127,7 @@
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,
@@ -120,6 +135,7 @@
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 {
@@ -133,14 +149,17 @@
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 {
@@ -154,12 +173,15 @@
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 b43ce18..7fa953b 100644
--- a/tests/private_annotation_test/game_generated.rs
+++ b/tests/private_annotation_test/game_generated.rs
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub(crate) enum GameOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub(crate) enum GameOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub(crate) struct Game<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for Game<'a> {
type Inner = Game<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -28,6 +30,7 @@
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>,
@@ -65,9 +68,11 @@
Ok(())
}
}
+
pub(crate) struct GameArgs {
pub value: i32,
}
+
impl<'a> Default for GameArgs {
#[inline]
fn default() -> Self {
@@ -81,11 +86,13 @@
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();
@@ -94,6 +101,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<Game<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -108,11 +116,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub(crate) struct GameT {
pub value: i32,
}
+
impl Default for GameT {
fn default() -> Self {
Self {
@@ -120,6 +130,7 @@
}
}
}
+
impl GameT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
diff --git a/tests/private_annotation_test/object_generated.rs b/tests/private_annotation_test/object_generated.rs
index 5e98d99..3d5106d 100644
--- a/tests/private_annotation_test/object_generated.rs
+++ b/tests/private_annotation_test/object_generated.rs
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct Object, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub(crate) struct Object(pub [u8; 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")
@@ -20,27 +23,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for Object {}
+
impl<'a> ::flatbuffers::Follow<'a> for Object {
type Inner = &'a Object;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a Object>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for Object {
type Output = Object;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const Object as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -110,6 +120,7 @@
pub(crate) struct ObjectT {
pub value: i32,
}
+
impl ObjectT {
pub fn pack(&self) -> Object {
Object::new(
@@ -117,4 +128,3 @@
)
}
}
-
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 6325650..88e0da1 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum FieldTableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum FieldTableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct FieldTable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for FieldTable<'a> {
type Inner = FieldTable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> FieldTable<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"RustNamerTest.FieldTable"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct FieldTableArgs {
}
+
impl<'a> Default for FieldTableArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<FieldTable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct FieldTableT {
}
+
impl Default for FieldTableT {
fn default() -> Self {
Self {
}
}
}
+
impl FieldTableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 7088359..7bedafe 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_FIELD_UNION: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_FIELD_UNION: u8 = 1;
+
#[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] = [
@@ -16,6 +19,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct FieldUnion(pub u8);
+
#[allow(non_upper_case_globals)]
impl FieldUnion {
pub const NONE: Self = Self(0);
@@ -27,6 +31,7 @@
Self::NONE,
Self::f,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -36,6 +41,7 @@
}
}
}
+
impl ::core::fmt::Debug for FieldUnion {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -45,8 +51,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for FieldUnion {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -56,6 +64,7 @@
impl ::flatbuffers::Push for FieldUnion {
type Output = FieldUnion;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -64,10 +73,12 @@
impl ::flatbuffers::EndianScalar for FieldUnion {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -86,6 +97,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for FieldUnion {}
+
pub struct FieldUnionUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -95,11 +107,13 @@
NONE,
F(alloc::boxed::Box<FieldTableT>),
}
+
impl Default for FieldUnionT {
fn default() -> Self {
Self::NONE
}
}
+
impl FieldUnionT {
pub fn field_union_type(&self) -> FieldUnion {
match self {
@@ -107,12 +121,14 @@
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()),
}
}
+
/// 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 {
@@ -126,12 +142,15 @@
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 }
}
}
+
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 47d0a99..5d4dc48 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
@@ -2,10 +2,13 @@
// @generated
extern crate alloc;
use super::*;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MIN_GAME_MESSAGE: u8 = 0;
+
#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
pub const ENUM_MAX_GAME_MESSAGE: u8 = 3;
+
#[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] = [
@@ -18,6 +21,7 @@
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Default)]
#[repr(transparent)]
pub struct GameMessage(pub u8);
+
#[allow(non_upper_case_globals)]
impl GameMessage {
pub const NONE: Self = Self(0);
@@ -33,6 +37,7 @@
Self::PlayerSpectate,
Self::PlayerInputChange,
];
+
/// Returns the variant's name or "" if unknown.
pub fn variant_name(self) -> Option<&'static str> {
match self {
@@ -44,6 +49,7 @@
}
}
}
+
impl ::core::fmt::Debug for GameMessage {
fn fmt(&self, f: &mut ::core::fmt::Formatter) -> ::core::fmt::Result {
if let Some(name) = self.variant_name() {
@@ -53,8 +59,10 @@
}
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for GameMessage {
type Inner = Self;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
let b = unsafe { ::flatbuffers::read_scalar_at::<u8>(buf, loc) };
@@ -64,6 +72,7 @@
impl ::flatbuffers::Push for GameMessage {
type Output = GameMessage;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
unsafe { ::flatbuffers::emplace_scalar::<u8>(dst, self.0) };
@@ -72,10 +81,12 @@
impl ::flatbuffers::EndianScalar for GameMessage {
type Scalar = u8;
+
#[inline]
fn to_little_endian(self) -> u8 {
self.0.to_le()
}
+
#[inline]
#[allow(clippy::wrong_self_convention)]
fn from_little_endian(v: u8) -> Self {
@@ -94,6 +105,7 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for GameMessage {}
+
pub struct GameMessageUnionTableOffset {}
#[allow(clippy::upper_case_acronyms)]
@@ -105,11 +117,13 @@
PlayerSpectate(alloc::boxed::Box<PlayerSpectateT>),
PlayerInputChange(alloc::boxed::Box<PlayerInputChangeT>),
}
+
impl Default for GameMessageT {
fn default() -> Self {
Self::NONE
}
}
+
impl GameMessageT {
pub fn game_message_type(&self) -> GameMessage {
match self {
@@ -119,6 +133,7 @@
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,
@@ -127,6 +142,7 @@
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 {
@@ -140,14 +156,17 @@
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 {
@@ -161,14 +180,17 @@
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 {
@@ -182,12 +204,15 @@
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 9c8adbe..6132c77 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum GameMessageWrapperOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum GameMessageWrapperOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct GameMessageWrapper<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for GameMessageWrapper<'a> {
type Inner = GameMessageWrapper<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@
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>,
@@ -72,6 +75,7 @@
// 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:
@@ -79,6 +83,7 @@
// 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>> {
@@ -123,7 +128,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for GameMessageWrapper<'_> {
@@ -144,10 +148,12 @@
Ok(())
}
}
+
pub struct GameMessageWrapperArgs {
pub Message_type: GameMessage,
pub Message: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
}
+
impl<'a> Default for GameMessageWrapperArgs {
#[inline]
fn default() -> Self {
@@ -162,15 +168,18 @@
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();
@@ -179,6 +188,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<GameMessageWrapper<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -220,11 +230,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct GameMessageWrapperT {
pub Message: GameMessageT,
}
+
impl Default for GameMessageWrapperT {
fn default() -> Self {
Self {
@@ -232,6 +244,7 @@
}
}
}
+
impl GameMessageWrapperT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 ef06454..75fb6e4 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum PlayerInputChangeOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum PlayerInputChangeOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct PlayerInputChange<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for PlayerInputChange<'a> {
type Inner = PlayerInputChange<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> PlayerInputChange<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"RustNamerTest.PlayerInputChange"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct PlayerInputChangeArgs {
}
+
impl<'a> Default for PlayerInputChangeArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerInputChange<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerInputChangeT {
}
+
impl Default for PlayerInputChangeT {
fn default() -> Self {
Self {
}
}
}
+
impl PlayerInputChangeT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 40b2066..df9fbd9 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum PlayerSpectateOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum PlayerSpectateOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct PlayerSpectate<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for PlayerSpectate<'a> {
type Inner = PlayerSpectate<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> PlayerSpectate<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"RustNamerTest.PlayerSpectate"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct PlayerSpectateArgs {
}
+
impl<'a> Default for PlayerSpectateArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerSpectate<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerSpectateT {
}
+
impl Default for PlayerSpectateT {
fn default() -> Self {
Self {
}
}
}
+
impl PlayerSpectateT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 7fe60fa..4ed80f0 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum PlayerStatEventOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum PlayerStatEventOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct PlayerStatEvent<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for PlayerStatEvent<'a> {
type Inner = PlayerStatEvent<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -18,7 +20,6 @@
}
impl<'a> PlayerStatEvent<'a> {
-
pub const fn get_fully_qualified_name() -> &'static str {
"RustNamerTest.PlayerStatEvent"
}
@@ -27,6 +28,7 @@
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>,
@@ -52,8 +54,10 @@
Ok(())
}
}
+
pub struct PlayerStatEventArgs {
}
+
impl<'a> Default for PlayerStatEventArgs {
#[inline]
fn default() -> Self {
@@ -66,6 +70,7 @@
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> {
@@ -75,6 +80,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<PlayerStatEvent<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -88,16 +94,19 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct PlayerStatEventT {
}
+
impl Default for PlayerStatEventT {
fn default() -> Self {
Self {
}
}
}
+
impl PlayerStatEventT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,
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 6d4ec11..bff14ad 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
@@ -2,15 +2,18 @@
// @generated
extern crate alloc;
use super::*;
+
// struct PossiblyReservedWords, aligned to 4
#[repr(transparent)]
#[derive(Clone, Copy, PartialEq)]
pub struct PossiblyReservedWords(pub [u8; 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")
@@ -23,27 +26,34 @@
}
impl ::flatbuffers::SimpleToVerifyInSlice for PossiblyReservedWords {}
+
impl<'a> ::flatbuffers::Follow<'a> for PossiblyReservedWords {
type Inner = &'a PossiblyReservedWords;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
unsafe { <&'a PossiblyReservedWords>::follow(buf, loc) }
}
}
+
impl<'a> ::flatbuffers::Follow<'a> for &'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) }
}
}
+
impl<'b> ::flatbuffers::Push for PossiblyReservedWords {
type Output = PossiblyReservedWords;
+
#[inline]
unsafe fn push(&self, dst: &mut [u8], _written_len: usize) {
let src = unsafe { ::core::slice::from_raw_parts(self as *const PossiblyReservedWords as *const u8, <Self as ::flatbuffers::Push>::size()) };
dst.copy_from_slice(src);
}
+
#[inline]
fn alignment() -> ::flatbuffers::PushAlignment {
::flatbuffers::PushAlignment::new(4)
@@ -212,6 +222,7 @@
pub size: f32,
pub alignment: f32,
}
+
impl PossiblyReservedWordsT {
pub fn pack(&self) -> PossiblyReservedWords {
PossiblyReservedWords::new(
@@ -222,4 +233,3 @@
)
}
}
-
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 c3d458e..7677de0 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
@@ -2,15 +2,17 @@
// @generated
extern crate alloc;
use super::*;
-pub enum RootTableOffset {}
-#[derive(Copy, Clone, PartialEq)]
+pub enum RootTableOffset {}
+
+#[derive(Copy, Clone, PartialEq)]
pub struct RootTable<'a> {
pub _tab: ::flatbuffers::Table<'a>,
}
impl<'a> ::flatbuffers::Follow<'a> for RootTable<'a> {
type Inner = RootTable<'a>;
+
#[inline]
unsafe fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
Self { _tab: unsafe { ::flatbuffers::Table::new(buf, loc) } }
@@ -29,6 +31,7 @@
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>,
@@ -62,6 +65,7 @@
// 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:
@@ -69,6 +73,7 @@
// 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>> {
@@ -83,7 +88,6 @@
None
}
}
-
}
impl ::flatbuffers::Verifiable for RootTable<'_> {
@@ -102,10 +106,12 @@
Ok(())
}
}
+
pub struct RootTableArgs {
pub field42_type: FieldUnion,
pub field42: Option<::flatbuffers::WIPOffset<::flatbuffers::UnionWIPOffset>>,
}
+
impl<'a> Default for RootTableArgs {
#[inline]
fn default() -> Self {
@@ -120,15 +126,18 @@
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();
@@ -137,6 +146,7 @@
start_: start,
}
}
+
#[inline]
pub fn finish(self) -> ::flatbuffers::WIPOffset<RootTable<'a>> {
let o = self.fbb_.end_table(self.start_);
@@ -164,11 +174,13 @@
ds.finish()
}
}
+
#[non_exhaustive]
#[derive(Debug, Clone, PartialEq)]
pub struct RootTableT {
pub field42: FieldUnionT,
}
+
impl Default for RootTableT {
fn default() -> Self {
Self {
@@ -176,6 +188,7 @@
}
}
}
+
impl RootTableT {
pub fn pack<'b, A: ::flatbuffers::Allocator + 'b>(
&self,