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

Remove GenericArray #2857

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

kevinheavey
Copy link

This branches off #2054 so that needs to be merged first

Problem

generic-array is an annoying dependency that is quite avoidable. We can avoid it by hand rolling the serde impls for Signature, or by using the serde_with or serde-big-array crates.

This PR hand rolls the serde impls by closely mimicking what generic-array does (but without the generic stuff). The advantage of this approach is that we should have the same behaviour and performance as before. The disadvantage of this approach is I cargo culted it somewhat so it would be good for someone to look over the unsafe code.

It's possible that serde_with or serde-big-array are better solutions but I haven't investigated the performance or if they differ in any edge cases. I did try serde_bytes and saw that it serialized differently when using short_vec, so the serialization is not trivial.

Summary of Changes

  • Replace GenericArray<u8, U64> with [u8; 64]
  • Hand roll serde impls based on the serde code in generic-array
  • Remove generic-array everywhere else as it is now unused

@kevinheavey kevinheavey marked this pull request as ready for review September 6, 2024 17:09
@kevinheavey
Copy link
Author

This is the serde code from the generic-array crate that I've ported over: https://github.com/fizyk20/generic-array/blob/master/src/impl_serde.rs

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: In review
Development

Successfully merging this pull request may close these issues.

1 participant