3Hren / msgpack-rust

MessagePack implementation for Rust / msgpack.org[Rust]
MIT License
1.17k stars 130 forks source link

Serialize enumeration as index #319

Open woodworker7 opened 2 years ago

woodworker7 commented 2 years ago

Hello,

I noticed that between versions 0.15.4 and 1.0.0 the enumerations are serialized by name rather than index.

Is it possible by configuration to achieve back the old behavior?

Zannick commented 1 year ago

Seconding this. I have a need for an efficient binary packing of data (ideally without renaming my enum fields from descriptive names to single-character names), which msgpack is great at for all other datatypes. I was able to use #[repr(uX)] for all of my C-like enums but that is a feature of serde_repr.

It would be nice to have a similar explicit configuration on the enum to use a tag index or manually tag each enum variant with an integer tag.

kornelski commented 1 year ago

Dupe #327

The change wasn't intentional. I'm not sure whether that was a side effect of fixing nested Option serialization, or just an accident. The format was meant to be configurable.