Squashed 'third_party/flatbuffers/' changes from 338393f85..e5f331db9
e5f331db9 [TS] Add single-file ts codegen & bazel rule for typescript (#7161)
2f84c6038 Apply Namer to Go code gen (#7150)
d64839651 [Lobster] file_identifier support
777e78d8d [Lobster] support unsigned integer reads
4016c549d Apply Namer to Python code gen (#7146)
40827b21b Fix missing 'break' (#7151)
65a10b6e3 Implement a config based name manager and use it in Rust codegen (#7144)
8db2fef3f [TS] Escape keywords in typescript object names (#7137)
9ed132304 Fix 64-bit numeric enum values in typescript (#7135)
1a4c40566 updated npm to 2.0.6
318594e4b prevent name clash (#7133)
3d903302c [Rust] Add length checks to arrays and vectors. (#7130)
c9571d989 Replaced ToDasherCase with ConvertCase (#7131)
3694b830a Use ConvertCase instead of Make{Upper,Lower,Snake} implementations (#7127)
0471fa807 remove stall reference to version
914344ea9 some minor help edits
b40266c56 Use target_compile_features to target C++11 (#7122)
8a9303d46 update proto tests with alaised enum (#7121)
30c4bf47f Trigger fuzzing CI only on relevant changes (#7120)
46ce45601 remove auto generate code from cmakelists (#7119)
433312c55 add the missing checkNullConditionnal code in the "GenObjApi" function when the field is scalar optional (#7114)
9c52ec374 Add deps attribute to flatbuffer_cc_library (#7107)
70e2f49bf fixed string-json -> strict-json typo
5ac0367ed [TS] Fix generation of reserved words in object api (#7106) (#7115)
5d101afb5 Fix minor typo in WhitePaper.md (#7108)
06f4af11b Go optional scalars (#7104)
57e338f81 explicitly use windows-2019 to unblock ci (#7105)
615616cb5 Change Rust generated file defaults (#7101)
3413c3300 Fixed FlexBuffers verifier fuzzer timing out
69f5660a4 Fixed Parser not checking size of union types vector
d5add9fca Fixed FlexBuffers ToString unquoted non-ident keys
15df50eb7 Remove @ExperimentalUnsignedTypes annotation from kotlin code generator. (#7092)
a94132a45 Swift FlatBufferBuilder.sizedByteArray to ByteBuffer.toArray() (#7093)
48befb6be [TS] Refactor away circular ref (#7099)
b30069133 Add reflection support for python (#7026)
faadbc10e Add CreateVector overload to accept array like (#7095)
ed6ae8d32 explicitly defined std::allocator (#7094)
e910bddbc [JS] Add ".js" suffix to all import statements to generate a browser compatible mjs version. (#7086)
c85fb690f Add Parsing Completed function for Rust (#7084)
c1daa6ba0 rust: Bump thiserror version and remove git dependency (#7080)
4c71c7b02 replace framework include of flatbuffers (#7079)
f5664d33f fix go_test implement error (#7012)
39c8a19ce fixed comparator for native_inline (#7076)
826193ff6 skip generating reflection.fbs in generate_scripts (#7077)
fd0d1ed92 update C++ generator to emit scoped enums in vector of unions (#7075)
424988f30 replaced removed xml tag
b2550dbaa removed BSD-3-Clause license and Zlib licenses (#7073)
a2b238960 Fixed default value of bool in struct for Swift (#7072)
619b78437 one last dart omit local (#7070)
68a766154 more omit type annotations for dart local variables (#7069)
7dac9961f omit type annotations for dart local variables (#7067)
c65c389c6 add xmlns to .Net (#7066)
6446dcf3d Updates swift gen licence for grpc code (#7063)
e090d8da1 Fixed long cast to int in flexbufferbuilder.java (#7059)
bc901436d clang format on codebase (#7058)
240be9b5a attempt to remove appveyor (#7056)
bc366a7f9 Provide a short help text and default in error case (#6992)
14b19d446 Use FindPython3 (#7055)
9e6f17b94 remove BIICODE
c3801ad37 Update readme.md
4f3b24db0 Fixes a bug where bools arent being nil when marked optional (#7051)
1d294a31b Implement Serialize on generated rust types (#7022)
dd8fccfb1 Cmake 3.16 de-facto minimum version (#7049)
7089c9ecd Convert flatbuffers_version_string to inline function (#7046)
43203984f [C++] Support C++ object copies and moves (#5988)
5993338ee [ts] Builder incorrectly serializing empty strings (#7047)
19920db39 Include a SizePrefixed..HasIdentifier for c++. (#6871)
dbbaeac85 Use `${PYTHON_EXECUTABLE}` instead of `py` in cmake (#7042)
028f0fde6 'flattest': Add --test_path option (#7041)
87343631b Added support for clang-cl on windows (CMake) (#7038)
1fbfaf5c5 Fix/cmake build grpc (#7028)
4421375bb Add FlatBuffers::FlatBuffers interface, needed for FetchContent_Declare (#7023)
162ad7a37 Fix comment with line orders - Rust should be last. (#7037)
a0a6c3f8c Use actions/checkout@v2, which fixes security vulnerability. (#7036)
a2d38fbb9 Add --warnings-as-errors to flatc compiler. (#7034)
9ef1524d3 Emit include for bfbs-gen-embed (#7031)
0c9de0352 Upgraded GRPC version to 1.42.0 (#7033)
a783bc926 chore: dart 2.0.5 release changes (#6983)
aff818ceb rust: Allow for usage in no_std environment (#6989)
d7b75417f Make flatbuffer builder deterministic (#6993)
a42e89897 Added verifier alignment checking to table fields (#7018)
96cc2f3ee BuildFlatBuffers.cmake: fix arguments not passed properly to flatc (#7013)
3250a1f8d Add initial C# vector of unions support to the documentation. (#6880)
ace4a37f2 [TS/JS] BigInt implementation (#6998)
f28c2b293 Avoid implicit conversion from float to double. (#7003)
96f3cf690 Rearrange #include directives to pass to compilation with a particular DSP toolchain (#7000)
b3edfdbfb Reverting grpc generated file suffix (#6995)
b8aaccee8 Disable parsing of nested_flatbuffers as bytes by default
2dc8ae774 Enable OSS-Fuzz on CI
5b0d49112 Updated FlexBuffers fuzzer
d8b7041d7 Added alignment checking to FlexBuffers verifier
5a0c3366c FlexBuffers verifier additionally checks for nesting
f8148b8da Made FlexBuffers reuse tracker track types
a22b1b626 Prevent shadow with _{{FIELD_NAME}} (#6991)
4264daadd FlexBuffers fuzzer fixes
3cbc120a0 Refractor Flatc Options (#6987)
8dcd2682c [CMake] Add option for disable universal on OSX (#6990)
b78002ff3 Validate C# json/object-api options (#6985)
c555ee8fa Add .NET test to github workflows (#6982)
b92bb0584 [CMake]: Fix version in pkgconfig file (#6986)
956d11569 re-enabled FlexBuffer JSON in fuzzer
e367ca32a Verifier for FlexBuffers (#6977)
705f27f6e [CMake]: Fix python command for mingw environment (#6984)
5fc87f4c4 Enable --gen-onefile in Python (#6953)
11749095a Make idl_parser deterministic (#6976)
d0cede9c9 Bumping to Version 2.0.5 (#6967)
fcc2bee0b Fix typo in variable name (#6973)
e08da4dea remove Appveyor's Vs2010 and 13 builds (#6969)
18538c401 [TS] Fix reserved words as arguments (#6955) (#6956)
e57f4ab2d Update stale bot version and provide away to exempt issues with the not-stale label (#6968)
deed68db5 missing generated files (#6966)
061d61f3f Lua Generator using IR. (#6940)
cffe0c454 FixedTypedVector: add const to ElementType() and size() (#6965)
fadd40e40 Have grpc include file with correct filename-suffix given to flatc (#6954)
e47dc0e46 Removed test/generate_code.{sh|bat} (#6873)
5c5475479 switched to windows-lastest, removed deadcode (#6948)
4f7f6dc30 Restore FlatBufferBuilder::kFileIdentifierLength. (#6960)
0fadaf391 Enable verifier on nested_flatbuffers
4d0e9a870 Turn off nested FlatBuffers/FlexBuffers for the fuzzer
c05f6783a invalid conditional running genrate_code.py (#6952)
a14f4052c rust: remove needless borrow (#6922)
9e4ca857b Vector Downward GetSize optimization (#6925)
a2b99084b Fix flexbuffers clang-analyzer warning (#6947)
85b4effac test: fix undefined order of functio parameters. (#6946)
790f41154 [cmake] Fix getting version info from tags during the build (#6936)
e89de4411 clang-all (#6941)
256ab3798 WIP: Dart release 2.0 (#6927)
a59288a01 Add benchmarks to Linux CI (#6928)
587bbd49a [C++] Fix compile failure on Object API union construction for struct member (#6923)
a9c341545 Fix integer overflow warnings
8aa18b629 fixed cmp0048 error (#6932)
d727579b6 fuzzers: fix typo in file path (#6931)
97a30171c Added Raw C++ benchmarks (#6924)
0989fc5e5 Added Google benchmarks (and gtests) (#6920)
927175ea2 [Java] lookup by byteArray is giving back wrong entry (#6915)
6748c373b Removal of support for FLATBUFFERS_CPP98_STL (#6918)
3fab0c6ee move [[ ]] to calling sites (#6914)
6c8c29155 [C++] Split flatbuffers.h into separate files (#6868)
fd4ff23da Keep methods with struct name and switch them to default (#6879)
f8b69e330 [Python] Verify EnumDef is not generated in GenUnionCreator (#6903)
c0394bb09 Support `--conform` for vector of unions (#6883)
8433eb108 Typo fixes in comments of flatbuffers.h and flexbuffers.h (#6901)
f2f9380c8 [Java] Prevent generation of enum names when underlying type is long (#6781) (#6895)
e672dabfe [C++] Fix memory leak when using grpc (#6896) (#6897)
9a4ca2764 Output errors / warnings on stderr instead of stdout (#6881)
4c7a9c10d Adds JSON encoding to swift (#6874)
38295a187 [Kotlin] Fix missing escape for struct construction statements (#6877)
31bb0b972 add working directory (#6878)
45e5642e9 Default Arguments for Mutators C++ [Updated] (#6872)
a592f4c89 [Cmake] Add a post build command after flatc to run the new generate_code.py script. (#6866)
b9d43a557 dart - add Packable interface (#6846)
2ece9e25b Bumped package.json to 2.0.4
2dd212637 Fix linker errors on (Free|Open)BSD. (#6860)
f63c130c2 Improves documentation, and adding DocC (#6784)
e2b26ee19 Make and generate_code.sh generate same outputs (#6855)
9d686bf43 Include subdirectories in published npm package (#6850)
1d26daff3 Use ArrayBuffer type for JS flexbuffer's toObject (#6851)
e72e18d9f feat(build): compile "universal" libraries and executables for Mac (#6852)
354d97f6d fixed errant itemgroup element in C# test project (#6854)
6f7a57eaa [C#] Using 'global::' as qualifying_start_ within BaseGenerator (#6767)
90baa1444 Dart: binary lists (typed_data) (#6839)
0a3b017f0 Delete IDLOptions::lang (#6841)
47d35f105 BugFix: Optional enum when it is null (#6835)
8fb8c2ce1 [C#] Use @ for keyword escaping (#6834)
1d063d87c [C++] Let builder accept custom-alloc std::vector (#6814)
338331b55 Changes to support binary schema file loading and parsing (flatc) (#6823)
156a30c75 Move Apple-specific build flags to Clang section (#6802)
550d2f904 Issue error if jsonschema has no root type defined #6821 (#6831)
c3a38242e Fix typos in docs (#6829)
74c3d7eba [C++] Add mutable version of LookupByKey and test (#6826)
db6eae5c4 Add html and latex to gitignore (#6819)
0e9d79c35 [Java] Avoid casting ByteBuffer to Buffer (#6785)
b20c4d3aa [C++] Add GetMutableSizePrefixedRoot and generate GetMutableSizePrefixedXxx functions (#6815)
ae145293c flattests_cpp17 doesn't compile with Visual Studio 2017: warning C4100: 'indent': unreferenced formal parameter (#6811)
e3c76a5cd Dart lints (#6808)
4b9123baf fix parser string=null (#6810)
f89e0b1a6 Refactor idl_gen_rust and Rust generated code to use consistent whitespace (#6809)
273f6084e Fix Rust keyword inconsistency (#6794)
4a0879458 [C#] Remove superfluous semicolon in C# structs (#6791)
d6f51ea16 fix ptr in flatbuffers cpp tutorial (#6787)
067dce6e7 [C#] Handle keywords (#6775)
2ca5f0e72 [C#] Respect command line parameter for file name extension and suffix (#6779)
f20d2253a update Java version to 2.0.3
390d438e2 [Kotlin] Fix CI by changing compiler to Java 11 (#6783)
6fb2c90d9 avoiding even more NoSuchMethod exceptions (#6729)
a7b527d94 java: Use maven profile to target Java 8 bytecode (#6764)
5d77820b3 [C++] Using calculated fields_number for field_names size (#6769)
909ce970a [C++] Use UnPackTo instead of UnPack if pointer exists (#6725)
35e2cac6e Store vtables sorted in Rust builder (#6765)
c39fc9dd9 [C++] Use nullptr instead of 0 in generated headers (#6762)
775c6567d [C++] Fix compiler warning -Wredundant-parens in clang (#6761)
97d9527f6 Dart 2.0 release prep (#6759)
e01205466 [C++] Use proper gRPC C++ API when using MemoryBuffer Slice (#6756)
5235133f3 Dart - make ascii optimization optional in StringReader, same as in writeString() (#6758)
c871df770 Dart - change table building to assert() instead of exceptions (#6754)
a6eeeb3b9 Dart - inline small functions to increase performance (#6755)
3dd02144d [C#] Fix field name struct name collision (#6744) (#6757)
e77926f0e [C#] Add Union Constructor Utility for ObjectAPI. (#6105)
ac2348202 Dart - fixup writeString() return type after previous merges (#6753)
8be8a0a71 [C++] Fix union type handling on object api in C++17 (#6745)
12e341e4f Rework how Rust generated files are laid out (#6731)
c36672d80 Dart - optimize writeString for ASCII (#6736)
2bfc8e9f0 Dart - make writeString() argument non-nullable (#6737)
674a9f2aa fix lints in rust tests (#6743)
016e6aa13 Add a split on ':' to build_defs.bzl (#6742)
65700441d Dart - make vTable fixed size (expect the number of fields when creating) (#6735)
dd5bb55ca Dart - make vTable deduplication optional (#6734)
e8423da1b Dart - regenerate example after recent flatc changes (#6733)
0980e39c9 flexbuffers: Add variant of Blob() that takes a key (#6730)
e73fab27d Dart - store empty vectors instead of NULL (#6728)
92ae532e4 Dart - finish/lowFinish/buffer changes (#6712)
7482b25f8 Remove ubuntu1604 from presubmit.yml (#6715)
3f77dc9a0 Dart - unpack() must use eager list reader (#6723)
838c93b84 Dart - fix flex-builder compilation error (#6722)
089f48a4a Dart - make sure added padding is zeroed, same as in C++ (#6716)
bf3470c16 Fix UB in CreateVectorOfStructs in case of an empty vector: avoid calling memcpy in this case (#6726)
8f8196e13 Fix 6348 (#6717)
8ab35b2a5 Dart - add custom allocator support (#6711)
c0ba2870c Fix typo in docu (#6714)
22498cf3a [C++] add make_span for Array<T,N> (#6663)
bd37e67ac [C++] Fix a -Wdeprecated-copy warning. (#6708)
a6ee33557 Dart null safety (#6696)
71d43f3be Make --bfbs-filenames default to location of first schema file. (#6705)
c8db1ca5d Jsonschema add prop comments (#6617)
962751a6e Improve generated comparisons for tables (#6486)
06fd6d640 Replace filenames in reflection with filenames+includes. (#6703)
acce4ac3f Fix incorrect assertion usage. (#6702)
8fd7861b7 Fix warning about deprecated module: imp (#6362)
c58ae9422 Add the file a symbol is declared in to Reflection (#6613)
2cf7bb796 Intermediate Representation docs (#6685)
4e3a66c14 Dart object API (#6682)
d959e2320 dart - change Builder.reset() to reuse an existing buffer (#6661)
a9fb54088 use improved versioning (#6691)
337eb8b8f update docs - structs can't be roots (#6690)
6415ef05d [Python] [Codegen] Fixes nested structs with underscore names (#6686)
f069396d1 [C++] flatc --cpp-field-case-style option to permit camel-case field names in C++ (#6669)
021177af0 Fix snap version formatting (#6683)
e1e9f9373 [C++/grpc] added hiding of unused variables in the generated code (#6677)
15110094e Fix GitHub Actions CI gcc/clang versions
093badb0a Use unoptimized path for ReadUInt64 for win32 build as the optimized path crashes. (#6681)
752c7b576 avoiding more NoSuchMethod exceptions (#6671)
7c3e267e1 [Java] ObjectAPI implementation (#6521) (#6582)
baaffbaed npm update to 2.0.3 and script fix
4cb3f222b [TS] Fix module reference in package.json (#6676)
eabdbda75 [TS] Generate entry point module (#6674)
bec23700f Prepare for Java 2.0.1 release
12f2eedad Update CI to GCC/Clang 11
221eeb231 Fix typo in C++ doc (#6664)
813d3632e avoiding NoSuchMethod exception (#6658)
d84bccb0c Removed most heap allocations in builder (#6662)
b4e67f9bf Dart test fix (#6660)
54c11932f [Java] Flexbuffers - Negative signed object length (#6651)
fbcb3c423 [TS/JS] Updates the grpc (#6654)
8937dcfd7 Updates go lang support to allow other languages to communicate with it (#6653)
512d5a689 Update readme.md to point to security policy
a92cb5dd7 Create Security.md
d151dcbb9 Revert "[C++] Removed most heap allocations in builder (#6620)" (#6659)
f1884c66f Fix gRPC test to use EndVector without specifying the length. (#6646)
72730ecd8 [C++] Removed most heap allocations in builder (#6620)
fe2bc2b0a Added README for Rust Flatbuffers (before publishing v=2.0) (#6652)
4867c9456 Fixed generation of c++ code with flags (#6637)
ef0eb3701 Ran clang-format-all.sh. Removed default --style=file parameter (#6639)
f83ee1af5 [idl_parser] Check structs and enums do not clash in a namespace (#6562)
a5175c513 Implements verifier and code gen for swift (#6373)
04b10f5a3 Deprecate EnumVal.object (#6612)
c121c0345 Fixed Java gRPC version number dependency
8fd10606c Implement Serialize for flexbuffer::Reader (#6635)
a1730fcea [Swift] Updated cocoapods to 2.0.0 (#6634)
a9a295fec More missing version changes
5c01ad387 Dart generated code update
42ca1b914 Swift/Kotlin generated code version updates
6ed780dbd C++/Rust version changes
3412fab8e C#/Java generated code version updates
8a7d013f8 Updated main version numbers to 2.0
170af5978 [Go] Add missing namespace when using Object API (#6633)
c8c16de16 Fix reverse iterators for Vector and Array (#6626)
4525cd9c5 [Lua] manipulate byte array as string (#6624)
47361baf6 [C++] Fix union copy constructor to work with nested structs (#6552) (#6607)
8a582883a Updates swift generated monster sample file (#6616)
a4bb8f0c2 [Lua] Avoid infinite loop when creating empty string (#6614)
82aed82b8 Added support for Lua 5.1, 5.2 and 5.4 (#6606)
60ff76630 [TS] Remove wrong and obsolete NS prefix use (#6604)
a27c7d809 Fixed LuaJIT when not compiled with COMPAT mode (#6605)
363220823 removed unneeded type prefixing (#6601)
6b44c605b Bump Rust to 0.9.0 (#6610)
d3cd78a87 [Lua] Add LuaJIT support (#6584)
8fa3dfdb5 Introduce new_from_vec in Rust (also fix formatting) (#6599)
29379e8e4 fix typo in CppUsage.md (#6595)
14725d6c3 [Lua] GetRootAs can accept strings. Made Luatest Benchmarks optional (#6593)
16836ff95 Add advance feature indicators to reflection (#6546)
c87179e73 Rust Remove SafeSliceAccess for Arrays, and fix miri. (#6592)
c24031c36 Mark endian_scalar as unsafe. (#6588)
4ccc52c7a [swift] Implements union strings (#6589)
b82fe0738 [Rust] Fix small mistyping (#6585)
1e7f6c8c7 [TS] Commit the generated tests code (#6579)
84714b109 chore: ensure bash is used to generate code (#6577)
1045d7dd4 [Lua] Fix EnforceNumberAndPack for bool type (#6576)
0c7777596 [TS] Remove duplicated build-ts ci (#6575)
c43ba1752 [Rust] Specify Minimum Supported Rust Version (#6573)
da3bb64ef [Rust] Add support for fixed size arrays (#6548)
151900ba9 [Kotlin][FlexBuffers] Add support for Kotlin-iOS (#6564)
c012f29f9 silenced clippy warning (#6565)
df2df21ec [Kotlin] Bump kotlinx.benchmark dependency to 0.3.0 (#6560)
408e4db4a [TS] Add Build TS to CI jobs (#6524)
4d2364f34 [Kotlin][FlexBuffers] Add support for Kotlin-JS (#6554)
261cf3b20 Default-empty vectors of enums (#6505)
cd67261bb [CI] fixes buildkite (#6544)
1aa0c2f6a Limit formatter to pull requests only (#6540)
4133a39df Rust structz (#6539)
1c26d2a1a [Kotlin][FlexBuffers] JSON support for Flexbuffers (#6417)
276b1bc34 [grpc] Support latest version of grpc PoC (#6338)
124654ffc fixed packing structs (#6530)
3b7d1e86b [GO] Tries to add go format to the CI (#6518)
78f0c0d1d [C++] #6501 - Problem when mapping a native type multiple times (#6514)
c992eafb5 [fuzzer] Add `monster_debug` target (#6513)
ef8dd7792 [Swift] Removes allman rule (#6519)
69b329fc8 [flexbuffers, json] Parse `nan` and `inf` (#6512)
6543ba529 fixed packing structs in nested buffers (#6509)
0e453ac35 [idl_parser] Add kTokenNumericConstant token (#6432)
e9b4ae69d Remove `flatbuffers.pc` from the repository (#6508)
fc4fffea4 Bump grpc to 1.0.0 (#6507)
b240ab704 Move Traits struct and Create method out of --cpp-static-reflection. (#6503)
9a4f1f434 Disable x64-specific optimizations for ARM64EC ReadInt64 (#6506)
fac64918d Add --cpp-static-reflection to generate_code.bat. (#6502)
a69815f72 [C++17] Add compile-time reflection for fields. (#6324)
4033ff589 fixed invalid TS call and added test files (#6495)
a08357251 disable clippy (#6494)
5319dedb1 [idl_parser, JSON] Disable parsing of JSON for incomplete schemes (#6493)
bd4e0b30a [idl_parser] Track included files by hash (#6434)
bf9061200 fix for noUncheckedIndexedAccess in ts (#6474)
8142fedd1 Working on a python example plus fixing python grpc code (#6456)
c0be1cb7a [rust] Remove debug code (#6475)
8cccdfba5 Revert "[C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)" (#6488)
cbbbaa61b [C#] Fix truncated ArraySegment<byte> if elementSize != 1 (#6462)
ffc2ef77c [CI] Adds Code Generation tests on Github Actions (#6482)
1da6f4f18 [CMake] generate pkg-config flatbuffers.pc file (#6455)
b5da526e6 [Swift] Moves grpc example to grpc/examples (#6479)
3b5365762 [TS] Moves grpc code to examples folder (#6476)
e2f5438ac Fixes grammer (#6477)
5e3613f73 Fix sample_binary.py to use latest EndVector without a size. (#6478)
e6b911d40 updated JS docs to reflect current status (#6436)
0c7ae5816 [Go] Working on a go example plus fixing go grpc code (#6448)
ae603b977 [Swift] adds support for default vectors and strings (#6461)
7f47718b6 Update Building.md (#6473)
54dc09e8a GetUOffsetT must get value by GetUint32 not GetInt32 (#6072)
334c6be49 Fix a typo in Swift codegen (#6470)
4174c10e7 [rust] Genericize flexbuffer reader (#6450)
a20f606c2 [Swift] Renaming protocols (#6469)
a72a20827 Update swift docs (#6460)
86401e078 Default strings and vectors: Parser + Rust support (#6421)
6af37e672 [CMake] Renames BUILD files (#6457)
1b88655b0 [Build, cmake] Add -Werror override option (#6429)
0b15916e5 [C++]Fix extra char generation for byte type during json schema generation (#6276)
60eed0ca6 Updating working code (#6441)
0f83367f5 JSON schema - tailing double quotes for maximum (#6452)
fee095410 [idl_parser] Validate `force_align` on all possible paths (#6430)
6f3e45eca Implement Rust object API defaults (#6444)
815d3e820 Upgrade swift grpc to alpha 24 (#6439)
76e7a0ff5 [fuzzer] Limit parser_fuzzer execution time (#6431)
6d91096a2 This commit contains the initial implementation of Flexbuffers in Kotlin. The code was ported based (#6387)
13d9e3585 Better python generated code naming (#6336)
6effe431b Rust: remove inner attributes (#6410)
efcbdc769 [Rust] Ensure unions are referenced with the correct path (#6422)
e581013e3 Refactor FieldDef to model presense as an enum rather than 2 bools. (#6420)
0984d4328 [c++] Apply NativeName before WrapInNameSpace in idl_gen_cpp.cpp (#6419)
786f69b24 Formats cpp code (#6349)
1da0a2dfa Rust Object API (#6070)
796ed68fa Clarify that (Flat|Flex)Buffers do not deduplicate vector elements (#6415)
7b1ee31d8 Clarify that FlatBuffers unions do not support scalars (#6416)
4aff1198d Explain how FlatBuffers encodes unions (#6414)
ad3a729f9 dart Builder - expose finished buffer size (#6403)
52e217706 Remove invalid claim that Protocol Buffers does not support unions (#6413)
760c65755 [TS/JS] New gen TS code gen (#6302)
75c859e98 [idl_parser] Improve symbols lookup thru parent namespaces (#6407)
91b0958c4 Search for includes in the directory containg the current file (#6371)
8008dde11 Upgrade Rust dependencies (#6406)
c81cf8249 [TS/JS] New gen TS code gen prequel to preserve history (#6404)
8573108bb Unset FieldDef.optional if its key (#6402)
7abe612b5 [fuzzer] Fix the binary schema loading in the monster_fuzzer (#6396)
408cf5802 Fix Rust UB problems (#6393)
39e115fdb Define Vector::value_type for STL compatibility (#6394)
85719669c [fuzzer] Debug the monster_tets.bfbs on clusterfuzz server (#6392)
809fe49c7 Fix up scripts, fix generated enum value for strong mode, regenerate files (#6389)
41253e574 [go] tests/GoTest.sh: Fix flags.Parse location to work on new go SDKs. (#6388)
08d2ce844 fix Dart Builder._writeString() - always write trailing zero byte (#6390)
a15a8d930 fix Dart Builder.reset() - clear vTables (#6386)
83ce29cc2 [C++, JSON] Fix nullptr access when reading a key with a default value. (#6375)
4363c1d2c Fix generated EndVector. (#6385)
1bf1ec027 Implements type promotion for Java enum (#6382)
080097653 Delete label_notify.yml
795408115 Disabled PHP CI (#6381)
46545e627 fixed warnings (#6355)
0168178a1 Fix multiple fbs code generation failure (#6365)
82836a62b [idl_parser] Improve stack overflow protection (#6364)
e7430bbeb [idl_parser] Check the range of explicitly set field's id value (#6363)
24dd85fd2 Generate code to encode and decode nested flatbuffers in Python. (#6354)
57f68e289 [Rust] Shared String (#6367)
44cf2bde1 Updates license date to 2021 (#6378)
be37d4da1 include_prefix support for rust (#6330)
4e79d129c [Swift] Rebuild the way swift handles structs from scratch (#6326)
05192553f Fix typos in usage/comments; Make rust generator respect to --filenam… (#6342)
f2511d7d4 Renaming infinity variables in test.cpp (#6340)
f8b203c9c Add vectorNumElements attribute to Builder for simpler vector creation. (#6328)
8ab7c7e2c [CI] Adds formatter to CI (#6272)
7e0039028 Fix Max CI build path (#6333)
65c415911 Generate nullable properties in C# object-based API for optional scalars. (without -gen-mutable) (#6273)
a9e91116d [Python] Commit some orphan python genfile diffs. (#6325)
80a745d9b Fixed missing ending quotes in labeller (#6327)
9fca5e4f4 Add flatc option to inhibit all warnings #6005 (#6301)
92a806b4e [fuzzer] Rename fuzzing dictionaries for `oss-fuzz` (#6318)
9c9baf6d5 bumprust (#6322)
aafc5dc95 Set default initialSize for Builder to 0 (#6310)
442949bc1 Rust Flatbuffers Verifier (#6269)
9064072e8 Version message should be a "STATUS" to avoid going to stderr. (#6316)
fd4c1b5ff Replace std::string and const char* CreateSharedString with string_view (#6315)
bc7eb8ade [fuzzer] Fix mistakes in the `parser` and `scalar` fuzzers. (#6314)
fc960f367 Add default to offset param of Python generated GetRootAs (#6312)
f437f0f7e [fuzzer] Fix loading of schema in monster_fuzzer (#6308)
7f33cf682 [C++] Switch `flatc` to `--cpp-std c++11` C++ code generator (#6306)
8d9eae9ac [idl_parser] Unify parsing of NaN values read from .fbs and .json files (#6296)
2046bffa4 Moved various language tests from AppVeyor to GitHub Actions (#6300)
git-subtree-dir: third_party/flatbuffers
git-subtree-split: e5f331db998a808f78cf5a4880e6f5d0a321c4d0
Signed-off-by: James Kuszmaul <jabukuszmaul+collab@gmail.com>
Change-Id: I37f8aaf007fc86226cfa250169a87807afa64a78
diff --git a/tests/monster_test/mod.rs b/tests/monster_test/mod.rs
new file mode 100644
index 0000000..fdbc26b
--- /dev/null
+++ b/tests/monster_test/mod.rs
@@ -0,0 +1,55 @@
+// Automatically generated by the Flatbuffers compiler. Do not modify.
+pub mod my_game {
+ use super::*;
+ pub mod example {
+ use super::*;
+ mod color_generated;
+ pub use self::color_generated::*;
+ mod race_generated;
+ pub use self::race_generated::*;
+ mod long_enum_generated;
+ pub use self::long_enum_generated::*;
+ mod any_generated;
+ pub use self::any_generated::*;
+ mod any_unique_aliases_generated;
+ pub use self::any_unique_aliases_generated::*;
+ mod any_ambiguous_aliases_generated;
+ pub use self::any_ambiguous_aliases_generated::*;
+ mod test_generated;
+ pub use self::test_generated::*;
+ mod test_simple_table_with_enum_generated;
+ pub use self::test_simple_table_with_enum_generated::*;
+ mod vec_3_generated;
+ pub use self::vec_3_generated::*;
+ mod ability_generated;
+ pub use self::ability_generated::*;
+ mod struct_of_structs_generated;
+ pub use self::struct_of_structs_generated::*;
+ mod stat_generated;
+ pub use self::stat_generated::*;
+ mod referrable_generated;
+ pub use self::referrable_generated::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ mod type_aliases_generated;
+ pub use self::type_aliases_generated::*;
+ } // example
+ pub mod example_2 {
+ use super::*;
+ mod monster_generated;
+ pub use self::monster_generated::*;
+ } // example_2
+ pub mod other_name_space {
+ use super::*;
+ mod from_include_generated;
+ pub use self::from_include_generated::*;
+ mod unused_generated;
+ pub use self::unused_generated::*;
+ mod table_b_generated;
+ pub use self::table_b_generated::*;
+ } // other_name_space
+ mod in_parent_namespace_generated;
+ pub use self::in_parent_namespace_generated::*;
+} // my_game
+mod table_a_generated;
+pub use self::table_a_generated::*;
diff --git a/tests/monster_test/my_game/example/ability_generated.rs b/tests/monster_test/my_game/example/ability_generated.rs
new file mode 100644
index 0000000..5746e8e
--- /dev/null
+++ b/tests/monster_test/my_game/example/ability_generated.rs
@@ -0,0 +1,166 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+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 std::fmt::Debug for Ability {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("Ability")
+ .field("id", &self.id())
+ .field("distance", &self.distance())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Ability {}
+impl flatbuffers::SafeSliceAccess for Ability {}
+impl<'a> flatbuffers::Follow<'a> for Ability {
+ type Inner = &'a Ability;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a Ability>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a Ability {
+ type Inner = &'a Ability;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<Ability>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for Ability {
+ type Output = Ability;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const Ability as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b Ability {
+ type Output = Ability;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const Ability as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Ability {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> Ability {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ id: u32,
+ distance: u32,
+ ) -> Self {
+ let mut s = Self([0; 8]);
+ s.set_id(id);
+ s.set_distance(distance);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Ability"
+ }
+
+ pub fn id(&self) -> u32 {
+ let mut mem = core::mem::MaybeUninit::<u32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<u32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_id(&mut self, x: u32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const u32 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<u32>(),
+ );
+ }
+ }
+
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Ability) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u32) -> ::std::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
+ pub fn distance(&self) -> u32 {
+ let mut mem = core::mem::MaybeUninit::<u32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<u32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_distance(&mut self, x: u32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const u32 as *const u8,
+ self.0[4..].as_mut_ptr(),
+ core::mem::size_of::<u32>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> AbilityT {
+ AbilityT {
+ id: self.id(),
+ distance: self.distance(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct AbilityT {
+ pub id: u32,
+ pub distance: u32,
+}
+impl AbilityT {
+ pub fn pack(&self) -> Ability {
+ Ability::new(
+ self.id,
+ self.distance,
+ )
+ }
+}
+
diff --git a/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
new file mode 100644
index 0000000..321007a
--- /dev/null
+++ b/tests/monster_test/my_game/example/any_ambiguous_aliases_generated.rs
@@ -0,0 +1,198 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_ANY_AMBIGUOUS_ALIASES: u8 = 0;
+#[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] = [
+ AnyAmbiguousAliases::NONE,
+ AnyAmbiguousAliases::M1,
+ AnyAmbiguousAliases::M2,
+ AnyAmbiguousAliases::M3,
+];
+
+#[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);
+ pub const M1: Self = Self(1);
+ pub const M2: Self = Self(2);
+ pub const M3: Self = Self(3);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M1,
+ Self::M2,
+ Self::M3,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M1 => Some("M1"),
+ Self::M2 => Some("M2"),
+ Self::M3 => Some("M3"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for AnyAmbiguousAliases {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for AnyAmbiguousAliases {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u8>(buf, loc)
+ };
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for AnyAmbiguousAliases {
+ type Output = AnyAmbiguousAliases;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for AnyAmbiguousAliases {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for AnyAmbiguousAliases {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for AnyAmbiguousAliases {}
+pub struct AnyAmbiguousAliasesUnionTableOffset {}
+
+#[allow(clippy::upper_case_acronyms)]
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub enum AnyAmbiguousAliasesT {
+ NONE,
+ M1(Box<MonsterT>),
+ M2(Box<MonsterT>),
+ M3(Box<MonsterT>),
+}
+impl Default for AnyAmbiguousAliasesT {
+ fn default() -> Self {
+ Self::NONE
+ }
+}
+impl AnyAmbiguousAliasesT {
+ pub fn any_ambiguous_aliases_type(&self) -> AnyAmbiguousAliases {
+ match self {
+ Self::NONE => AnyAmbiguousAliases::NONE,
+ Self::M1(_) => AnyAmbiguousAliases::M1,
+ Self::M2(_) => AnyAmbiguousAliases::M2,
+ Self::M3(_) => AnyAmbiguousAliases::M3,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::M1(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M3(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m1(&mut self) -> Option<Box<MonsterT>> {
+ if let Self::M1(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::M1(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m1(&self) -> Option<&MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m1_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M1(v) = self { Some(v.as_mut()) } else { None }
+ }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m2(&mut self) -> Option<Box<MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_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<Box<MonsterT>> {
+ if let Self::M3(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::M3(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m3(&self) -> Option<&MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m3_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M3(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
diff --git a/tests/monster_test/my_game/example/any_generated.rs b/tests/monster_test/my_game/example/any_generated.rs
new file mode 100644
index 0000000..6f7f6fd
--- /dev/null
+++ b/tests/monster_test/my_game/example/any_generated.rs
@@ -0,0 +1,198 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_ANY: u8 = 0;
+#[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] = [
+ Any::NONE,
+ Any::Monster,
+ Any::TestSimpleTableWithEnum,
+ Any::MyGame_Example2_Monster,
+];
+
+#[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);
+ pub const Monster: Self = Self(1);
+ pub const TestSimpleTableWithEnum: Self = Self(2);
+ pub const MyGame_Example2_Monster: Self = Self(3);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::Monster,
+ Self::TestSimpleTableWithEnum,
+ Self::MyGame_Example2_Monster,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::Monster => Some("Monster"),
+ Self::TestSimpleTableWithEnum => Some("TestSimpleTableWithEnum"),
+ Self::MyGame_Example2_Monster => Some("MyGame_Example2_Monster"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for Any {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for Any {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u8>(buf, loc)
+ };
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for Any {
+ type Output = Any;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for Any {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Any {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Any {}
+pub struct AnyUnionTableOffset {}
+
+#[allow(clippy::upper_case_acronyms)]
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub enum AnyT {
+ NONE,
+ Monster(Box<MonsterT>),
+ TestSimpleTableWithEnum(Box<TestSimpleTableWithEnumT>),
+ MyGameExample2Monster(Box<super::example_2::MonsterT>),
+}
+impl Default for AnyT {
+ fn default() -> Self {
+ Self::NONE
+ }
+}
+impl AnyT {
+ pub fn any_type(&self) -> Any {
+ match self {
+ Self::NONE => Any::NONE,
+ Self::Monster(_) => Any::Monster,
+ Self::TestSimpleTableWithEnum(_) => Any::TestSimpleTableWithEnum,
+ Self::MyGameExample2Monster(_) => Any::MyGame_Example2_Monster,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::Monster(v) => Some(v.pack(fbb).as_union_value()),
+ Self::TestSimpleTableWithEnum(v) => Some(v.pack(fbb).as_union_value()),
+ Self::MyGameExample2Monster(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_monster(&mut self) -> Option<Box<MonsterT>> {
+ if let Self::Monster(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_monster(&self) -> Option<&MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_monster_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::Monster(v) = self { Some(v.as_mut()) } else { None }
+ }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_test_simple_table_with_enum(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
+ if let Self::TestSimpleTableWithEnum(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::TestSimpleTableWithEnum(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the 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<Box<super::example_2::MonsterT>> {
+ if let Self::MyGameExample2Monster(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::MyGameExample2Monster(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_my_game_example_2_monster_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::MyGameExample2Monster(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
diff --git a/tests/monster_test/my_game/example/any_unique_aliases_generated.rs b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
new file mode 100644
index 0000000..1749d5d
--- /dev/null
+++ b/tests/monster_test/my_game/example/any_unique_aliases_generated.rs
@@ -0,0 +1,198 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_ANY_UNIQUE_ALIASES: u8 = 0;
+#[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] = [
+ AnyUniqueAliases::NONE,
+ AnyUniqueAliases::M,
+ AnyUniqueAliases::TS,
+ AnyUniqueAliases::M2,
+];
+
+#[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);
+ pub const M: Self = Self(1);
+ pub const TS: Self = Self(2);
+ pub const M2: Self = Self(3);
+
+ pub const ENUM_MIN: u8 = 0;
+ pub const ENUM_MAX: u8 = 3;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::NONE,
+ Self::M,
+ Self::TS,
+ Self::M2,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::NONE => Some("NONE"),
+ Self::M => Some("M"),
+ Self::TS => Some("TS"),
+ Self::M2 => Some("M2"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for AnyUniqueAliases {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for AnyUniqueAliases {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u8>(buf, loc)
+ };
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for AnyUniqueAliases {
+ type Output = AnyUniqueAliases;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for AnyUniqueAliases {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for AnyUniqueAliases {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for AnyUniqueAliases {}
+pub struct AnyUniqueAliasesUnionTableOffset {}
+
+#[allow(clippy::upper_case_acronyms)]
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub enum AnyUniqueAliasesT {
+ NONE,
+ M(Box<MonsterT>),
+ TS(Box<TestSimpleTableWithEnumT>),
+ M2(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 {
+ Self::NONE => AnyUniqueAliases::NONE,
+ Self::M(_) => AnyUniqueAliases::M,
+ Self::TS(_) => AnyUniqueAliases::TS,
+ Self::M2(_) => AnyUniqueAliases::M2,
+ }
+ }
+ pub fn pack(&self, fbb: &mut flatbuffers::FlatBufferBuilder) -> Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>> {
+ match self {
+ Self::NONE => None,
+ Self::M(v) => Some(v.pack(fbb).as_union_value()),
+ Self::TS(v) => Some(v.pack(fbb).as_union_value()),
+ Self::M2(v) => Some(v.pack(fbb).as_union_value()),
+ }
+ }
+ /// If the union variant matches, return the owned MonsterT, setting the union to NONE.
+ pub fn take_m(&mut self) -> Option<Box<MonsterT>> {
+ if let Self::M(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::M(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the MonsterT.
+ pub fn as_m(&self) -> Option<&MonsterT> {
+ if let Self::M(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the MonsterT.
+ pub fn as_m_mut(&mut self) -> Option<&mut MonsterT> {
+ if let Self::M(v) = self { Some(v.as_mut()) } else { None }
+ }
+ /// If the union variant matches, return the owned TestSimpleTableWithEnumT, setting the union to NONE.
+ pub fn take_ts(&mut self) -> Option<Box<TestSimpleTableWithEnumT>> {
+ if let Self::TS(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::TS(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the 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<Box<super::example_2::MonsterT>> {
+ if let Self::M2(_) = self {
+ let v = std::mem::replace(self, Self::NONE);
+ if let Self::M2(w) = v {
+ Some(w)
+ } else {
+ unreachable!()
+ }
+ } else {
+ None
+ }
+ }
+ /// If the union variant matches, return a reference to the super::example_2::MonsterT.
+ pub fn as_m2(&self) -> Option<&super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_ref()) } else { None }
+ }
+ /// If the union variant matches, return a mutable reference to the super::example_2::MonsterT.
+ pub fn as_m2_mut(&mut self) -> Option<&mut super::example_2::MonsterT> {
+ if let Self::M2(v) = self { Some(v.as_mut()) } else { None }
+ }
+}
diff --git a/tests/monster_test/my_game/example/color_generated.rs b/tests/monster_test/my_game/example/color_generated.rs
new file mode 100644
index 0000000..4a3282b
--- /dev/null
+++ b/tests/monster_test/my_game/example/color_generated.rs
@@ -0,0 +1,67 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[allow(non_upper_case_globals)]
+mod bitflags_color {
+ flatbuffers::bitflags::bitflags! {
+ /// Composite components of Monster color.
+ #[derive(Default)]
+ pub struct Color: u8 {
+ const Red = 1;
+ /// \brief color Green
+ /// Green is bit_flag with value (1u << 1)
+ const Green = 2;
+ /// \brief color Blue (1u << 3)
+ const Blue = 8;
+ }
+ }
+}
+pub use self::bitflags_color::Color;
+
+impl<'a> flatbuffers::Follow<'a> for Color {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u8>(buf, loc)
+ };
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+}
+
+impl flatbuffers::Push for Color {
+ type Output = Color;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u8>(dst, self.bits()); }
+ }
+}
+
+impl flatbuffers::EndianScalar for Color {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u8::to_le(self.bits());
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u8::from_le(self.bits());
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Color {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Color {}
diff --git a/tests/monster_test/my_game/example/long_enum_generated.rs b/tests/monster_test/my_game/example/long_enum_generated.rs
new file mode 100644
index 0000000..b22f826
--- /dev/null
+++ b/tests/monster_test/my_game/example/long_enum_generated.rs
@@ -0,0 +1,63 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[allow(non_upper_case_globals)]
+mod bitflags_long_enum {
+ flatbuffers::bitflags::bitflags! {
+ #[derive(Default)]
+ pub struct LongEnum: u64 {
+ const LongOne = 2;
+ const LongTwo = 4;
+ const LongBig = 1099511627776;
+ }
+ }
+}
+pub use self::bitflags_long_enum::LongEnum;
+
+impl<'a> flatbuffers::Follow<'a> for LongEnum {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<u64>(buf, loc)
+ };
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+}
+
+impl flatbuffers::Push for LongEnum {
+ type Output = LongEnum;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<u64>(dst, self.bits()); }
+ }
+}
+
+impl flatbuffers::EndianScalar for LongEnum {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = u64::to_le(self.bits());
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = u64::from_le(self.bits());
+ unsafe { Self::from_bits_unchecked(b) }
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for LongEnum {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ u64::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for LongEnum {}
diff --git a/tests/monster_test/my_game/example/monster_generated.rs b/tests/monster_test/my_game/example/monster_generated.rs
new file mode 100644
index 0000000..58e7628
--- /dev/null
+++ b/tests/monster_test/my_game/example/monster_generated.rs
@@ -0,0 +1,1628 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum MonsterOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+/// an example documentation comment: "monster object"
+pub struct Monster<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
+ type Inner = Monster<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Monster<'a> {
+ pub const VT_POS: flatbuffers::VOffsetT = 4;
+ pub const VT_MANA: flatbuffers::VOffsetT = 6;
+ pub const VT_HP: flatbuffers::VOffsetT = 8;
+ pub const VT_NAME: flatbuffers::VOffsetT = 10;
+ pub const VT_INVENTORY: flatbuffers::VOffsetT = 14;
+ pub const VT_COLOR: flatbuffers::VOffsetT = 16;
+ pub const VT_TEST_TYPE: flatbuffers::VOffsetT = 18;
+ pub const VT_TEST: flatbuffers::VOffsetT = 20;
+ pub const VT_TEST4: flatbuffers::VOffsetT = 22;
+ pub const VT_TESTARRAYOFSTRING: flatbuffers::VOffsetT = 24;
+ pub const VT_TESTARRAYOFTABLES: flatbuffers::VOffsetT = 26;
+ pub const VT_ENEMY: flatbuffers::VOffsetT = 28;
+ pub const VT_TESTNESTEDFLATBUFFER: flatbuffers::VOffsetT = 30;
+ pub const VT_TESTEMPTY: flatbuffers::VOffsetT = 32;
+ pub const VT_TESTBOOL: flatbuffers::VOffsetT = 34;
+ pub const VT_TESTHASHS32_FNV1: flatbuffers::VOffsetT = 36;
+ pub const VT_TESTHASHU32_FNV1: flatbuffers::VOffsetT = 38;
+ pub const VT_TESTHASHS64_FNV1: flatbuffers::VOffsetT = 40;
+ pub const VT_TESTHASHU64_FNV1: flatbuffers::VOffsetT = 42;
+ pub const VT_TESTHASHS32_FNV1A: flatbuffers::VOffsetT = 44;
+ pub const VT_TESTHASHU32_FNV1A: flatbuffers::VOffsetT = 46;
+ pub const VT_TESTHASHS64_FNV1A: flatbuffers::VOffsetT = 48;
+ pub const VT_TESTHASHU64_FNV1A: flatbuffers::VOffsetT = 50;
+ pub const VT_TESTARRAYOFBOOLS: flatbuffers::VOffsetT = 52;
+ pub const VT_TESTF: flatbuffers::VOffsetT = 54;
+ pub const VT_TESTF2: flatbuffers::VOffsetT = 56;
+ pub const VT_TESTF3: flatbuffers::VOffsetT = 58;
+ pub const VT_TESTARRAYOFSTRING2: flatbuffers::VOffsetT = 60;
+ pub const VT_TESTARRAYOFSORTEDSTRUCT: flatbuffers::VOffsetT = 62;
+ pub const VT_FLEX: flatbuffers::VOffsetT = 64;
+ pub const VT_TEST5: flatbuffers::VOffsetT = 66;
+ pub const VT_VECTOR_OF_LONGS: flatbuffers::VOffsetT = 68;
+ pub const VT_VECTOR_OF_DOUBLES: flatbuffers::VOffsetT = 70;
+ pub const VT_PARENT_NAMESPACE_TEST: flatbuffers::VOffsetT = 72;
+ pub const VT_VECTOR_OF_REFERRABLES: flatbuffers::VOffsetT = 74;
+ pub const VT_SINGLE_WEAK_REFERENCE: flatbuffers::VOffsetT = 76;
+ pub const VT_VECTOR_OF_WEAK_REFERENCES: flatbuffers::VOffsetT = 78;
+ pub const VT_VECTOR_OF_STRONG_REFERRABLES: flatbuffers::VOffsetT = 80;
+ pub const VT_CO_OWNING_REFERENCE: flatbuffers::VOffsetT = 82;
+ pub const VT_VECTOR_OF_CO_OWNING_REFERENCES: flatbuffers::VOffsetT = 84;
+ pub const VT_NON_OWNING_REFERENCE: flatbuffers::VOffsetT = 86;
+ pub const VT_VECTOR_OF_NON_OWNING_REFERENCES: flatbuffers::VOffsetT = 88;
+ pub const VT_ANY_UNIQUE_TYPE: flatbuffers::VOffsetT = 90;
+ pub const VT_ANY_UNIQUE: flatbuffers::VOffsetT = 92;
+ pub const VT_ANY_AMBIGUOUS_TYPE: flatbuffers::VOffsetT = 94;
+ pub const VT_ANY_AMBIGUOUS: flatbuffers::VOffsetT = 96;
+ pub const VT_VECTOR_OF_ENUMS: flatbuffers::VOffsetT = 98;
+ pub const VT_SIGNED_ENUM: flatbuffers::VOffsetT = 100;
+ pub const VT_TESTREQUIREDNESTEDFLATBUFFER: flatbuffers::VOffsetT = 102;
+ pub const VT_SCALAR_KEY_SORTED_TABLES: flatbuffers::VOffsetT = 104;
+ pub const VT_NATIVE_INLINE: flatbuffers::VOffsetT = 106;
+ pub const VT_LONG_ENUM_NON_ENUM_DEFAULT: flatbuffers::VOffsetT = 108;
+ pub const VT_LONG_ENUM_NORMAL_DEFAULT: flatbuffers::VOffsetT = 110;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Monster"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args MonsterArgs<'args>
+ ) -> flatbuffers::WIPOffset<Monster<'bldr>> {
+ let mut builder = MonsterBuilder::new(_fbb);
+ builder.add_long_enum_normal_default(args.long_enum_normal_default);
+ builder.add_long_enum_non_enum_default(args.long_enum_non_enum_default);
+ builder.add_non_owning_reference(args.non_owning_reference);
+ builder.add_co_owning_reference(args.co_owning_reference);
+ builder.add_single_weak_reference(args.single_weak_reference);
+ builder.add_testhashu64_fnv1a(args.testhashu64_fnv1a);
+ builder.add_testhashs64_fnv1a(args.testhashs64_fnv1a);
+ builder.add_testhashu64_fnv1(args.testhashu64_fnv1);
+ builder.add_testhashs64_fnv1(args.testhashs64_fnv1);
+ if let Some(x) = args.native_inline { builder.add_native_inline(x); }
+ if let Some(x) = args.scalar_key_sorted_tables { builder.add_scalar_key_sorted_tables(x); }
+ if let Some(x) = args.testrequirednestedflatbuffer { builder.add_testrequirednestedflatbuffer(x); }
+ if let Some(x) = args.vector_of_enums { builder.add_vector_of_enums(x); }
+ if let Some(x) = args.any_ambiguous { builder.add_any_ambiguous(x); }
+ if let Some(x) = args.any_unique { builder.add_any_unique(x); }
+ if let Some(x) = args.vector_of_non_owning_references { builder.add_vector_of_non_owning_references(x); }
+ if let Some(x) = args.vector_of_co_owning_references { builder.add_vector_of_co_owning_references(x); }
+ if let Some(x) = args.vector_of_strong_referrables { builder.add_vector_of_strong_referrables(x); }
+ if let Some(x) = args.vector_of_weak_references { builder.add_vector_of_weak_references(x); }
+ if let Some(x) = args.vector_of_referrables { builder.add_vector_of_referrables(x); }
+ if let Some(x) = args.parent_namespace_test { builder.add_parent_namespace_test(x); }
+ if let Some(x) = args.vector_of_doubles { builder.add_vector_of_doubles(x); }
+ if let Some(x) = args.vector_of_longs { builder.add_vector_of_longs(x); }
+ if let Some(x) = args.test5 { builder.add_test5(x); }
+ if let Some(x) = args.flex { builder.add_flex(x); }
+ if let Some(x) = args.testarrayofsortedstruct { builder.add_testarrayofsortedstruct(x); }
+ if let Some(x) = args.testarrayofstring2 { builder.add_testarrayofstring2(x); }
+ builder.add_testf3(args.testf3);
+ builder.add_testf2(args.testf2);
+ builder.add_testf(args.testf);
+ if let Some(x) = args.testarrayofbools { builder.add_testarrayofbools(x); }
+ builder.add_testhashu32_fnv1a(args.testhashu32_fnv1a);
+ builder.add_testhashs32_fnv1a(args.testhashs32_fnv1a);
+ builder.add_testhashu32_fnv1(args.testhashu32_fnv1);
+ builder.add_testhashs32_fnv1(args.testhashs32_fnv1);
+ if let Some(x) = args.testempty { builder.add_testempty(x); }
+ if let Some(x) = args.testnestedflatbuffer { builder.add_testnestedflatbuffer(x); }
+ if let Some(x) = args.enemy { builder.add_enemy(x); }
+ if let Some(x) = args.testarrayoftables { builder.add_testarrayoftables(x); }
+ if let Some(x) = args.testarrayofstring { builder.add_testarrayofstring(x); }
+ if let Some(x) = args.test4 { builder.add_test4(x); }
+ if let Some(x) = args.test { builder.add_test(x); }
+ if let Some(x) = args.inventory { builder.add_inventory(x); }
+ if let Some(x) = args.name { builder.add_name(x); }
+ if let Some(x) = args.pos { builder.add_pos(x); }
+ builder.add_hp(args.hp);
+ builder.add_mana(args.mana);
+ builder.add_signed_enum(args.signed_enum);
+ builder.add_any_ambiguous_type(args.any_ambiguous_type);
+ builder.add_any_unique_type(args.any_unique_type);
+ builder.add_testbool(args.testbool);
+ builder.add_test_type(args.test_type);
+ builder.add_color(args.color);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> MonsterT {
+ let pos = self.pos().map(|x| {
+ x.unpack()
+ });
+ let mana = self.mana();
+ let hp = self.hp();
+ let name = {
+ let x = self.name();
+ x.to_string()
+ };
+ let inventory = self.inventory().map(|x| {
+ x.to_vec()
+ });
+ let color = self.color();
+ let test = match self.test_type() {
+ Any::NONE => AnyT::NONE,
+ Any::Monster => AnyT::Monster(Box::new(
+ self.test_as_monster()
+ .expect("Invalid union table, expected `Any::Monster`.")
+ .unpack()
+ )),
+ Any::TestSimpleTableWithEnum => AnyT::TestSimpleTableWithEnum(Box::new(
+ self.test_as_test_simple_table_with_enum()
+ .expect("Invalid union table, expected `Any::TestSimpleTableWithEnum`.")
+ .unpack()
+ )),
+ Any::MyGame_Example2_Monster => AnyT::MyGameExample2Monster(Box::new(
+ self.test_as_my_game_example_2_monster()
+ .expect("Invalid union table, expected `Any::MyGame_Example2_Monster`.")
+ .unpack()
+ )),
+ _ => AnyT::NONE,
+ };
+ let test4 = self.test4().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let testarrayofstring = self.testarrayofstring().map(|x| {
+ x.iter().map(|s| s.to_string()).collect()
+ });
+ let testarrayoftables = self.testarrayoftables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let enemy = self.enemy().map(|x| {
+ Box::new(x.unpack())
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer().map(|x| {
+ x.to_vec()
+ });
+ let testempty = self.testempty().map(|x| {
+ Box::new(x.unpack())
+ });
+ let testbool = self.testbool();
+ let testhashs32_fnv1 = self.testhashs32_fnv1();
+ let testhashu32_fnv1 = self.testhashu32_fnv1();
+ let testhashs64_fnv1 = self.testhashs64_fnv1();
+ let testhashu64_fnv1 = self.testhashu64_fnv1();
+ let testhashs32_fnv1a = self.testhashs32_fnv1a();
+ let testhashu32_fnv1a = self.testhashu32_fnv1a();
+ let testhashs64_fnv1a = self.testhashs64_fnv1a();
+ let testhashu64_fnv1a = self.testhashu64_fnv1a();
+ let testarrayofbools = self.testarrayofbools().map(|x| {
+ x.to_vec()
+ });
+ let testf = self.testf();
+ let testf2 = self.testf2();
+ let testf3 = self.testf3();
+ let testarrayofstring2 = self.testarrayofstring2().map(|x| {
+ x.iter().map(|s| s.to_string()).collect()
+ });
+ let testarrayofsortedstruct = self.testarrayofsortedstruct().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let flex = self.flex().map(|x| {
+ x.to_vec()
+ });
+ let test5 = self.test5().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let vector_of_longs = self.vector_of_longs().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_doubles = self.vector_of_doubles().map(|x| {
+ x.into_iter().collect()
+ });
+ let parent_namespace_test = self.parent_namespace_test().map(|x| {
+ Box::new(x.unpack())
+ });
+ let vector_of_referrables = self.vector_of_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let single_weak_reference = self.single_weak_reference();
+ let vector_of_weak_references = self.vector_of_weak_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let vector_of_strong_referrables = self.vector_of_strong_referrables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let co_owning_reference = self.co_owning_reference();
+ let vector_of_co_owning_references = self.vector_of_co_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let non_owning_reference = self.non_owning_reference();
+ let vector_of_non_owning_references = self.vector_of_non_owning_references().map(|x| {
+ x.into_iter().collect()
+ });
+ let any_unique = match self.any_unique_type() {
+ AnyUniqueAliases::NONE => AnyUniqueAliasesT::NONE,
+ AnyUniqueAliases::M => AnyUniqueAliasesT::M(Box::new(
+ self.any_unique_as_m()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M`.")
+ .unpack()
+ )),
+ AnyUniqueAliases::TS => AnyUniqueAliasesT::TS(Box::new(
+ self.any_unique_as_ts()
+ .expect("Invalid union table, expected `AnyUniqueAliases::TS`.")
+ .unpack()
+ )),
+ AnyUniqueAliases::M2 => AnyUniqueAliasesT::M2(Box::new(
+ self.any_unique_as_m2()
+ .expect("Invalid union table, expected `AnyUniqueAliases::M2`.")
+ .unpack()
+ )),
+ _ => AnyUniqueAliasesT::NONE,
+ };
+ let any_ambiguous = match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::NONE => AnyAmbiguousAliasesT::NONE,
+ AnyAmbiguousAliases::M1 => AnyAmbiguousAliasesT::M1(Box::new(
+ self.any_ambiguous_as_m1()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M1`.")
+ .unpack()
+ )),
+ AnyAmbiguousAliases::M2 => AnyAmbiguousAliasesT::M2(Box::new(
+ self.any_ambiguous_as_m2()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M2`.")
+ .unpack()
+ )),
+ AnyAmbiguousAliases::M3 => AnyAmbiguousAliasesT::M3(Box::new(
+ self.any_ambiguous_as_m3()
+ .expect("Invalid union table, expected `AnyAmbiguousAliases::M3`.")
+ .unpack()
+ )),
+ _ => AnyAmbiguousAliasesT::NONE,
+ };
+ let vector_of_enums = self.vector_of_enums().map(|x| {
+ x.into_iter().collect()
+ });
+ let signed_enum = self.signed_enum();
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer().map(|x| {
+ x.to_vec()
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables().map(|x| {
+ x.iter().map(|t| t.unpack()).collect()
+ });
+ let native_inline = self.native_inline().map(|x| {
+ x.unpack()
+ });
+ let long_enum_non_enum_default = self.long_enum_non_enum_default();
+ let long_enum_normal_default = self.long_enum_normal_default();
+ MonsterT {
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ }
+ }
+
+ #[inline]
+ pub fn pos(&self) -> Option<&'a Vec3> {
+ self._tab.get::<Vec3>(Monster::VT_POS, None)
+ }
+ #[inline]
+ pub fn mana(&self) -> i16 {
+ self._tab.get::<i16>(Monster::VT_MANA, Some(150)).unwrap()
+ }
+ #[inline]
+ pub fn hp(&self) -> i16 {
+ self._tab.get::<i16>(Monster::VT_HP, Some(100)).unwrap()
+ }
+ #[inline]
+ pub fn name(&self) -> &'a str {
+ self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Monster::VT_NAME, None).unwrap()
+ }
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Monster) -> bool {
+ self.name() < o.name()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: & str) -> ::std::cmp::Ordering {
+ let key = self.name();
+ key.cmp(val)
+ }
+ #[inline]
+ pub fn inventory(&self) -> Option<&'a [u8]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_INVENTORY, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn color(&self) -> Color {
+ self._tab.get::<Color>(Monster::VT_COLOR, Some(Color::Blue)).unwrap()
+ }
+ #[inline]
+ pub fn test_type(&self) -> Any {
+ self._tab.get::<Any>(Monster::VT_TEST_TYPE, Some(Any::NONE)).unwrap()
+ }
+ #[inline]
+ pub fn test(&self) -> Option<flatbuffers::Table<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_TEST, None)
+ }
+ #[inline]
+ pub fn test4(&self) -> Option<&'a [Test]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST4, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn testarrayofstring(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING, None)
+ }
+ /// an example documentation comment: this will end up in the generated code
+ /// multiline too
+ #[inline]
+ pub fn testarrayoftables(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Monster<'a>>>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Monster>>>>(Monster::VT_TESTARRAYOFTABLES, None)
+ }
+ #[inline]
+ pub fn enemy(&self) -> Option<Monster<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<Monster>>(Monster::VT_ENEMY, None)
+ }
+ #[inline]
+ pub fn testnestedflatbuffer(&self) -> Option<&'a [u8]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTNESTEDFLATBUFFER, None).map(|v| v.safe_slice())
+ }
+ pub fn testnestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testnestedflatbuffer().map(|data| {
+ use flatbuffers::Follow;
+ <flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data, 0)
+ })
+ }
+ #[inline]
+ pub fn testempty(&self) -> Option<Stat<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<Stat>>(Monster::VT_TESTEMPTY, None)
+ }
+ #[inline]
+ pub fn testbool(&self) -> bool {
+ self._tab.get::<bool>(Monster::VT_TESTBOOL, Some(false)).unwrap()
+ }
+ #[inline]
+ pub fn testhashs32_fnv1(&self) -> i32 {
+ self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashu32_fnv1(&self) -> u32 {
+ self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashs64_fnv1(&self) -> i64 {
+ self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashu64_fnv1(&self) -> u64 {
+ self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashs32_fnv1a(&self) -> i32 {
+ self._tab.get::<i32>(Monster::VT_TESTHASHS32_FNV1A, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashu32_fnv1a(&self) -> u32 {
+ self._tab.get::<u32>(Monster::VT_TESTHASHU32_FNV1A, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashs64_fnv1a(&self) -> i64 {
+ self._tab.get::<i64>(Monster::VT_TESTHASHS64_FNV1A, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testhashu64_fnv1a(&self) -> u64 {
+ self._tab.get::<u64>(Monster::VT_TESTHASHU64_FNV1A, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn testarrayofbools(&self) -> Option<&'a [bool]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, bool>>>(Monster::VT_TESTARRAYOFBOOLS, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn testf(&self) -> f32 {
+ self._tab.get::<f32>(Monster::VT_TESTF, Some(3.14159)).unwrap()
+ }
+ #[inline]
+ pub fn testf2(&self) -> f32 {
+ self._tab.get::<f32>(Monster::VT_TESTF2, Some(3.0)).unwrap()
+ }
+ #[inline]
+ pub fn testf3(&self) -> f32 {
+ self._tab.get::<f32>(Monster::VT_TESTF3, Some(0.0)).unwrap()
+ }
+ #[inline]
+ pub fn testarrayofstring2(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>(Monster::VT_TESTARRAYOFSTRING2, None)
+ }
+ #[inline]
+ pub fn testarrayofsortedstruct(&self) -> Option<&'a [Ability]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Ability>>>(Monster::VT_TESTARRAYOFSORTEDSTRUCT, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn flex(&self) -> Option<&'a [u8]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_FLEX, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn test5(&self) -> Option<&'a [Test]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Test>>>(Monster::VT_TEST5, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn vector_of_longs(&self) -> Option<flatbuffers::Vector<'a, i64>> {
+ 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>> {
+ 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>> {
+ 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>>>> {
+ 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 {
+ 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>> {
+ 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>>>> {
+ 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 {
+ 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>> {
+ 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 {
+ 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>> {
+ 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 {
+ self._tab.get::<AnyUniqueAliases>(Monster::VT_ANY_UNIQUE_TYPE, Some(AnyUniqueAliases::NONE)).unwrap()
+ }
+ #[inline]
+ pub fn any_unique(&self) -> Option<flatbuffers::Table<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Table<'a>>>(Monster::VT_ANY_UNIQUE, None)
+ }
+ #[inline]
+ pub fn any_ambiguous_type(&self) -> AnyAmbiguousAliases {
+ self._tab.get::<AnyAmbiguousAliases>(Monster::VT_ANY_AMBIGUOUS_TYPE, Some(AnyAmbiguousAliases::NONE)).unwrap()
+ }
+ #[inline]
+ pub fn any_ambiguous(&self) -> Option<flatbuffers::Table<'a>> {
+ 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>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, Color>>>(Monster::VT_VECTOR_OF_ENUMS, None)
+ }
+ #[inline]
+ pub fn signed_enum(&self) -> Race {
+ self._tab.get::<Race>(Monster::VT_SIGNED_ENUM, Some(Race::None)).unwrap()
+ }
+ #[inline]
+ pub fn testrequirednestedflatbuffer(&self) -> Option<&'a [u8]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, u8>>>(Monster::VT_TESTREQUIREDNESTEDFLATBUFFER, None).map(|v| v.safe_slice())
+ }
+ pub fn testrequirednestedflatbuffer_nested_flatbuffer(&'a self) -> Option<Monster<'a>> {
+ self.testrequirednestedflatbuffer().map(|data| {
+ use flatbuffers::Follow;
+ <flatbuffers::ForwardsUOffset<Monster<'a>>>::follow(data, 0)
+ })
+ }
+ #[inline]
+ pub fn scalar_key_sorted_tables(&self) -> Option<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Stat<'a>>>> {
+ 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> {
+ self._tab.get::<Test>(Monster::VT_NATIVE_INLINE, None)
+ }
+ #[inline]
+ pub fn long_enum_non_enum_default(&self) -> LongEnum {
+ self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NON_ENUM_DEFAULT, Some(Default::default())).unwrap()
+ }
+ #[inline]
+ pub fn long_enum_normal_default(&self) -> LongEnum {
+ self._tab.get::<LongEnum>(Monster::VT_LONG_ENUM_NORMAL_DEFAULT, Some(LongEnum::LongOne)).unwrap()
+ }
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_monster(&self) -> Option<Monster<'a>> {
+ if self.test_type() == Any::Monster {
+ self.test().map(Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_test_simple_table_with_enum(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.test_type() == Any::TestSimpleTableWithEnum {
+ self.test().map(TestSimpleTableWithEnum::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn test_as_my_game_example_2_monster(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.test_type() == Any::MyGame_Example2_Monster {
+ self.test().map(super::example_2::Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m(&self) -> Option<Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M {
+ self.any_unique().map(Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_ts(&self) -> Option<TestSimpleTableWithEnum<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::TS {
+ self.any_unique().map(TestSimpleTableWithEnum::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_unique_as_m2(&self) -> Option<super::example_2::Monster<'a>> {
+ if self.any_unique_type() == AnyUniqueAliases::M2 {
+ self.any_unique().map(super::example_2::Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m1(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M1 {
+ self.any_ambiguous().map(Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m2(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M2 {
+ self.any_ambiguous().map(Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+ #[inline]
+ #[allow(non_snake_case)]
+ pub fn any_ambiguous_as_m3(&self) -> Option<Monster<'a>> {
+ if self.any_ambiguous_type() == AnyAmbiguousAliases::M3 {
+ self.any_ambiguous().map(Monster::init_from_table)
+ } else {
+ None
+ }
+ }
+
+}
+
+impl flatbuffers::Verifiable for Monster<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<Vec3>("pos", Self::VT_POS, false)?
+ .visit_field::<i16>("mana", Self::VT_MANA, false)?
+ .visit_field::<i16>("hp", Self::VT_HP, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>("name", Self::VT_NAME, true)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("inventory", Self::VT_INVENTORY, false)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .visit_union::<Any, _>("test_type", Self::VT_TEST_TYPE, "test", Self::VT_TEST, false, |key, v, pos| {
+ match key {
+ Any::Monster => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Monster>>("Any::Monster", pos),
+ Any::TestSimpleTableWithEnum => v.verify_union_variant::<flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("Any::TestSimpleTableWithEnum", pos),
+ Any::MyGame_Example2_Monster => v.verify_union_variant::<flatbuffers::ForwardsUOffset<super::example_2::Monster>>("Any::MyGame_Example2_Monster", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Test>>>("test4", Self::VT_TEST4, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring", Self::VT_TESTARRAYOFSTRING, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Monster>>>>("testarrayoftables", Self::VT_TESTARRAYOFTABLES, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Monster>>("enemy", Self::VT_ENEMY, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("testnestedflatbuffer", Self::VT_TESTNESTEDFLATBUFFER, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<Stat>>("testempty", Self::VT_TESTEMPTY, false)?
+ .visit_field::<bool>("testbool", Self::VT_TESTBOOL, false)?
+ .visit_field::<i32>("testhashs32_fnv1", Self::VT_TESTHASHS32_FNV1, false)?
+ .visit_field::<u32>("testhashu32_fnv1", Self::VT_TESTHASHU32_FNV1, false)?
+ .visit_field::<i64>("testhashs64_fnv1", Self::VT_TESTHASHS64_FNV1, false)?
+ .visit_field::<u64>("testhashu64_fnv1", Self::VT_TESTHASHU64_FNV1, false)?
+ .visit_field::<i32>("testhashs32_fnv1a", Self::VT_TESTHASHS32_FNV1A, false)?
+ .visit_field::<u32>("testhashu32_fnv1a", Self::VT_TESTHASHU32_FNV1A, false)?
+ .visit_field::<i64>("testhashs64_fnv1a", Self::VT_TESTHASHS64_FNV1A, false)?
+ .visit_field::<u64>("testhashu64_fnv1a", Self::VT_TESTHASHU64_FNV1A, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, bool>>>("testarrayofbools", Self::VT_TESTARRAYOFBOOLS, false)?
+ .visit_field::<f32>("testf", Self::VT_TESTF, false)?
+ .visit_field::<f32>("testf2", Self::VT_TESTF2, false)?
+ .visit_field::<f32>("testf3", Self::VT_TESTF3, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<&'_ str>>>>("testarrayofstring2", Self::VT_TESTARRAYOFSTRING2, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Ability>>>("testarrayofsortedstruct", Self::VT_TESTARRAYOFSORTEDSTRUCT, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("flex", Self::VT_FLEX, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Test>>>("test5", Self::VT_TEST5, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i64>>>("vector_of_longs", Self::VT_VECTOR_OF_LONGS, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, f64>>>("vector_of_doubles", Self::VT_VECTOR_OF_DOUBLES, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<super::InParentNamespace>>("parent_namespace_test", Self::VT_PARENT_NAMESPACE_TEST, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_referrables", Self::VT_VECTOR_OF_REFERRABLES, false)?
+ .visit_field::<u64>("single_weak_reference", Self::VT_SINGLE_WEAK_REFERENCE, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u64>>>("vector_of_weak_references", Self::VT_VECTOR_OF_WEAK_REFERENCES, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Referrable>>>>("vector_of_strong_referrables", Self::VT_VECTOR_OF_STRONG_REFERRABLES, false)?
+ .visit_field::<u64>("co_owning_reference", Self::VT_CO_OWNING_REFERENCE, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u64>>>("vector_of_co_owning_references", Self::VT_VECTOR_OF_CO_OWNING_REFERENCES, false)?
+ .visit_field::<u64>("non_owning_reference", Self::VT_NON_OWNING_REFERENCE, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u64>>>("vector_of_non_owning_references", Self::VT_VECTOR_OF_NON_OWNING_REFERENCES, false)?
+ .visit_union::<AnyUniqueAliases, _>("any_unique_type", Self::VT_ANY_UNIQUE_TYPE, "any_unique", Self::VT_ANY_UNIQUE, false, |key, v, pos| {
+ match key {
+ AnyUniqueAliases::M => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Monster>>("AnyUniqueAliases::M", pos),
+ AnyUniqueAliases::TS => v.verify_union_variant::<flatbuffers::ForwardsUOffset<TestSimpleTableWithEnum>>("AnyUniqueAliases::TS", pos),
+ AnyUniqueAliases::M2 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<super::example_2::Monster>>("AnyUniqueAliases::M2", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_union::<AnyAmbiguousAliases, _>("any_ambiguous_type", Self::VT_ANY_AMBIGUOUS_TYPE, "any_ambiguous", Self::VT_ANY_AMBIGUOUS, false, |key, v, pos| {
+ match key {
+ AnyAmbiguousAliases::M1 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M1", pos),
+ AnyAmbiguousAliases::M2 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M2", pos),
+ AnyAmbiguousAliases::M3 => v.verify_union_variant::<flatbuffers::ForwardsUOffset<Monster>>("AnyAmbiguousAliases::M3", pos),
+ _ => Ok(()),
+ }
+ })?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, Color>>>("vector_of_enums", Self::VT_VECTOR_OF_ENUMS, false)?
+ .visit_field::<Race>("signed_enum", Self::VT_SIGNED_ENUM, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, u8>>>("testrequirednestedflatbuffer", Self::VT_TESTREQUIREDNESTEDFLATBUFFER, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, flatbuffers::ForwardsUOffset<Stat>>>>("scalar_key_sorted_tables", Self::VT_SCALAR_KEY_SORTED_TABLES, false)?
+ .visit_field::<Test>("native_inline", Self::VT_NATIVE_INLINE, false)?
+ .visit_field::<LongEnum>("long_enum_non_enum_default", Self::VT_LONG_ENUM_NON_ENUM_DEFAULT, false)?
+ .visit_field::<LongEnum>("long_enum_normal_default", Self::VT_LONG_ENUM_NORMAL_DEFAULT, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct MonsterArgs<'a> {
+ pub pos: Option<&'a Vec3>,
+ pub mana: i16,
+ pub hp: i16,
+ pub name: Option<flatbuffers::WIPOffset<&'a str>>,
+ pub inventory: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
+ pub color: Color,
+ pub test_type: Any,
+ pub test: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
+ pub test4: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Test>>>,
+ pub testarrayofstring: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>,
+ pub testarrayoftables: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Monster<'a>>>>>,
+ pub enemy: Option<flatbuffers::WIPOffset<Monster<'a>>>,
+ pub testnestedflatbuffer: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
+ pub testempty: Option<flatbuffers::WIPOffset<Stat<'a>>>,
+ pub testbool: bool,
+ pub testhashs32_fnv1: i32,
+ pub testhashu32_fnv1: u32,
+ pub testhashs64_fnv1: i64,
+ pub testhashu64_fnv1: u64,
+ pub testhashs32_fnv1a: i32,
+ pub testhashu32_fnv1a: u32,
+ pub testhashs64_fnv1a: i64,
+ pub testhashu64_fnv1a: u64,
+ pub testarrayofbools: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, bool>>>,
+ pub testf: f32,
+ pub testf2: f32,
+ pub testf3: f32,
+ pub testarrayofstring2: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<&'a str>>>>,
+ pub testarrayofsortedstruct: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Ability>>>,
+ pub flex: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
+ pub test5: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Test>>>,
+ pub vector_of_longs: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, i64>>>,
+ pub vector_of_doubles: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, f64>>>,
+ pub parent_namespace_test: Option<flatbuffers::WIPOffset<super::InParentNamespace<'a>>>,
+ pub vector_of_referrables: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Referrable<'a>>>>>,
+ pub single_weak_reference: u64,
+ pub vector_of_weak_references: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u64>>>,
+ pub vector_of_strong_referrables: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Referrable<'a>>>>>,
+ pub co_owning_reference: u64,
+ pub vector_of_co_owning_references: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u64>>>,
+ pub non_owning_reference: u64,
+ pub vector_of_non_owning_references: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u64>>>,
+ pub any_unique_type: AnyUniqueAliases,
+ pub any_unique: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
+ pub any_ambiguous_type: AnyAmbiguousAliases,
+ pub any_ambiguous: Option<flatbuffers::WIPOffset<flatbuffers::UnionWIPOffset>>,
+ pub vector_of_enums: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, Color>>>,
+ pub signed_enum: Race,
+ pub testrequirednestedflatbuffer: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, u8>>>,
+ pub scalar_key_sorted_tables: Option<flatbuffers::WIPOffset<flatbuffers::Vector<'a, flatbuffers::ForwardsUOffset<Stat<'a>>>>>,
+ pub native_inline: Option<&'a Test>,
+ pub long_enum_non_enum_default: LongEnum,
+ pub long_enum_normal_default: LongEnum,
+}
+impl<'a> Default for MonsterArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: None, // required field
+ inventory: None,
+ color: Color::Blue,
+ test_type: Any::NONE,
+ test: None,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique_type: AnyUniqueAliases::NONE,
+ any_unique: None,
+ any_ambiguous_type: AnyAmbiguousAliases::NONE,
+ any_ambiguous: None,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ }
+ }
+}
+
+pub struct MonsterBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
+ #[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 new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MonsterBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ self.fbb_.required(o, Monster::VT_NAME,"name");
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("Monster");
+ ds.field("pos", &self.pos());
+ ds.field("mana", &self.mana());
+ ds.field("hp", &self.hp());
+ ds.field("name", &self.name());
+ ds.field("inventory", &self.inventory());
+ ds.field("color", &self.color());
+ ds.field("test_type", &self.test_type());
+ match self.test_type() {
+ Any::Monster => {
+ if let Some(x) = self.test_as_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::TestSimpleTableWithEnum => {
+ if let Some(x) = self.test_as_test_simple_table_with_enum() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ Any::MyGame_Example2_Monster => {
+ if let Some(x) = self.test_as_my_game_example_2_monster() {
+ ds.field("test", &x)
+ } else {
+ ds.field("test", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("test", &x)
+ },
+ };
+ ds.field("test4", &self.test4());
+ ds.field("testarrayofstring", &self.testarrayofstring());
+ ds.field("testarrayoftables", &self.testarrayoftables());
+ ds.field("enemy", &self.enemy());
+ ds.field("testnestedflatbuffer", &self.testnestedflatbuffer());
+ ds.field("testempty", &self.testempty());
+ ds.field("testbool", &self.testbool());
+ ds.field("testhashs32_fnv1", &self.testhashs32_fnv1());
+ ds.field("testhashu32_fnv1", &self.testhashu32_fnv1());
+ ds.field("testhashs64_fnv1", &self.testhashs64_fnv1());
+ ds.field("testhashu64_fnv1", &self.testhashu64_fnv1());
+ ds.field("testhashs32_fnv1a", &self.testhashs32_fnv1a());
+ ds.field("testhashu32_fnv1a", &self.testhashu32_fnv1a());
+ ds.field("testhashs64_fnv1a", &self.testhashs64_fnv1a());
+ ds.field("testhashu64_fnv1a", &self.testhashu64_fnv1a());
+ ds.field("testarrayofbools", &self.testarrayofbools());
+ ds.field("testf", &self.testf());
+ ds.field("testf2", &self.testf2());
+ ds.field("testf3", &self.testf3());
+ ds.field("testarrayofstring2", &self.testarrayofstring2());
+ ds.field("testarrayofsortedstruct", &self.testarrayofsortedstruct());
+ ds.field("flex", &self.flex());
+ ds.field("test5", &self.test5());
+ ds.field("vector_of_longs", &self.vector_of_longs());
+ ds.field("vector_of_doubles", &self.vector_of_doubles());
+ ds.field("parent_namespace_test", &self.parent_namespace_test());
+ ds.field("vector_of_referrables", &self.vector_of_referrables());
+ ds.field("single_weak_reference", &self.single_weak_reference());
+ ds.field("vector_of_weak_references", &self.vector_of_weak_references());
+ ds.field("vector_of_strong_referrables", &self.vector_of_strong_referrables());
+ ds.field("co_owning_reference", &self.co_owning_reference());
+ ds.field("vector_of_co_owning_references", &self.vector_of_co_owning_references());
+ ds.field("non_owning_reference", &self.non_owning_reference());
+ ds.field("vector_of_non_owning_references", &self.vector_of_non_owning_references());
+ ds.field("any_unique_type", &self.any_unique_type());
+ match self.any_unique_type() {
+ AnyUniqueAliases::M => {
+ if let Some(x) = self.any_unique_as_m() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::TS => {
+ if let Some(x) = self.any_unique_as_ts() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyUniqueAliases::M2 => {
+ if let Some(x) = self.any_unique_as_m2() {
+ ds.field("any_unique", &x)
+ } else {
+ ds.field("any_unique", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_unique", &x)
+ },
+ };
+ ds.field("any_ambiguous_type", &self.any_ambiguous_type());
+ match self.any_ambiguous_type() {
+ AnyAmbiguousAliases::M1 => {
+ if let Some(x) = self.any_ambiguous_as_m1() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M2 => {
+ if let Some(x) = self.any_ambiguous_as_m2() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ AnyAmbiguousAliases::M3 => {
+ if let Some(x) = self.any_ambiguous_as_m3() {
+ ds.field("any_ambiguous", &x)
+ } else {
+ ds.field("any_ambiguous", &"InvalidFlatbuffer: Union discriminant does not match value.")
+ }
+ },
+ _ => {
+ let x: Option<()> = None;
+ ds.field("any_ambiguous", &x)
+ },
+ };
+ ds.field("vector_of_enums", &self.vector_of_enums());
+ ds.field("signed_enum", &self.signed_enum());
+ ds.field("testrequirednestedflatbuffer", &self.testrequirednestedflatbuffer());
+ ds.field("scalar_key_sorted_tables", &self.scalar_key_sorted_tables());
+ ds.field("native_inline", &self.native_inline());
+ ds.field("long_enum_non_enum_default", &self.long_enum_non_enum_default());
+ ds.field("long_enum_normal_default", &self.long_enum_normal_default());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct MonsterT {
+ pub pos: Option<Vec3T>,
+ pub mana: i16,
+ pub hp: i16,
+ pub name: String,
+ pub inventory: Option<Vec<u8>>,
+ pub color: Color,
+ pub test: AnyT,
+ pub test4: Option<Vec<TestT>>,
+ pub testarrayofstring: Option<Vec<String>>,
+ pub testarrayoftables: Option<Vec<MonsterT>>,
+ pub enemy: Option<Box<MonsterT>>,
+ pub testnestedflatbuffer: Option<Vec<u8>>,
+ pub testempty: Option<Box<StatT>>,
+ pub testbool: bool,
+ pub testhashs32_fnv1: i32,
+ pub testhashu32_fnv1: u32,
+ pub testhashs64_fnv1: i64,
+ pub testhashu64_fnv1: u64,
+ pub testhashs32_fnv1a: i32,
+ pub testhashu32_fnv1a: u32,
+ pub testhashs64_fnv1a: i64,
+ pub testhashu64_fnv1a: u64,
+ pub testarrayofbools: Option<Vec<bool>>,
+ pub testf: f32,
+ pub testf2: f32,
+ pub testf3: f32,
+ pub testarrayofstring2: Option<Vec<String>>,
+ pub testarrayofsortedstruct: Option<Vec<AbilityT>>,
+ pub flex: Option<Vec<u8>>,
+ pub test5: Option<Vec<TestT>>,
+ pub vector_of_longs: Option<Vec<i64>>,
+ pub vector_of_doubles: Option<Vec<f64>>,
+ pub parent_namespace_test: Option<Box<super::InParentNamespaceT>>,
+ pub vector_of_referrables: Option<Vec<ReferrableT>>,
+ pub single_weak_reference: u64,
+ pub vector_of_weak_references: Option<Vec<u64>>,
+ pub vector_of_strong_referrables: Option<Vec<ReferrableT>>,
+ pub co_owning_reference: u64,
+ pub vector_of_co_owning_references: Option<Vec<u64>>,
+ pub non_owning_reference: u64,
+ pub vector_of_non_owning_references: Option<Vec<u64>>,
+ pub any_unique: AnyUniqueAliasesT,
+ pub any_ambiguous: AnyAmbiguousAliasesT,
+ pub vector_of_enums: Option<Vec<Color>>,
+ pub signed_enum: Race,
+ pub testrequirednestedflatbuffer: Option<Vec<u8>>,
+ pub scalar_key_sorted_tables: Option<Vec<StatT>>,
+ pub native_inline: Option<TestT>,
+ pub long_enum_non_enum_default: LongEnum,
+ pub long_enum_normal_default: LongEnum,
+}
+impl Default for MonsterT {
+ fn default() -> Self {
+ Self {
+ pos: None,
+ mana: 150,
+ hp: 100,
+ name: "".to_string(),
+ inventory: None,
+ color: Color::Blue,
+ test: AnyT::NONE,
+ test4: None,
+ testarrayofstring: None,
+ testarrayoftables: None,
+ enemy: None,
+ testnestedflatbuffer: None,
+ testempty: None,
+ testbool: false,
+ testhashs32_fnv1: 0,
+ testhashu32_fnv1: 0,
+ testhashs64_fnv1: 0,
+ testhashu64_fnv1: 0,
+ testhashs32_fnv1a: 0,
+ testhashu32_fnv1a: 0,
+ testhashs64_fnv1a: 0,
+ testhashu64_fnv1a: 0,
+ testarrayofbools: None,
+ testf: 3.14159,
+ testf2: 3.0,
+ testf3: 0.0,
+ testarrayofstring2: None,
+ testarrayofsortedstruct: None,
+ flex: None,
+ test5: None,
+ vector_of_longs: None,
+ vector_of_doubles: None,
+ parent_namespace_test: None,
+ vector_of_referrables: None,
+ single_weak_reference: 0,
+ vector_of_weak_references: None,
+ vector_of_strong_referrables: None,
+ co_owning_reference: 0,
+ vector_of_co_owning_references: None,
+ non_owning_reference: 0,
+ vector_of_non_owning_references: None,
+ any_unique: AnyUniqueAliasesT::NONE,
+ any_ambiguous: AnyAmbiguousAliasesT::NONE,
+ vector_of_enums: None,
+ signed_enum: Race::None,
+ testrequirednestedflatbuffer: None,
+ scalar_key_sorted_tables: None,
+ native_inline: None,
+ long_enum_non_enum_default: Default::default(),
+ long_enum_normal_default: LongEnum::LongOne,
+ }
+ }
+}
+impl MonsterT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Monster<'b>> {
+ let pos_tmp = self.pos.as_ref().map(|x| x.pack());
+ let pos = pos_tmp.as_ref();
+ let mana = self.mana;
+ let hp = self.hp;
+ let name = Some({
+ let x = &self.name;
+ _fbb.create_string(x)
+ });
+ let inventory = self.inventory.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let color = self.color;
+ let test_type = self.test.any_type();
+ let test = self.test.pack(_fbb);
+ let test4 = self.test4.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ let testarrayofstring = self.testarrayofstring.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|s| s.as_ref()).collect();_fbb.create_vector_of_strings(&w)
+ });
+ let testarrayoftables = self.testarrayoftables.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
+ });
+ let enemy = self.enemy.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let testnestedflatbuffer = self.testnestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testempty = self.testempty.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let testbool = self.testbool;
+ let testhashs32_fnv1 = self.testhashs32_fnv1;
+ let testhashu32_fnv1 = self.testhashu32_fnv1;
+ let testhashs64_fnv1 = self.testhashs64_fnv1;
+ let testhashu64_fnv1 = self.testhashu64_fnv1;
+ let testhashs32_fnv1a = self.testhashs32_fnv1a;
+ let testhashu32_fnv1a = self.testhashu32_fnv1a;
+ let testhashs64_fnv1a = self.testhashs64_fnv1a;
+ let testhashu64_fnv1a = self.testhashu64_fnv1a;
+ let testarrayofbools = self.testarrayofbools.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let testf = self.testf;
+ let testf2 = self.testf2;
+ let testf3 = self.testf3;
+ let testarrayofstring2 = self.testarrayofstring2.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|s| s.as_ref()).collect();_fbb.create_vector_of_strings(&w)
+ });
+ let testarrayofsortedstruct = self.testarrayofsortedstruct.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ let flex = self.flex.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let test5 = self.test5.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack()).collect();_fbb.create_vector(&w)
+ });
+ let vector_of_longs = self.vector_of_longs.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let vector_of_doubles = self.vector_of_doubles.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let parent_namespace_test = self.parent_namespace_test.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ let vector_of_referrables = self.vector_of_referrables.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
+ });
+ let single_weak_reference = self.single_weak_reference;
+ let vector_of_weak_references = self.vector_of_weak_references.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let vector_of_strong_referrables = self.vector_of_strong_referrables.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
+ });
+ let co_owning_reference = self.co_owning_reference;
+ let vector_of_co_owning_references = self.vector_of_co_owning_references.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let non_owning_reference = self.non_owning_reference;
+ let vector_of_non_owning_references = self.vector_of_non_owning_references.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let any_unique_type = self.any_unique.any_unique_aliases_type();
+ let any_unique = self.any_unique.pack(_fbb);
+ let any_ambiguous_type = self.any_ambiguous.any_ambiguous_aliases_type();
+ let any_ambiguous = self.any_ambiguous.pack(_fbb);
+ let vector_of_enums = self.vector_of_enums.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let signed_enum = self.signed_enum;
+ let testrequirednestedflatbuffer = self.testrequirednestedflatbuffer.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let scalar_key_sorted_tables = self.scalar_key_sorted_tables.as_ref().map(|x|{
+ let w: Vec<_> = x.iter().map(|t| t.pack(_fbb)).collect();_fbb.create_vector(&w)
+ });
+ let native_inline_tmp = self.native_inline.as_ref().map(|x| x.pack());
+ let native_inline = native_inline_tmp.as_ref();
+ let long_enum_non_enum_default = self.long_enum_non_enum_default;
+ let long_enum_normal_default = self.long_enum_normal_default;
+ Monster::create(_fbb, &MonsterArgs{
+ pos,
+ mana,
+ hp,
+ name,
+ inventory,
+ color,
+ test_type,
+ test,
+ test4,
+ testarrayofstring,
+ testarrayoftables,
+ enemy,
+ testnestedflatbuffer,
+ testempty,
+ testbool,
+ testhashs32_fnv1,
+ testhashu32_fnv1,
+ testhashs64_fnv1,
+ testhashu64_fnv1,
+ testhashs32_fnv1a,
+ testhashu32_fnv1a,
+ testhashs64_fnv1a,
+ testhashu64_fnv1a,
+ testarrayofbools,
+ testf,
+ testf2,
+ testf3,
+ testarrayofstring2,
+ testarrayofsortedstruct,
+ flex,
+ test5,
+ vector_of_longs,
+ vector_of_doubles,
+ parent_namespace_test,
+ vector_of_referrables,
+ single_weak_reference,
+ vector_of_weak_references,
+ vector_of_strong_referrables,
+ co_owning_reference,
+ vector_of_co_owning_references,
+ non_owning_reference,
+ vector_of_non_owning_references,
+ any_unique_type,
+ any_unique,
+ any_ambiguous_type,
+ any_ambiguous,
+ vector_of_enums,
+ signed_enum,
+ testrequirednestedflatbuffer,
+ scalar_key_sorted_tables,
+ native_inline,
+ long_enum_non_enum_default,
+ long_enum_normal_default,
+ })
+ }
+}
+#[inline]
+#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
+pub fn get_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
+ unsafe { flatbuffers::root_unchecked::<Monster<'a>>(buf) }
+}
+
+#[inline]
+#[deprecated(since="2.0.0", note="Deprecated in favor of `root_as...` methods.")]
+pub fn get_size_prefixed_root_as_monster<'a>(buf: &'a [u8]) -> Monster<'a> {
+ unsafe { flatbuffers::size_prefixed_root_unchecked::<Monster<'a>>(buf) }
+}
+
+#[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`.
+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`.
+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`.
+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`.
+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`.
+pub unsafe fn root_as_monster_unchecked(buf: &[u8]) -> Monster {
+ flatbuffers::root_unchecked::<Monster>(buf)
+}
+#[inline]
+/// Assumes, without verification, that a buffer of bytes contains a size prefixed Monster and returns it.
+/// # Safety
+/// Callers must trust the given bytes do indeed contain a valid size prefixed `Monster`.
+pub unsafe fn size_prefixed_root_as_monster_unchecked(buf: &[u8]) -> Monster {
+ flatbuffers::size_prefixed_root_unchecked::<Monster>(buf)
+}
+pub const MONSTER_IDENTIFIER: &str = "MONS";
+
+#[inline]
+pub fn monster_buffer_has_identifier(buf: &[u8]) -> bool {
+ flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, false)
+}
+
+#[inline]
+pub fn monster_size_prefixed_buffer_has_identifier(buf: &[u8]) -> bool {
+ flatbuffers::buffer_has_identifier(buf, MONSTER_IDENTIFIER, true)
+}
+
+pub const MONSTER_EXTENSION: &str = "mon";
+
+#[inline]
+pub fn finish_monster_buffer<'a, 'b>(
+ fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ root: flatbuffers::WIPOffset<Monster<'a>>) {
+ fbb.finish(root, Some(MONSTER_IDENTIFIER));
+}
+
+#[inline]
+pub fn finish_size_prefixed_monster_buffer<'a, 'b>(fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>, root: flatbuffers::WIPOffset<Monster<'a>>) {
+ fbb.finish_size_prefixed(root, Some(MONSTER_IDENTIFIER));
+}
diff --git a/tests/monster_test/my_game/example/race_generated.rs b/tests/monster_test/my_game/example/race_generated.rs
new file mode 100644
index 0000000..ab012f9
--- /dev/null
+++ b/tests/monster_test/my_game/example/race_generated.rs
@@ -0,0 +1,101 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_RACE: i8 = -1;
+#[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] = [
+ Race::None,
+ Race::Human,
+ Race::Dwarf,
+ Race::Elf,
+];
+
+#[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);
+ pub const Human: Self = Self(0);
+ pub const Dwarf: Self = Self(1);
+ pub const Elf: Self = Self(2);
+
+ pub const ENUM_MIN: i8 = -1;
+ pub const ENUM_MAX: i8 = 2;
+ pub const ENUM_VALUES: &'static [Self] = &[
+ Self::None,
+ Self::Human,
+ Self::Dwarf,
+ Self::Elf,
+ ];
+ /// Returns the variant's name or "" if unknown.
+ pub fn variant_name(self) -> Option<&'static str> {
+ match self {
+ Self::None => Some("None"),
+ Self::Human => Some("Human"),
+ Self::Dwarf => Some("Dwarf"),
+ Self::Elf => Some("Elf"),
+ _ => None,
+ }
+ }
+}
+impl std::fmt::Debug for Race {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(name) = self.variant_name() {
+ f.write_str(name)
+ } else {
+ f.write_fmt(format_args!("<UNKNOWN {:?}>", self.0))
+ }
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for Race {
+ type Inner = Self;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ let b = unsafe {
+ flatbuffers::read_scalar_at::<i8>(buf, loc)
+ };
+ Self(b)
+ }
+}
+
+impl flatbuffers::Push for Race {
+ type Output = Race;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<i8>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for Race {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = i8::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = i8::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Race {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ i8::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Race {}
diff --git a/tests/monster_test/my_game/example/referrable_generated.rs b/tests/monster_test/my_game/example/referrable_generated.rs
new file mode 100644
index 0000000..877e3b8
--- /dev/null
+++ b/tests/monster_test/my_game/example/referrable_generated.rs
@@ -0,0 +1,143 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum ReferrableOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct Referrable<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Referrable<'a> {
+ type Inner = Referrable<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Referrable<'a> {
+ pub const VT_ID: flatbuffers::VOffsetT = 4;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Referrable"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args ReferrableArgs
+ ) -> flatbuffers::WIPOffset<Referrable<'bldr>> {
+ let mut builder = ReferrableBuilder::new(_fbb);
+ builder.add_id(args.id);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> ReferrableT {
+ let id = self.id();
+ ReferrableT {
+ id,
+ }
+ }
+
+ #[inline]
+ pub fn id(&self) -> u64 {
+ self._tab.get::<u64>(Referrable::VT_ID, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Referrable) -> bool {
+ self.id() < o.id()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u64) -> ::std::cmp::Ordering {
+ let key = self.id();
+ key.cmp(&val)
+ }
+}
+
+impl flatbuffers::Verifiable for Referrable<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<u64>("id", Self::VT_ID, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct ReferrableArgs {
+ pub id: u64,
+}
+impl<'a> Default for ReferrableArgs {
+ #[inline]
+ fn default() -> Self {
+ ReferrableArgs {
+ id: 0,
+ }
+ }
+}
+
+pub struct ReferrableBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> ReferrableBuilder<'a, 'b> {
+ #[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>) -> ReferrableBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ ReferrableBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Referrable<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for Referrable<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("Referrable");
+ ds.field("id", &self.id());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct ReferrableT {
+ pub id: u64,
+}
+impl Default for ReferrableT {
+ fn default() -> Self {
+ Self {
+ id: 0,
+ }
+ }
+}
+impl ReferrableT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Referrable<'b>> {
+ let id = self.id;
+ Referrable::create(_fbb, &ReferrableArgs{
+ id,
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/example/stat_generated.rs b/tests/monster_test/my_game/example/stat_generated.rs
new file mode 100644
index 0000000..d6e5fad
--- /dev/null
+++ b/tests/monster_test/my_game/example/stat_generated.rs
@@ -0,0 +1,187 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum StatOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct Stat<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Stat<'a> {
+ type Inner = Stat<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Stat<'a> {
+ pub const VT_ID: flatbuffers::VOffsetT = 4;
+ pub const VT_VAL: flatbuffers::VOffsetT = 6;
+ pub const VT_COUNT: flatbuffers::VOffsetT = 8;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Stat"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args StatArgs<'args>
+ ) -> flatbuffers::WIPOffset<Stat<'bldr>> {
+ let mut builder = StatBuilder::new(_fbb);
+ builder.add_val(args.val);
+ if let Some(x) = args.id { builder.add_id(x); }
+ builder.add_count(args.count);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> StatT {
+ let id = self.id().map(|x| {
+ x.to_string()
+ });
+ let val = self.val();
+ let count = self.count();
+ StatT {
+ id,
+ val,
+ count,
+ }
+ }
+
+ #[inline]
+ pub fn id(&self) -> Option<&'a str> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<&str>>(Stat::VT_ID, None)
+ }
+ #[inline]
+ pub fn val(&self) -> i64 {
+ self._tab.get::<i64>(Stat::VT_VAL, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn count(&self) -> u16 {
+ self._tab.get::<u16>(Stat::VT_COUNT, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn key_compare_less_than(&self, o: &Stat) -> bool {
+ self.count() < o.count()
+ }
+
+ #[inline]
+ pub fn key_compare_with_value(&self, val: u16) -> ::std::cmp::Ordering {
+ let key = self.count();
+ key.cmp(&val)
+ }
+}
+
+impl flatbuffers::Verifiable for Stat<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<&str>>("id", Self::VT_ID, false)?
+ .visit_field::<i64>("val", Self::VT_VAL, false)?
+ .visit_field::<u16>("count", Self::VT_COUNT, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct StatArgs<'a> {
+ pub id: Option<flatbuffers::WIPOffset<&'a str>>,
+ pub val: i64,
+ pub count: u16,
+}
+impl<'a> Default for StatArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ StatArgs {
+ id: None,
+ val: 0,
+ count: 0,
+ }
+ }
+}
+
+pub struct StatBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> StatBuilder<'a, 'b> {
+ #[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>) -> StatBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ StatBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Stat<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for Stat<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("Stat");
+ ds.field("id", &self.id());
+ ds.field("val", &self.val());
+ ds.field("count", &self.count());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct StatT {
+ pub id: Option<String>,
+ pub val: i64,
+ pub count: u16,
+}
+impl Default for StatT {
+ fn default() -> Self {
+ Self {
+ id: None,
+ val: 0,
+ count: 0,
+ }
+ }
+}
+impl StatT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Stat<'b>> {
+ let id = self.id.as_ref().map(|x|{
+ _fbb.create_string(x)
+ });
+ let val = self.val;
+ let count = self.count;
+ Stat::create(_fbb, &StatArgs{
+ id,
+ val,
+ count,
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/example/struct_of_structs_generated.rs b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
new file mode 100644
index 0000000..9994f7e
--- /dev/null
+++ b/tests/monster_test/my_game/example/struct_of_structs_generated.rs
@@ -0,0 +1,143 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+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 std::fmt::Debug for StructOfStructs {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("StructOfStructs")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .field("c", &self.c())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for StructOfStructs {}
+impl flatbuffers::SafeSliceAccess for StructOfStructs {}
+impl<'a> flatbuffers::Follow<'a> for StructOfStructs {
+ type Inner = &'a StructOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a StructOfStructs>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a StructOfStructs {
+ type Inner = &'a StructOfStructs;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<StructOfStructs>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for StructOfStructs {
+ type Output = StructOfStructs;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const StructOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b StructOfStructs {
+ type Output = StructOfStructs;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const StructOfStructs as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for StructOfStructs {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> StructOfStructs {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: &Ability,
+ b: &Test,
+ c: &Ability,
+ ) -> Self {
+ let mut s = Self([0; 20]);
+ s.set_a(a);
+ s.set_b(b);
+ s.set_c(c);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.StructOfStructs"
+ }
+
+ pub fn a(&self) -> &Ability {
+ unsafe { &*(self.0[0..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_a(&mut self, x: &Ability) {
+ self.0[0..0 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn b(&self) -> &Test {
+ unsafe { &*(self.0[8..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_b(&mut self, x: &Test) {
+ self.0[8..8 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn c(&self) -> &Ability {
+ unsafe { &*(self.0[12..].as_ptr() as *const Ability) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_c(&mut self, x: &Ability) {
+ self.0[12..12 + 8].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> StructOfStructsT {
+ StructOfStructsT {
+ a: self.a().unpack(),
+ b: self.b().unpack(),
+ c: self.c().unpack(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct StructOfStructsT {
+ pub a: AbilityT,
+ pub b: TestT,
+ pub c: AbilityT,
+}
+impl StructOfStructsT {
+ pub fn pack(&self) -> StructOfStructs {
+ StructOfStructs::new(
+ &self.a.pack(),
+ &self.b.pack(),
+ &self.c.pack(),
+ )
+ }
+}
+
diff --git a/tests/monster_test/my_game/example/test_generated.rs b/tests/monster_test/my_game/example/test_generated.rs
new file mode 100644
index 0000000..187b7cd
--- /dev/null
+++ b/tests/monster_test/my_game/example/test_generated.rs
@@ -0,0 +1,156 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+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 std::fmt::Debug for Test {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("Test")
+ .field("a", &self.a())
+ .field("b", &self.b())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Test {}
+impl flatbuffers::SafeSliceAccess for Test {}
+impl<'a> flatbuffers::Follow<'a> for Test {
+ type Inner = &'a Test;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a Test>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a Test {
+ type Inner = &'a Test;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<Test>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for Test {
+ type Output = Test;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const Test as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b Test {
+ type Output = Test;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const Test as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Test {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> Test {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ a: i16,
+ b: i8,
+ ) -> Self {
+ let mut s = Self([0; 4]);
+ s.set_a(a);
+ s.set_b(b);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Test"
+ }
+
+ pub fn a(&self) -> i16 {
+ let mut mem = core::mem::MaybeUninit::<i16>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i16>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_a(&mut self, x: i16) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i16 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<i16>(),
+ );
+ }
+ }
+
+ pub fn b(&self) -> i8 {
+ let mut mem = core::mem::MaybeUninit::<i8>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[2..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i8>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_b(&mut self, x: i8) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i8 as *const u8,
+ self.0[2..].as_mut_ptr(),
+ core::mem::size_of::<i8>(),
+ );
+ }
+ }
+
+ pub fn unpack(&self) -> TestT {
+ TestT {
+ a: self.a(),
+ b: self.b(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct TestT {
+ pub a: i16,
+ pub b: i8,
+}
+impl TestT {
+ pub fn pack(&self) -> Test {
+ Test::new(
+ self.a,
+ self.b,
+ )
+ }
+}
+
diff --git a/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
new file mode 100644
index 0000000..6ebe31f
--- /dev/null
+++ b/tests/monster_test/my_game/example/test_simple_table_with_enum_generated.rs
@@ -0,0 +1,133 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum TestSimpleTableWithEnumOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct TestSimpleTableWithEnum<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for TestSimpleTableWithEnum<'a> {
+ type Inner = TestSimpleTableWithEnum<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> TestSimpleTableWithEnum<'a> {
+ pub const VT_COLOR: flatbuffers::VOffsetT = 4;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TestSimpleTableWithEnum"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args TestSimpleTableWithEnumArgs
+ ) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'bldr>> {
+ let mut builder = TestSimpleTableWithEnumBuilder::new(_fbb);
+ builder.add_color(args.color);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TestSimpleTableWithEnumT {
+ let color = self.color();
+ TestSimpleTableWithEnumT {
+ color,
+ }
+ }
+
+ #[inline]
+ pub fn color(&self) -> Color {
+ self._tab.get::<Color>(TestSimpleTableWithEnum::VT_COLOR, Some(Color::Green)).unwrap()
+ }
+}
+
+impl flatbuffers::Verifiable for TestSimpleTableWithEnum<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<Color>("color", Self::VT_COLOR, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct TestSimpleTableWithEnumArgs {
+ pub color: Color,
+}
+impl<'a> Default for TestSimpleTableWithEnumArgs {
+ #[inline]
+ fn default() -> Self {
+ TestSimpleTableWithEnumArgs {
+ color: Color::Green,
+ }
+ }
+}
+
+pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> TestSimpleTableWithEnumBuilder<'a, 'b> {
+ #[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>) -> TestSimpleTableWithEnumBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ TestSimpleTableWithEnumBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for TestSimpleTableWithEnum<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("TestSimpleTableWithEnum");
+ ds.field("color", &self.color());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct TestSimpleTableWithEnumT {
+ pub color: Color,
+}
+impl Default for TestSimpleTableWithEnumT {
+ fn default() -> Self {
+ Self {
+ color: Color::Green,
+ }
+ }
+}
+impl TestSimpleTableWithEnumT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<TestSimpleTableWithEnum<'b>> {
+ let color = self.color;
+ TestSimpleTableWithEnum::create(_fbb, &TestSimpleTableWithEnumArgs{
+ color,
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/example/type_aliases_generated.rs b/tests/monster_test/my_game/example/type_aliases_generated.rs
new file mode 100644
index 0000000..5b3ede5
--- /dev/null
+++ b/tests/monster_test/my_game/example/type_aliases_generated.rs
@@ -0,0 +1,361 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum TypeAliasesOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct TypeAliases<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for TypeAliases<'a> {
+ type Inner = TypeAliases<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> TypeAliases<'a> {
+ pub const VT_I8_: flatbuffers::VOffsetT = 4;
+ pub const VT_U8_: flatbuffers::VOffsetT = 6;
+ pub const VT_I16_: flatbuffers::VOffsetT = 8;
+ pub const VT_U16_: flatbuffers::VOffsetT = 10;
+ pub const VT_I32_: flatbuffers::VOffsetT = 12;
+ pub const VT_U32_: flatbuffers::VOffsetT = 14;
+ pub const VT_I64_: flatbuffers::VOffsetT = 16;
+ pub const VT_U64_: flatbuffers::VOffsetT = 18;
+ pub const VT_F32_: flatbuffers::VOffsetT = 20;
+ pub const VT_F64_: flatbuffers::VOffsetT = 22;
+ pub const VT_V8: flatbuffers::VOffsetT = 24;
+ pub const VT_VF64: flatbuffers::VOffsetT = 26;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.TypeAliases"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args TypeAliasesArgs<'args>
+ ) -> flatbuffers::WIPOffset<TypeAliases<'bldr>> {
+ let mut builder = TypeAliasesBuilder::new(_fbb);
+ builder.add_f64_(args.f64_);
+ builder.add_u64_(args.u64_);
+ builder.add_i64_(args.i64_);
+ if let Some(x) = args.vf64 { builder.add_vf64(x); }
+ if let Some(x) = args.v8 { builder.add_v8(x); }
+ builder.add_f32_(args.f32_);
+ builder.add_u32_(args.u32_);
+ builder.add_i32_(args.i32_);
+ builder.add_u16_(args.u16_);
+ builder.add_i16_(args.i16_);
+ builder.add_u8_(args.u8_);
+ builder.add_i8_(args.i8_);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TypeAliasesT {
+ let i8_ = self.i8_();
+ let u8_ = self.u8_();
+ let i16_ = self.i16_();
+ let u16_ = self.u16_();
+ let i32_ = self.i32_();
+ let u32_ = self.u32_();
+ let i64_ = self.i64_();
+ let u64_ = self.u64_();
+ let f32_ = self.f32_();
+ let f64_ = self.f64_();
+ let v8 = self.v8().map(|x| {
+ x.to_vec()
+ });
+ let vf64 = self.vf64().map(|x| {
+ x.into_iter().collect()
+ });
+ TypeAliasesT {
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ }
+ }
+
+ #[inline]
+ pub fn i8_(&self) -> i8 {
+ self._tab.get::<i8>(TypeAliases::VT_I8_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn u8_(&self) -> u8 {
+ self._tab.get::<u8>(TypeAliases::VT_U8_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn i16_(&self) -> i16 {
+ self._tab.get::<i16>(TypeAliases::VT_I16_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn u16_(&self) -> u16 {
+ self._tab.get::<u16>(TypeAliases::VT_U16_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn i32_(&self) -> i32 {
+ self._tab.get::<i32>(TypeAliases::VT_I32_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn u32_(&self) -> u32 {
+ self._tab.get::<u32>(TypeAliases::VT_U32_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn i64_(&self) -> i64 {
+ self._tab.get::<i64>(TypeAliases::VT_I64_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn u64_(&self) -> u64 {
+ self._tab.get::<u64>(TypeAliases::VT_U64_, Some(0)).unwrap()
+ }
+ #[inline]
+ pub fn f32_(&self) -> f32 {
+ self._tab.get::<f32>(TypeAliases::VT_F32_, Some(0.0)).unwrap()
+ }
+ #[inline]
+ pub fn f64_(&self) -> f64 {
+ self._tab.get::<f64>(TypeAliases::VT_F64_, Some(0.0)).unwrap()
+ }
+ #[inline]
+ pub fn v8(&self) -> Option<&'a [i8]> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, i8>>>(TypeAliases::VT_V8, None).map(|v| v.safe_slice())
+ }
+ #[inline]
+ pub fn vf64(&self) -> Option<flatbuffers::Vector<'a, f64>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'a, f64>>>(TypeAliases::VT_VF64, None)
+ }
+}
+
+impl flatbuffers::Verifiable for TypeAliases<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<i8>("i8_", Self::VT_I8_, false)?
+ .visit_field::<u8>("u8_", Self::VT_U8_, false)?
+ .visit_field::<i16>("i16_", Self::VT_I16_, false)?
+ .visit_field::<u16>("u16_", Self::VT_U16_, false)?
+ .visit_field::<i32>("i32_", Self::VT_I32_, false)?
+ .visit_field::<u32>("u32_", Self::VT_U32_, false)?
+ .visit_field::<i64>("i64_", Self::VT_I64_, false)?
+ .visit_field::<u64>("u64_", Self::VT_U64_, false)?
+ .visit_field::<f32>("f32_", Self::VT_F32_, false)?
+ .visit_field::<f64>("f64_", Self::VT_F64_, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, i8>>>("v8", Self::VT_V8, false)?
+ .visit_field::<flatbuffers::ForwardsUOffset<flatbuffers::Vector<'_, f64>>>("vf64", Self::VT_VF64, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct TypeAliasesArgs<'a> {
+ pub i8_: i8,
+ pub u8_: u8,
+ pub i16_: i16,
+ pub u16_: u16,
+ pub i32_: i32,
+ pub u32_: u32,
+ pub i64_: i64,
+ pub u64_: u64,
+ pub f32_: f32,
+ pub f64_: f64,
+ pub v8: Option<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 {
+ TypeAliasesArgs {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
+ }
+}
+
+pub struct TypeAliasesBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> TypeAliasesBuilder<'a, 'b> {
+ #[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>) -> TypeAliasesBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ TypeAliasesBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<TypeAliases<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for TypeAliases<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("TypeAliases");
+ ds.field("i8_", &self.i8_());
+ ds.field("u8_", &self.u8_());
+ ds.field("i16_", &self.i16_());
+ ds.field("u16_", &self.u16_());
+ ds.field("i32_", &self.i32_());
+ ds.field("u32_", &self.u32_());
+ ds.field("i64_", &self.i64_());
+ ds.field("u64_", &self.u64_());
+ ds.field("f32_", &self.f32_());
+ ds.field("f64_", &self.f64_());
+ ds.field("v8", &self.v8());
+ ds.field("vf64", &self.vf64());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct TypeAliasesT {
+ pub i8_: i8,
+ pub u8_: u8,
+ pub i16_: i16,
+ pub u16_: u16,
+ pub i32_: i32,
+ pub u32_: u32,
+ pub i64_: i64,
+ pub u64_: u64,
+ pub f32_: f32,
+ pub f64_: f64,
+ pub v8: Option<Vec<i8>>,
+ pub vf64: Option<Vec<f64>>,
+}
+impl Default for TypeAliasesT {
+ fn default() -> Self {
+ Self {
+ i8_: 0,
+ u8_: 0,
+ i16_: 0,
+ u16_: 0,
+ i32_: 0,
+ u32_: 0,
+ i64_: 0,
+ u64_: 0,
+ f32_: 0.0,
+ f64_: 0.0,
+ v8: None,
+ vf64: None,
+ }
+ }
+}
+impl TypeAliasesT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<TypeAliases<'b>> {
+ let i8_ = self.i8_;
+ let u8_ = self.u8_;
+ let i16_ = self.i16_;
+ let u16_ = self.u16_;
+ let i32_ = self.i32_;
+ let u32_ = self.u32_;
+ let i64_ = self.i64_;
+ let u64_ = self.u64_;
+ let f32_ = self.f32_;
+ let f64_ = self.f64_;
+ let v8 = self.v8.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ let vf64 = self.vf64.as_ref().map(|x|{
+ _fbb.create_vector(x)
+ });
+ TypeAliases::create(_fbb, &TypeAliasesArgs{
+ i8_,
+ u8_,
+ i16_,
+ u16_,
+ i32_,
+ u32_,
+ i64_,
+ u64_,
+ f32_,
+ f64_,
+ v8,
+ vf64,
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/example/vec_3_generated.rs b/tests/monster_test/my_game/example/vec_3_generated.rs
new file mode 100644
index 0000000..e5a25bb
--- /dev/null
+++ b/tests/monster_test/my_game/example/vec_3_generated.rs
@@ -0,0 +1,258 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+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 std::fmt::Debug for Vec3 {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("Vec3")
+ .field("x", &self.x())
+ .field("y", &self.y())
+ .field("z", &self.z())
+ .field("test1", &self.test1())
+ .field("test2", &self.test2())
+ .field("test3", &self.test3())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Vec3 {}
+impl flatbuffers::SafeSliceAccess for Vec3 {}
+impl<'a> flatbuffers::Follow<'a> for Vec3 {
+ type Inner = &'a Vec3;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a Vec3>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a Vec3 {
+ type Inner = &'a Vec3;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<Vec3>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for Vec3 {
+ type Output = Vec3;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const Vec3 as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b Vec3 {
+ type Output = Vec3;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const Vec3 as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Vec3 {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.in_buffer::<Self>(pos)
+ }
+}
+
+impl<'a> Vec3 {
+ #[allow(clippy::too_many_arguments)]
+ pub fn new(
+ x: f32,
+ y: f32,
+ z: f32,
+ test1: f64,
+ test2: Color,
+ test3: &Test,
+ ) -> Self {
+ let mut s = Self([0; 32]);
+ s.set_x(x);
+ s.set_y(y);
+ s.set_z(z);
+ s.set_test1(test1);
+ s.set_test2(test2);
+ s.set_test3(test3);
+ s
+ }
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example.Vec3"
+ }
+
+ pub fn x(&self) -> f32 {
+ let mut mem = core::mem::MaybeUninit::<f32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<f32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_x(&mut self, x: f32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const f32 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<f32>(),
+ );
+ }
+ }
+
+ pub fn y(&self) -> f32 {
+ let mut mem = core::mem::MaybeUninit::<f32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[4..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<f32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_y(&mut self, x: f32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const f32 as *const u8,
+ self.0[4..].as_mut_ptr(),
+ core::mem::size_of::<f32>(),
+ );
+ }
+ }
+
+ pub fn z(&self) -> f32 {
+ let mut mem = core::mem::MaybeUninit::<f32>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[8..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<f32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_z(&mut self, x: f32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const f32 as *const u8,
+ self.0[8..].as_mut_ptr(),
+ core::mem::size_of::<f32>(),
+ );
+ }
+ }
+
+ pub fn test1(&self) -> f64 {
+ let mut mem = core::mem::MaybeUninit::<f64>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[16..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<f64>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_test1(&mut self, x: f64) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const f64 as *const u8,
+ self.0[16..].as_mut_ptr(),
+ core::mem::size_of::<f64>(),
+ );
+ }
+ }
+
+ pub fn test2(&self) -> Color {
+ let mut mem = core::mem::MaybeUninit::<Color>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[24..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<Color>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_test2(&mut self, x: Color) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const Color as *const u8,
+ self.0[24..].as_mut_ptr(),
+ core::mem::size_of::<Color>(),
+ );
+ }
+ }
+
+ pub fn test3(&self) -> &Test {
+ unsafe { &*(self.0[26..].as_ptr() as *const Test) }
+ }
+
+ #[allow(clippy::identity_op)]
+ pub fn set_test3(&mut self, x: &Test) {
+ self.0[26..26 + 4].copy_from_slice(&x.0)
+ }
+
+ pub fn unpack(&self) -> Vec3T {
+ Vec3T {
+ x: self.x(),
+ y: self.y(),
+ z: self.z(),
+ test1: self.test1(),
+ test2: self.test2(),
+ test3: self.test3().unpack(),
+ }
+ }
+}
+
+#[derive(Debug, Clone, PartialEq, Default)]
+pub struct Vec3T {
+ pub x: f32,
+ pub y: f32,
+ pub z: f32,
+ pub test1: f64,
+ pub test2: Color,
+ pub test3: TestT,
+}
+impl Vec3T {
+ pub fn pack(&self) -> Vec3 {
+ Vec3::new(
+ self.x,
+ self.y,
+ self.z,
+ self.test1,
+ self.test2,
+ &self.test3.pack(),
+ )
+ }
+}
+
diff --git a/tests/monster_test/my_game/example_2/monster_generated.rs b/tests/monster_test/my_game/example_2/monster_generated.rs
new file mode 100644
index 0000000..54384b5
--- /dev/null
+++ b/tests/monster_test/my_game/example_2/monster_generated.rs
@@ -0,0 +1,112 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum MonsterOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct Monster<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for Monster<'a> {
+ type Inner = Monster<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> Monster<'a> {
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.Example2.Monster"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ _args: &'args MonsterArgs
+ ) -> flatbuffers::WIPOffset<Monster<'bldr>> {
+ let mut builder = MonsterBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> MonsterT {
+ MonsterT {
+ }
+ }
+}
+
+impl flatbuffers::Verifiable for Monster<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct MonsterArgs {
+}
+impl<'a> Default for MonsterArgs {
+ #[inline]
+ fn default() -> Self {
+ MonsterArgs {
+ }
+ }
+}
+
+pub struct MonsterBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> MonsterBuilder<'a, 'b> {
+ #[inline]
+ pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> MonsterBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ MonsterBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<Monster<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for Monster<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("Monster");
+ 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>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<Monster<'b>> {
+ Monster::create(_fbb, &MonsterArgs{
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/in_parent_namespace_generated.rs b/tests/monster_test/my_game/in_parent_namespace_generated.rs
new file mode 100644
index 0000000..aabd4b8
--- /dev/null
+++ b/tests/monster_test/my_game/in_parent_namespace_generated.rs
@@ -0,0 +1,112 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum InParentNamespaceOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct InParentNamespace<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for InParentNamespace<'a> {
+ type Inner = InParentNamespace<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> InParentNamespace<'a> {
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "MyGame.InParentNamespace"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ _args: &'args InParentNamespaceArgs
+ ) -> flatbuffers::WIPOffset<InParentNamespace<'bldr>> {
+ let mut builder = InParentNamespaceBuilder::new(_fbb);
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> InParentNamespaceT {
+ InParentNamespaceT {
+ }
+ }
+}
+
+impl flatbuffers::Verifiable for InParentNamespace<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct InParentNamespaceArgs {
+}
+impl<'a> Default for InParentNamespaceArgs {
+ #[inline]
+ fn default() -> Self {
+ InParentNamespaceArgs {
+ }
+ }
+}
+
+pub struct InParentNamespaceBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> InParentNamespaceBuilder<'a, 'b> {
+ #[inline]
+ pub fn new(_fbb: &'b mut flatbuffers::FlatBufferBuilder<'a>) -> InParentNamespaceBuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ InParentNamespaceBuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<InParentNamespace<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for InParentNamespace<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("InParentNamespace");
+ 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>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<InParentNamespace<'b>> {
+ InParentNamespace::create(_fbb, &InParentNamespaceArgs{
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/other_name_space/from_include_generated.rs b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
new file mode 100644
index 0000000..048bafd
--- /dev/null
+++ b/tests/monster_test/my_game/other_name_space/from_include_generated.rs
@@ -0,0 +1,89 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+#[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]
+pub const ENUM_MIN_FROM_INCLUDE: i64 = 0;
+#[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,
+];
+
+#[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 std::fmt::Debug for FromInclude {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::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]
+ 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]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ unsafe { flatbuffers::emplace_scalar::<i64>(dst, self.0); }
+ }
+}
+
+impl flatbuffers::EndianScalar for FromInclude {
+ #[inline]
+ fn to_little_endian(self) -> Self {
+ let b = i64::to_le(self.0);
+ Self(b)
+ }
+ #[inline]
+ #[allow(clippy::wrong_self_convention)]
+ fn from_little_endian(self) -> Self {
+ let b = i64::from_le(self.0);
+ Self(b)
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for FromInclude {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ i64::run_verifier(v, pos)
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for FromInclude {}
diff --git a/tests/monster_test/my_game/other_name_space/table_b_generated.rs b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
new file mode 100644
index 0000000..46a99cb
--- /dev/null
+++ b/tests/monster_test/my_game/other_name_space/table_b_generated.rs
@@ -0,0 +1,137 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum TableBOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct TableB<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for TableB<'a> {
+ type Inner = TableB<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { 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 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ 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| {
+ Box::new(x.unpack())
+ });
+ TableBT {
+ a,
+ }
+ }
+
+ #[inline]
+ pub fn a(&self) -> Option<super::super::TableA<'a>> {
+ 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> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<super::super::TableA>>("a", Self::VT_A, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct TableBArgs<'a> {
+ pub a: Option<flatbuffers::WIPOffset<super::super::TableA<'a>>>,
+}
+impl<'a> Default for TableBArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableBArgs {
+ a: None,
+ }
+ }
+}
+
+pub struct TableBBuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> TableBBuilder<'a, 'b> {
+ #[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>) -> TableBBuilder<'a, 'b> {
+ 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 std::fmt::Debug for TableB<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::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<Box<super::super::TableAT>>,
+}
+impl Default for TableBT {
+ fn default() -> Self {
+ Self {
+ a: None,
+ }
+ }
+}
+impl TableBT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<TableB<'b>> {
+ let a = self.a.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableB::create(_fbb, &TableBArgs{
+ a,
+ })
+ }
+}
diff --git a/tests/monster_test/my_game/other_name_space/unused_generated.rs b/tests/monster_test/my_game/other_name_space/unused_generated.rs
new file mode 100644
index 0000000..1dc5913
--- /dev/null
+++ b/tests/monster_test/my_game/other_name_space/unused_generated.rs
@@ -0,0 +1,127 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+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 std::fmt::Debug for Unused {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ f.debug_struct("Unused")
+ .field("a", &self.a())
+ .finish()
+ }
+}
+
+impl flatbuffers::SimpleToVerifyInSlice for Unused {}
+impl flatbuffers::SafeSliceAccess for Unused {}
+impl<'a> flatbuffers::Follow<'a> for Unused {
+ type Inner = &'a Unused;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ <&'a Unused>::follow(buf, loc)
+ }
+}
+impl<'a> flatbuffers::Follow<'a> for &'a Unused {
+ type Inner = &'a Unused;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ flatbuffers::follow_cast_ref::<Unused>(buf, loc)
+ }
+}
+impl<'b> flatbuffers::Push for Unused {
+ type Output = Unused;
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(self as *const Unused as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+impl<'b> flatbuffers::Push for &'b Unused {
+ type Output = Unused;
+
+ #[inline]
+ fn push(&self, dst: &mut [u8], _rest: &[u8]) {
+ let src = unsafe {
+ ::std::slice::from_raw_parts(*self as *const Unused as *const u8, Self::size())
+ };
+ dst.copy_from_slice(src);
+ }
+}
+
+impl<'a> flatbuffers::Verifiable for Unused {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ 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>::uninit();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ self.0[0..].as_ptr(),
+ mem.as_mut_ptr() as *mut u8,
+ core::mem::size_of::<i32>(),
+ );
+ mem.assume_init()
+ }.from_little_endian()
+ }
+
+ pub fn set_a(&mut self, x: i32) {
+ let x_le = x.to_little_endian();
+ unsafe {
+ core::ptr::copy_nonoverlapping(
+ &x_le as *const i32 as *const u8,
+ self.0[0..].as_mut_ptr(),
+ core::mem::size_of::<i32>(),
+ );
+ }
+ }
+
+ 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,
+ )
+ }
+}
+
diff --git a/tests/monster_test/table_a_generated.rs b/tests/monster_test/table_a_generated.rs
new file mode 100644
index 0000000..9188b29
--- /dev/null
+++ b/tests/monster_test/table_a_generated.rs
@@ -0,0 +1,137 @@
+// automatically generated by the FlatBuffers compiler, do not modify
+extern crate flatbuffers;
+use std::mem;
+use std::cmp::Ordering;
+use self::flatbuffers::{EndianScalar, Follow};
+use super::*;
+pub enum TableAOffset {}
+#[derive(Copy, Clone, PartialEq)]
+
+pub struct TableA<'a> {
+ pub _tab: flatbuffers::Table<'a>,
+}
+
+impl<'a> flatbuffers::Follow<'a> for TableA<'a> {
+ type Inner = TableA<'a>;
+ #[inline]
+ fn follow(buf: &'a [u8], loc: usize) -> Self::Inner {
+ Self { _tab: flatbuffers::Table { buf, loc } }
+ }
+}
+
+impl<'a> TableA<'a> {
+ pub const VT_B: flatbuffers::VOffsetT = 4;
+
+ pub const fn get_fully_qualified_name() -> &'static str {
+ "TableA"
+ }
+
+ #[inline]
+ pub 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>(
+ _fbb: &'mut_bldr mut flatbuffers::FlatBufferBuilder<'bldr>,
+ args: &'args TableAArgs<'args>
+ ) -> flatbuffers::WIPOffset<TableA<'bldr>> {
+ let mut builder = TableABuilder::new(_fbb);
+ if let Some(x) = args.b { builder.add_b(x); }
+ builder.finish()
+ }
+
+ pub fn unpack(&self) -> TableAT {
+ let b = self.b().map(|x| {
+ Box::new(x.unpack())
+ });
+ TableAT {
+ b,
+ }
+ }
+
+ #[inline]
+ pub fn b(&self) -> Option<my_game::other_name_space::TableB<'a>> {
+ self._tab.get::<flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>(TableA::VT_B, None)
+ }
+}
+
+impl flatbuffers::Verifiable for TableA<'_> {
+ #[inline]
+ fn run_verifier(
+ v: &mut flatbuffers::Verifier, pos: usize
+ ) -> Result<(), flatbuffers::InvalidFlatbuffer> {
+ use self::flatbuffers::Verifiable;
+ v.visit_table(pos)?
+ .visit_field::<flatbuffers::ForwardsUOffset<my_game::other_name_space::TableB>>("b", Self::VT_B, false)?
+ .finish();
+ Ok(())
+ }
+}
+pub struct TableAArgs<'a> {
+ pub b: Option<flatbuffers::WIPOffset<my_game::other_name_space::TableB<'a>>>,
+}
+impl<'a> Default for TableAArgs<'a> {
+ #[inline]
+ fn default() -> Self {
+ TableAArgs {
+ b: None,
+ }
+ }
+}
+
+pub struct TableABuilder<'a: 'b, 'b> {
+ fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
+ start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
+}
+impl<'a: 'b, 'b> TableABuilder<'a, 'b> {
+ #[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>) -> TableABuilder<'a, 'b> {
+ let start = _fbb.start_table();
+ TableABuilder {
+ fbb_: _fbb,
+ start_: start,
+ }
+ }
+ #[inline]
+ pub fn finish(self) -> flatbuffers::WIPOffset<TableA<'a>> {
+ let o = self.fbb_.end_table(self.start_);
+ flatbuffers::WIPOffset::new(o.value())
+ }
+}
+
+impl std::fmt::Debug for TableA<'_> {
+ fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
+ let mut ds = f.debug_struct("TableA");
+ ds.field("b", &self.b());
+ ds.finish()
+ }
+}
+#[non_exhaustive]
+#[derive(Debug, Clone, PartialEq)]
+pub struct TableAT {
+ pub b: Option<Box<my_game::other_name_space::TableBT>>,
+}
+impl Default for TableAT {
+ fn default() -> Self {
+ Self {
+ b: None,
+ }
+ }
+}
+impl TableAT {
+ pub fn pack<'b>(
+ &self,
+ _fbb: &mut flatbuffers::FlatBufferBuilder<'b>
+ ) -> flatbuffers::WIPOffset<TableA<'b>> {
+ let b = self.b.as_ref().map(|x|{
+ x.pack(_fbb)
+ });
+ TableA::create(_fbb, &TableAArgs{
+ b,
+ })
+ }
+}