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

Refactor Serialization/Deserialization APIs #113

Open
2 tasks
DanieleDiBenedetto opened this issue Jul 7, 2021 · 0 comments
Open
2 tasks

Refactor Serialization/Deserialization APIs #113

DanieleDiBenedetto opened this issue Jul 7, 2021 · 0 comments
Labels
enhancement New feature or request nice to have Possible new feature to introduce

Comments

@DanieleDiBenedetto
Copy link
Collaborator

DanieleDiBenedetto commented Jul 7, 2021

Currently we have 3 ways of serializing/deserializing structs in ginger-lib:

  • ToBytes/FromBytes/FromBytesChecked/ToBits/FromBits/ToCompressedBits/FromCompressedBits;
  • CanonicalSerialize/CanonicalDeserialize;
  • serde derive macros

For sure this situation is highly confusing and error prone, so I propose the following changes:

  • While ToBits/FromBits/ToCompressedBits/FromCompressedBits may still have some utility, ToBytes/FromBytes/FromBytesChecked are more or less duplications of CanonicalSerialize/CanonicalDeserialize traits so I would remove them. ToBytes and FromBytes can be directly replaced with CanonicalSerialize/CanonicalDeserialize; regarding FromBytesChecked we should modify deserialize and deserialize_uncompressed functions of CanonicalDeserialize trait to contextually perform validity checks (as defined by SemanticallyValid trait impl for a given struct, possibly in an optimized way enabling to perform early return in case of failures);
  • serde derive macros are very useful to get representation of structs in different formats (like JSON) so it may make sense to keep them; would be nice to find a way to integrate in them the compression capabilities of CanonicalSerialize/CanonicalDeserialize(WithFlags), possibly privatizing the latters and exposing as public APIs only the serde functions and macros (or even viceversa)
@DanieleDiBenedetto DanieleDiBenedetto added the enhancement New feature or request label Jul 7, 2021
@DanieleDiBenedetto DanieleDiBenedetto added the nice to have Possible new feature to introduce label Dec 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request nice to have Possible new feature to introduce
Projects
None yet
Development

No branches or pull requests

1 participant