-
-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow arbitrary enums #6
Comments
If possible, what would be great is for the discriminant to actually be passed as the variant index to crates like bincode, since this is the only way to keep serialized values "backwards compatible" when variants are removed (in the sense that variants that weren't removed will still be parsed correctly). Of course, this is dependent on the particular serializer/deserializer you use. |
Not only - another problem is that variant index in Serde API is limited to |
That is true, but for repr(u32) or less it would surely work :) |
What about using custom attribute macros? I would love to work on something like this. This is especially useful in our case since the protocol we're implementing usually uses a value for the Enum encoded in e.g. Examples:
|
This seems somewhat relevant to my use case: I want to deserialize json that looks like this: {
"type": 5,
"data": { ... }
} Where the value of |
@lokegustafsson this is the exact thing we are looking to solve. |
This feature has been stabilized in rust 1.56, are there any updates on whether or when this will be supported by either serde or serde-repr? |
support for enum-variants with fields? serde-rep is great for binary protocols, but I face a blocker dealing with an enum with fields in variants, for example
Sadly It would be great if serde-repr would support enum-variants with fields, as in the sample code |
I would prefer if someone else would make a different crate for this use case. I am not interested in building support for this into this crate. |
That's a shame, this crate seems like the most natural fit since they're not too different from other discriminants. |
RFC 2363 allows to set custom discriminant on arbitrary enums with payloads, and not just C-like enums.
While it's currently a nightly-only featureIt's a stable feature since Rust 1.56, it would be great to support arbitrary enums in serde-repr too.The text was updated successfully, but these errors were encountered: