google / flatbuffers

FlatBuffers: Memory Efficient Serialization Library
https://flatbuffers.dev/
Apache License 2.0
23.17k stars 3.24k forks source link

rust-flatbuffers: Upgrading from flat 1.12 to 25.x #8206

Closed cisaacson closed 2 months ago

cisaacson commented 9 months ago

In the older version of rust-flatbuffers the code gen for enum types were standard Rust enums, like:

#[repr(u16)]
enum MyEnum {
A = 0,
B = 1
}

Now in the latest version it builds a struct with accessors. Is the functionality the same? Can we access the new struct type just like an enum? We use strum to work with enum types to make it easy to do things like get a string value for the variant (and others). We also have a lot of cases like MyEnum::B as u16

In addition, we now see this warning in the generated code: #[deprecated(since = "2.0.0", note = "Use associated constants instead. This will no longer be generated in 2021.")]

I read about the issue, looks like it is not resolve yet. Is there anything we should do to accommodate this? Or just wait until it is resolved in the future?

We did try out the new version and it is functionally compatible with what we have been doing (without the need for strum). However I wonder why it was done this way? In other languages like Python and TypeScript it just generates idiomatic native enums, and in Rust you could have used impl on the enum to add other functionality?

github-actions[bot] commented 2 months ago

This issue is stale because it has been open 6 months with no activity. Please comment or label not-stale, or this will be closed in 14 days.

github-actions[bot] commented 2 months ago

This issue was automatically closed due to no activity for 6 months plus the 14 day notice period.