-
Notifications
You must be signed in to change notification settings - Fork 88
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
fix: Fixed untagged enum deserialization issues #194
Conversation
let value = Value::deserialize(deserializer)?; | ||
if let Ok(response) = serde_json::from_value(value.clone()) { | ||
return Ok(Self::Response(response)) | ||
} | ||
use serde::de::{Error}; | ||
Ok(Self::Event(serde_json::from_value(value.clone()).map_err(|err|Error::custom(format!("{:?}", err)))?)) |
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.
hmm, how is this different from untagged deserialization?
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.
CdpEventMessage deserialization doesn't play nice with untagged enums, i don't remember exactly why, but this adds the necessary coersion for it to work.
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.
maybe it was fixed in the meantime somehow, let me try on master for a bit
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 doesn't seem to be happening anymore, but longer tests are necessary
This looks a bit off, let me take a stab at this |
Let's add the This should work for a generic "fallback" type. |
I'm closing this as i no longer encounter the issues in the most recent version |
Fixes #167
There is maybe a better way to deserialize, but would not be as simple.