FlatBuffers: Memory Efficient Serialization Library
Go to file
Max Burke 355dfd48d1 [rust] Make enum names public (#5690)
* Bugfix for Rust generation of union fields named with language keywords

Looking at ParseField, it appears that in the case of unions, an extra field with a `UnionTypeFieldSuffix` is added to the type definition, however, if the name of this field is a keyword in the target language, it isn't escaped.

For example, if generating code for rust for a union field named `type`, flatc will generate a (non-keyword escaped) field named `type_type` for this hidden union field, and one (keyword escaped) called `type_` for the actual union contents.

When the union accessors are generated, they refer to this `type_type` field, but they will escape it mistakenly, generating code like this:

```
  #[inline]
  #[allow(non_snake_case)]
  pub fn type__as_int(&self) -> Option<Int<'a>> {
    if self.type__type() == Type::Int {
      self.type_().map(|u| Int::init_from_table(u))
    } else {
      None
    }
  }
```

Which will fail to build because the field is called `self.type_type()`, not `self.type__type()`.

* [Rust] Add crate-relative use statements for FBS includes.

At present if a flatbuffer description includes a reference to a type in
another file, the generated Rust code needs to be hand-modified to add
the appropriate `use` statements.

This assumes that the dependencies are built into the same crate, which
I think is a reasonable assumption?

* Revert "[Rust] Add crate-relative use statements for FBS includes."

This reverts commit d554d79fec.

* Address comments raised in PR

* Update documentation comments per feedback

* Fix typo

* [rust] Make enum variant names public.

* Update generated test files

* Add test for public enum names
2019-12-31 10:28:58 -08:00
.appveyor Add support for fixed-size arrays (#5313) 2019-06-18 00:15:13 +02:00
.bazelci Don't test on Ubuntu 14.04 (#5302) 2019-04-24 10:28:35 -07:00
.github Improved pull request & clang-format instructions. 2019-11-07 14:37:33 -08:00
.travis Add testing of C++ with sanitizers (CI-Docker) (#5631) 2019-11-18 12:16:41 -08:00
CMake Add RPM packaging support (#5177) 2019-02-21 20:06:04 +01:00
android Removed idl_gen_general.cpp and move contents to code_generators.cpp (#5625) 2019-11-14 15:47:58 -08:00
conan Update Conan version Automatically (#5027) 2018-11-12 08:49:42 -08:00
dart [Dart] Fix prepare space for writeListInt64 and writeListUint64 (#5654) 2019-12-18 11:23:54 -08:00
docs Minor doc updates: FlexBuffers C#, Discord, CppUsage. 2019-12-26 12:36:41 -08:00
go [go]add Name() for ForceCodec interface (#5486) 2019-08-19 15:32:04 -07:00
grpc Fix --incompatible_load_cc_rules_from_bzl (#5683) 2019-12-26 10:03:22 -08:00
include/flatbuffers [C++] Add Builder and Table typedefs (#5685) 2019-12-26 14:56:46 -08:00
java/com/google/flatbuffers Fixed warnings in FlexBuffers.java 2019-12-23 17:11:57 -08:00
js [JS/TS] Size prefix support (#5326) 2019-05-16 11:43:31 -07:00
lobster Lobster: added builder API for tables 2019-05-22 19:42:13 -07:00
lua Lua cleanup (#5624) 2019-11-14 15:46:46 -08:00
net/FlatBuffers Fixed struct initialization error on older versions of C# 2019-12-23 17:35:54 -08:00
php Performance improvement to generated+supporting PHP (#5080) 2018-12-20 16:10:20 -08:00
python Python: Add forceDefaults opt to python Builder (#5564) 2019-10-17 15:25:05 -07:00
reflection Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
rust/flatbuffers [Rust] Bump smallvec version to 1.0 (#5621) 2019-11-11 09:52:26 -08:00
samples [C++] Add Builder and Table typedefs (#5685) 2019-12-26 14:56:46 -08:00
snap Update snap include path instruction (#5297) 2019-04-18 15:15:21 -07:00
src [rust] Make enum names public (#5690) 2019-12-31 10:28:58 -08:00
tests [rust] Make enum names public (#5690) 2019-12-31 10:28:58 -08:00
.clang-format
.editorconfig Unify line ending rules in '.editorconfig' and '.gitattributes' (#5231) 2019-03-18 12:47:07 -07:00
.gitattributes Unify line ending rules in '.editorconfig' and '.gitattributes' (#5231) 2019-03-18 12:47:07 -07:00
.gitignore Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
.travis.yml Add `--clean-first` to the cmake-build command (travis) (#5574) 2019-10-21 10:11:32 -07:00
BUILD Split Bazel targets into multiple packages (#5640) 2019-12-02 14:14:48 -08:00
CMakeLists.txt Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
CONTRIBUTING.md
LICENSE.txt Fixed Apache license not using canonical version. 2019-11-04 17:15:56 -08:00
WORKSPACE Upgrade rules_go (#5684) 2019-12-26 10:07:15 -08:00
appveyor.yml Add flatc '--cpp_std' switch (#5656) 2019-12-23 12:13:48 -08:00
build_defs.bzl [Bazel] Add support for compatible_with and restricted_to (#5681) 2019-12-26 09:58:48 -08:00
composer.json
conanfile.py Update Conan version Automatically (#5027) 2018-11-12 08:49:42 -08:00
package.json Bumped version to 1.11.0 2019-04-24 11:34:53 -07:00
pom.xml Enforce matching version in Java and C#. 2019-05-31 12:15:19 -07:00
readme.md Minor doc updates: FlexBuffers C#, Discord, CppUsage. 2019-12-26 12:36:41 -08:00

readme.md

logo FlatBuffers

Build Status Build status Join the chat at https://gitter.im/google/flatbuffers Discord Chat Twitter Follow

FlatBuffers is a cross platform serialization library architected for maximum memory efficiency. It allows you to directly access serialized data without parsing/unpacking it first, while still having great forwards/backwards compatibility.

Go to our landing page to browse our documentation.

Supported operating systems

  • Windows
  • MacOS X
  • Linux
  • Android
  • And any others with a recent C++ compiler.

Supported programming languages

  • C++
  • C#
  • C
  • Dart
  • Go
  • Java
  • JavaScript
  • Lobster
  • Lua
  • PHP
  • Python
  • Rust
  • TypeScript

and more in progress...

Contribution

To contribute to this project, see CONTRIBUTING.

Licensing

Flatbuffers is licensed under the Apache License, Version 2.0. See LICENSE for the full license text.