Skip to content
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

"bincode does not support Deserializer::deserialize" #85

Closed
mikedilger opened this issue Aug 16, 2016 · 5 comments
Closed

"bincode does not support Deserializer::deserialize" #85

mikedilger opened this issue Aug 16, 2016 · 5 comments

Comments

@mikedilger
Copy link
Contributor

@mikedilger mikedilger commented Aug 16, 2016

Is this something that could be implemented, or does it mean my code is doing something wrong?

I'm trying to deserialize a chrono::NaiveDateTime which bincode serialized just fine.

@mikedilger
Copy link
Contributor Author

@mikedilger mikedilger commented Aug 16, 2016

Actually it serialized as "2016-08-16T16:41:52.757059590"... which I guess breaks the "no fluff" premise of bincode... but I think the way serde is designed it leaves things up to the type definer so not much can be done about that AFAIK.

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Aug 16, 2016

Looks like a bug in chrono.

https://github.com/lifthrasiir/rust-chrono/blob/d50546a5925b8689f6bcca7155a7af89f2839a32/src/naive/datetime.rs#L892

It should be calling deserializer.deserialize_str instead of deserializer.deserialize.

@mikedilger to understand why this is a problem: deserialize expects the deserializer to be able to tell from the input what data type is there. For example JSON can see a curly brace { and know that that means a map, or it can see a quote " and know that that means a string. For performance reasons bincode does not serialize any of this fluff punctuation so it has no way to tell from the input what type is there. Serde handles this by letting Deserialize implementations hint to the deserializer what type it expects to deserialize, which they do by calling methods like deserialize_str instead of plain deserialize.

@dtolnay
Copy link
Collaborator

@dtolnay dtolnay commented Aug 16, 2016

I made a chrono PR with a fix chronotope/chrono#89.

@lifthrasiir
Copy link

@lifthrasiir lifthrasiir commented Aug 16, 2016

@mikedilger

Actually it serialized as "2016-08-16T16:41:52.757059590"... which I guess breaks the "no fluff" premise of bincode...

I plan to do something about that in Chrono 0.3. As far as I understand, the ability to change the representation per the (de)serializer is heavily dependent of the specialization.

@mikedilger
Copy link
Contributor Author

@mikedilger mikedilger commented Aug 16, 2016

@TyOverby TyOverby closed this Sep 15, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.