Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.
Sign upPort FlatBuffers to Rust #4898
Conversation
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
ry
Aug 29, 2018
Awesome work @rw - thank you! We're already using your patch in our project and it's working great.
ry
commented
Aug 29, 2018
|
Awesome work @rw - thank you! We're already using your patch in our project and it's working great. |
aardappel
self-requested a review
Aug 29, 2018
rw
self-assigned this
Aug 29, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
phayes
Aug 30, 2018
Should the fie tests/rust_usage_test/test_bench_output.txt have been included in this PR?
phayes
commented
Aug 30, 2018
|
Should the fie |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rw
Aug 30, 2018
Collaborator
@phayes I included it in the PR for people who don't want to run the code but still want to see the output of tests passing.
|
@phayes I included it in the PR for people who don't want to run the code but still want to see the output of tests passing. |
aardappel
reviewed
Aug 30, 2018
WOW! This is some amazing effort, the most comprehensive language port yet!
I'm missing Rust specific changes to Tutorial.md, and a Rust sample in samples. Here is a sample checklist to see if you've touched all typical language port files: 4898809
| @@ -14,8 +14,8 @@ | ||
| # See the License for the specific language governing permissions and | ||
| # limitations under the License. | ||
| ../flatc --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --grpc --gen-mutable --reflect-names --gen-object-api --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json | ||
| ../flatc --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --gen-mutable --reflect-names --no-fb-import --cpp-ptr-type flatbuffers::unique_ptr -o namespace_test namespace_test/namespace_test1.fbs namespace_test/namespace_test2.fbs | ||
| ../flatc --cpp --java --csharp --dart --go --binary --lobster --lua --python --js --ts --php --rust --grpc --gen-mutable --reflect-names --gen-object-api --no-includes --cpp-ptr-type flatbuffers::unique_ptr --no-fb-import -I include_test monster_test.fbs monsterdata_test.json |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
| impl<'a> flatbuffers::Follow<'a> for Monster<'a> { | ||
| type Inner = Monster<'a>; | ||
| #[inline] | ||
| fn follow(buf: &'a [u8], loc: usize) -> Self::Inner { |
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
aardappel
Aug 30, 2018
Collaborator
should this be _follow if there is a possibility of a clash with generated fields?
aardappel
Aug 30, 2018
Collaborator
should this be _follow if there is a possibility of a clash with generated fields?
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rw
Sep 2, 2018
Collaborator
Good eye! This is actually okay because it's a trait method, so unless users are importing Push, they cannot access it. Furthermore, I added the trait methods we use to the reserved keywords list, so a field called follow would be generated as follow_.
rw
Sep 2, 2018
Collaborator
Good eye! This is actually okay because it's a trait method, so unless users are importing Push, they cannot access it. Furthermore, I added the trait methods we use to the reserved keywords list, so a field called follow would be generated as follow_.
rw
added some commits
Aug 31, 2018
rw
added some commits
Sep 2, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
rw
Sep 2, 2018
Collaborator
@aardappel Thanks for the feedback, I incorporated it all. Also, I resolved an alignment issue that I didn't catch before, and made the Push trait more useful.
|
@aardappel Thanks for the feedback, I incorporated it all. Also, I resolved an alignment issue that I didn't catch before, and made the |
aardappel
merged commit 0758c1e
into
google:master
Sep 3, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
|
Thanks! Amazing work! |
added a commit
that referenced
this pull request
Sep 3, 2018
added a commit
that referenced
this pull request
Sep 3, 2018
This comment has been minimized.
Show comment
Hide comment
This comment has been minimized.
binary132
commented
Sep 3, 2018
|
|
rw commentedAug 29, 2018
•
edited
Edited 2 times
-
rw
edited Sep 2, 2018 (most recent)
-
rw
edited Aug 29, 2018
-
rw
created Aug 29, 2018
This is a port of FlatBuffers to Rust. It provides code generation and a runtime library derived from the C++ implementation. It utilizes the Rust type system to provide safe and fast traversal of FlatBuffers data.
There are 188 tests, including many fuzz tests of roundtrips for various serialization scenarios. Initial benchmarks indicate that the canonical example payload can be written in ~700ns, and traversed in ~100ns.
Rustaceans may be interested in the
Follow,Push, andSafeSliceAccesstraits. These traits lift traversals, reads, writes, and slice accesses into the type system, providing abstraction with no runtime penalty.