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

Add instances for std Duration/SystemTime #267

Closed
wants to merge 1 commit into from

Conversation

Fuuzetsu
Copy link
Contributor

@Fuuzetsu Fuuzetsu commented Dec 7, 2023

No description provided.

@frol
Copy link
Collaborator

frol commented Dec 7, 2023

@Fuuzetsu Thank you for contributing to borsh! Unfortunately, we won’t merge this PR as date serialization is too opinionated, see previous discussion #131 (comment)

@frol frol closed this Dec 7, 2023
@Fuuzetsu
Copy link
Contributor Author

Fuuzetsu commented Dec 8, 2023

I'm a bit confused... For Duration, the instances just serialise the individual fields as-is, no opinions. It's the same code as if we wrote derive(BorshSerialize, BorshDeserialize) inside stdlib... No opinions needed.

For SystemTime, this is the same implementation as in serde so at least there's a very big precedent.

Not being able to de/serialise stdlib types is very, very sad because it adds another hurdle to adding support in other crates that include Duration and such.

If someone does have an opinion on how to serialise a type then they should newtype it or use deserialize_with or something, right?

@frol
Copy link
Collaborator

frol commented Feb 10, 2024

@Fuuzetsu borsh is not Rust serialization format. There are other languages with their own defaults for internal implementation of "duration". See borsh specification here: https://borsh.io/, there is no sane default format for time.

For SystemTime, this is the same implementation as in serde so at least there's a very big precedent.

They regret it: serde-rs/serde#2108

Not being able to de/serialise stdlib types is very, very sad because it adds another hurdle to adding support in other crates that include Duration and such.

It is explicit and this is essential property for a schema-less binary format.

If someone does have an opinion on how to serialise a type then they should newtype it or use deserialize_with or something, right?

Exactly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants