-
Notifications
You must be signed in to change notification settings - Fork 36
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
Adds support for parameterized Rust enums in serde #733
Conversation
} | ||
} | ||
|
||
fn deserialize_identifier<V>(self, visitor: V) -> Result<V::Value, Self::Error> | ||
where | ||
V: Visitor<'de>, | ||
{ | ||
visitor.visit_str(self.value.read()?.expect_text()?) | ||
// annotations are currently only supported with parameterized Rust enums |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does this mean? Does the rustdoc for this feature need to be updated as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This means that a serialized Ion data will only contain annotation in the case of parameterized Rust enums. And yes, I did add more comments in the rustdocs for it updating the table of serde data type to Ion type mappings: https://github.com/amazon-ion/ion-rust/pull/733/files#diff-de73824c75ee6203daf57ccbc5aee2ab3e2b46fbd9219d494c190298a7a8e745R43
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, I saw that but didn't make the connection. It might be worth renaming the table to say "Ion representation" instead of "Ion data type" now that we're including more information than just the data type.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure. I will change that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'll defer to @zslayton in case he has anything else to add.
Description of changes:
This PR works on adding support for parameterized Rust enums with
experimental-serde
feature.Example:
Below is an example parameterized enum value in Rust:
Ion representation:
List of changes:
newtype_variant
,struct_variant
andtuple_variant
. Instead add annotation with variant name.newtype_variant
,struct_variant
andtuple_variant
.Test:
Added tests for enum variants and struct types.
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.