msgpack-rust icon indicating copy to clipboard operation
msgpack-rust copied to clipboard

Serialize enumeration as index

Open woodworker7 opened this issue 1 year ago • 2 comments

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?

woodworker7 avatar Oct 21 '22 14:10 woodworker7

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.

Zannick avatar May 16 '23 02:05 Zannick

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.

kornelski avatar May 18 '23 22:05 kornelski