Skip to content
This repository has been archived by the owner on Aug 18, 2020. It is now read-only.

Support rust enums #21

Open
dorny opened this issue Aug 28, 2014 · 1 comment · May be fixed by #22
Open

Support rust enums #21

dorny opened this issue Aug 28, 2014 · 1 comment · May be fixed by #22

Comments

@dorny
Copy link

dorny commented Aug 28, 2014

Hi,

is there any reason why enums are not supported?
I know there is no Enum type in Msgpack spec, but it seems to me there is a realy simple workaround.
Enum type can be decomposed into its variant index (uint) and rest of data whatever they are.

I have already tested it and it seems to work.
PR?

@dorny dorny linked a pull request Aug 29, 2014 that will close this issue
@dorny
Copy link
Author

dorny commented Aug 29, 2014

Oh, i just discovered #13 .

Why ban so extremely useful feature?
We are able to encode/decode enums into valid Msgpack structure and I'm sure with little effort this would be also possible in other languages.

C++ has union type or more robust boost::variant and QVariant. Duck typed languages will neither have problems. In Java there could be simple switch statement on index returning reference to Object.

Many other similar libraries like Avro or [Cap’n Proto] http://kentonv.github.io/capnproto/) also supports enums.

Msgpack has two big advantages over other serialization formats in current rust: It's schemaless (you have to just derive Encodable/Decodable) and effectient. For this reasons i'm sure it will become very popular in rust. And if enums will not be supported (althought it's so easy) there will be many forks in local projects. It would be better to support this directly here and just add some docs describing how enum support is implemented and it's not recommended to use them in cross-language projects unless they are necessary.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant