diff options
author | Casper <casperneo@uchicago.edu> | 2021-01-22 13:07:32 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-22 13:07:32 -0500 |
commit | 1da0a2dfac4bd9a6876a7c39c4eea5eeefc36aa2 (patch) | |
tree | a48ac3f7455c980b05ca41d3e44d5e367b0260d2 /tests/namespace_test/namespace_test2_generated.rs | |
parent | 796ed68faf434cac90f094a5fdf47137ba74e5a2 (diff) | |
download | flatbuffers-1da0a2dfac4bd9a6876a7c39c4eea5eeefc36aa2.tar.gz flatbuffers-1da0a2dfac4bd9a6876a7c39c4eea5eeefc36aa2.tar.bz2 flatbuffers-1da0a2dfac4bd9a6876a7c39c4eea5eeefc36aa2.zip |
Rust Object API (#6070)
* inital commit of rust object api
* Required fields support.
* clang fallthrough
* Fix unused variables
* just don't fall through
* remove comment
* s/panic/unreachable
* Tests for object API
* Added defaults
* deleted unintentionally added files and updated .bat file
* fix bat file
* clang format
* Cargo clippy checks
* remove commented out code
* clippy allows
* Remove matches! macro since we're not yet at Rust v1.42
* install clippy in RustTest.sh
* move line
Co-authored-by: Casper Neo <cneo@google.com>
Diffstat (limited to 'tests/namespace_test/namespace_test2_generated.rs')
-rw-r--r-- | tests/namespace_test/namespace_test2_generated.rs | 112 |
1 files changed, 103 insertions, 9 deletions
diff --git a/tests/namespace_test/namespace_test2_generated.rs b/tests/namespace_test/namespace_test2_generated.rs index 490dd6b9..a774dbfc 100644 --- a/tests/namespace_test/namespace_test2_generated.rs +++ b/tests/namespace_test/namespace_test2_generated.rs @@ -42,9 +42,7 @@ impl<'a> TableInFirstNS<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TableInFirstNS { - _tab: table, - } + TableInFirstNS { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -57,6 +55,20 @@ impl<'a> TableInFirstNS<'a> { builder.finish() } + pub fn unpack(&self) -> TableInFirstNST { + let foo_table = self.foo_table().map(|x| { + Box::new(x.unpack()) + }); + let foo_enum = self.foo_enum(); + let foo_struct = self.foo_struct().map(|x| { + x.unpack() + }); + TableInFirstNST { + foo_table, + foo_enum, + foo_struct, + } + } pub const VT_FOO_TABLE: flatbuffers::VOffsetT = 4; pub const VT_FOO_ENUM: flatbuffers::VOffsetT = 6; pub const VT_FOO_STRUCT: flatbuffers::VOffsetT = 8; @@ -145,6 +157,31 @@ impl std::fmt::Debug for TableInFirstNS<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct TableInFirstNST { + pub foo_table: Option<Box<namespace_b::TableInNestedNST>>, + pub foo_enum: namespace_b::EnumInNestedNS, + pub foo_struct: Option<namespace_b::StructInNestedNST>, +} +impl TableInFirstNST { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<TableInFirstNS<'b>> { + let foo_table = self.foo_table.as_ref().map(|x|{ + x.pack(_fbb) + }); + let foo_enum = self.foo_enum; + let foo_struct_tmp = self.foo_struct.as_ref().map(|x| x.pack()); + let foo_struct = foo_struct_tmp.as_ref(); + TableInFirstNS::create(_fbb, &TableInFirstNSArgs{ + foo_table, + foo_enum, + foo_struct, + }) + } +} pub enum SecondTableInAOffset {} #[derive(Copy, Clone, PartialEq)] @@ -167,9 +204,7 @@ impl<'a> SecondTableInA<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - SecondTableInA { - _tab: table, - } + SecondTableInA { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -180,6 +215,14 @@ impl<'a> SecondTableInA<'a> { builder.finish() } + pub fn unpack(&self) -> SecondTableInAT { + let refer_to_c = self.refer_to_c().map(|x| { + Box::new(x.unpack()) + }); + SecondTableInAT { + refer_to_c, + } + } pub const VT_REFER_TO_C: flatbuffers::VOffsetT = 4; #[inline] @@ -242,6 +285,24 @@ impl std::fmt::Debug for SecondTableInA<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct SecondTableInAT { + pub refer_to_c: Option<Box<super::namespace_c::TableInCT>>, +} +impl SecondTableInAT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<SecondTableInA<'b>> { + let refer_to_c = self.refer_to_c.as_ref().map(|x|{ + x.pack(_fbb) + }); + SecondTableInA::create(_fbb, &SecondTableInAArgs{ + refer_to_c, + }) + } +} } // pub mod NamespaceA #[allow(unused_imports, dead_code)] @@ -276,9 +337,7 @@ impl<'a> TableInC<'a> { #[inline] pub fn init_from_table(table: flatbuffers::Table<'a>) -> Self { - TableInC { - _tab: table, - } + TableInC { _tab: table } } #[allow(unused_mut)] pub fn create<'bldr: 'args, 'args: 'mut_bldr, 'mut_bldr>( @@ -290,6 +349,18 @@ impl<'a> TableInC<'a> { builder.finish() } + pub fn unpack(&self) -> TableInCT { + let refer_to_a1 = self.refer_to_a1().map(|x| { + Box::new(x.unpack()) + }); + let refer_to_a2 = self.refer_to_a2().map(|x| { + Box::new(x.unpack()) + }); + TableInCT { + refer_to_a1, + refer_to_a2, + } + } pub const VT_REFER_TO_A1: flatbuffers::VOffsetT = 4; pub const VT_REFER_TO_A2: flatbuffers::VOffsetT = 6; @@ -365,5 +436,28 @@ impl std::fmt::Debug for TableInC<'_> { ds.finish() } } +#[non_exhaustive] +#[derive(Debug, Clone, PartialEq, Default)] +pub struct TableInCT { + pub refer_to_a1: Option<Box<super::namespace_a::TableInFirstNST>>, + pub refer_to_a2: Option<Box<super::namespace_a::SecondTableInAT>>, +} +impl TableInCT { + pub fn pack<'b>( + &self, + _fbb: &mut flatbuffers::FlatBufferBuilder<'b> + ) -> flatbuffers::WIPOffset<TableInC<'b>> { + let refer_to_a1 = self.refer_to_a1.as_ref().map(|x|{ + x.pack(_fbb) + }); + let refer_to_a2 = self.refer_to_a2.as_ref().map(|x|{ + x.pack(_fbb) + }); + TableInC::create(_fbb, &TableInCArgs{ + refer_to_a1, + refer_to_a2, + }) + } +} } // pub mod NamespaceC |