-
Notifications
You must be signed in to change notification settings - Fork 100
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
Variant data type support #170
Conversation
) -> Result<()> { | ||
panic!("newtype variant types are unsupported: `{name}::{variant}`"); |
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.
Note: this code implicitly allows using enums at the top level. Usually, it's avoided by using either the parameter stored in the serializer struct or dedicated SerializeStruct
/etc associated types.
In general, it's okay (the user will get some error anyway), but instead of more descriptive panic, it ends with "not enough data."
Also, it produces an unclear message for forgotten serde_repr
(Enum8
and Enum16
).
It's not a blocker for merge because it's an error anyway. But, probably, we should leave "TODO" at least in the code about it.
src/rowbinary/de.rs
Outdated
type Error = Error; | ||
|
||
fn unit_variant(self) -> Result<()> { | ||
Ok(()) |
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.
It seems to be an error on the definition side (SomeEnum::A
without any payload), innit?
We should return an error here to avoid the generic "not enough data" error. Probably, it's time to introduce Error::Unsupported
instead of panics, but up to you here.
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.
Added Error::Unsupported
and used it in this case. The rest of the panics can be changed as a follow-up.
Summary
Adds support for the Variant data type. Closes #143.
To discuss:
Checklist