mirror of
https://github.com/google/flatbuffers.git
synced 2026-06-03 12:21:23 +00:00
Implement Serialize on generated rust types (#7022)
* fix for rust build * Rust: Implement Serialize on generated types For debugging convenience it is really handy to be able to dump out types as another format (ie: json). For example, if we are logging a type to a structured logging system, or even printing it out in a structured way to the console. Right now we handle this by shelling out to `flatc` which is not ideal; by implementing Serialize on the generated types we can use any of the Serializer-implementing packages for our structured debug output. * clang-format * Make the flatbuffers Rust crate only have an optional dependency on the `serde` packages. * fix warning * fix rust test build * Oh yeah this needs to be initialized * fix toml syntax * code review feedback * rebuild test data
This commit is contained in:
@@ -184,6 +184,7 @@ const static FlatCOption options[] = {
|
||||
{ "", "reflect-types", "",
|
||||
"Add minimal type reflection to code generation." },
|
||||
{ "", "reflect-names", "", "Add minimal type/name reflection." },
|
||||
{ "", "rust-serialize", "", "Implement serde::Serialize on generated Rust types." },
|
||||
{ "", "root-type", "T", "Select or override the default root_type." },
|
||||
{ "", "require-explicit-ids", "",
|
||||
"When parsing schemas, require explicit ids (id: x)." },
|
||||
@@ -469,6 +470,8 @@ int FlatCompiler::Compile(int argc, const char **argv) {
|
||||
opts.mini_reflect = IDLOptions::kTypes;
|
||||
} else if (arg == "--reflect-names") {
|
||||
opts.mini_reflect = IDLOptions::kTypesAndNames;
|
||||
} else if (arg == "--rust-serialize") {
|
||||
opts.rust_serialize = true;
|
||||
} else if (arg == "--require-explicit-ids") {
|
||||
opts.require_explicit_ids = true;
|
||||
} else if (arg == "--root-type") {
|
||||
|
||||
Reference in New Issue
Block a user