mirror of
https://github.com/google/flatbuffers.git
synced 2026-07-01 00:21:37 +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:
@@ -69,6 +69,7 @@ impl<'a> flatbuffers::Verifiable for Ability {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Ability {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
|
||||
@@ -847,6 +847,7 @@ impl<'a> Default for MonsterArgs<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct MonsterBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
|
||||
@@ -86,6 +86,7 @@ impl<'a> Default for ReferrableArgs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct ReferrableBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
|
||||
@@ -110,6 +110,7 @@ impl<'a> Default for StatArgs<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct StatBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
|
||||
@@ -70,6 +70,7 @@ impl<'a> flatbuffers::Verifiable for StructOfStructs {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> StructOfStructs {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
|
||||
@@ -69,6 +69,7 @@ impl<'a> flatbuffers::Verifiable for Test {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Test {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
|
||||
@@ -76,6 +76,7 @@ impl<'a> Default for TestSimpleTableWithEnumArgs {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TestSimpleTableWithEnumBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
|
||||
@@ -201,6 +201,7 @@ impl<'a> Default for TypeAliasesArgs<'a> {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub struct TypeAliasesBuilder<'a: 'b, 'b> {
|
||||
fbb_: &'b mut flatbuffers::FlatBufferBuilder<'a>,
|
||||
start_: flatbuffers::WIPOffset<flatbuffers::TableUnfinishedWIPOffset>,
|
||||
|
||||
@@ -73,6 +73,7 @@ impl<'a> flatbuffers::Verifiable for Vec3 {
|
||||
v.in_buffer::<Self>(pos)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Vec3 {
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
pub fn new(
|
||||
|
||||
Reference in New Issue
Block a user