Skip to content

fix: properly handle deserialization from Reader#71

Merged
kodiakhq[bot] merged 1 commit intoinfluxdata:mainfrom
JustRustThings:55-fix-deserialize-from-reader
Oct 1, 2022
Merged

fix: properly handle deserialization from Reader#71
kodiakhq[bot] merged 1 commit intoinfluxdata:mainfrom
JustRustThings:55-fix-deserialize-from-reader

Conversation

@vthib
Copy link
Copy Markdown
Contributor

@vthib vthib commented Sep 27, 2022

The pattern "let s: &str = Deserialize::deserialize(deser)" used in multiple places is not ideal, as it generates errors when the deserializer uses an IO Reader and not a string. To fix this, implementing a visitor is preferred, as it gives the deserializer the choice of allocating or not a string.

To ensure the issue is fixed, the tests now deserialize both from a string and from a reader.

I haven't used the same fix for the integer/string deserialization for numbers. Using a Visitor is much more cumbersome as it would depend on each numeric type, and using a Cow type is enough to fix the issue.

Closes #55

The pattern "let s: &str = Deserialize::deserialize(deser)" used
in multiple places is not ideal, as it generates errors when the
deserializer uses an IO Reader and not a string. To fix this,
implementing a visitor is preferred, as it gives the deserializer the
choice of allocating or not a string.

To ensure the issue is fixed, the tests now deserialize both from a
string and from a reader.

Closes influxdata#55
Copy link
Copy Markdown
Contributor

@tustvold tustvold left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, thank you, and sorry for the delay in reviewing.

Could you please sign the CLA and I can get this in 😄

@vthib
Copy link
Copy Markdown
Contributor Author

vthib commented Sep 30, 2022

Thanks, I have signed the CLA

@tustvold tustvold added the automerge Put in the merge queue label Oct 1, 2022
@kodiakhq kodiakhq Bot merged commit 6f05959 into influxdata:main Oct 1, 2022
@tustvold
Copy link
Copy Markdown
Contributor

tustvold commented Oct 1, 2022

Thank you 😄

@vthib vthib deleted the 55-fix-deserialize-from-reader branch October 3, 2022 07:43
@tustvold tustvold mentioned this pull request Oct 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

automerge Put in the merge queue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Parsing bytes from reader can lead to expected a borrowed string error

2 participants