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

Custom encoder/decoder must receive allocator #19

Merged
merged 1 commit into from
Jan 11, 2024
Merged

Conversation

jsign
Copy link
Collaborator

@jsign jsign commented Jan 10, 2024

This PR makes the following changes:

  • It makes the custom encoder and decoder receive an allocator. This is required since both encoding and decoding need an allocator thus custom ones need one too. (i.e: the same allocator, so all allocations in potentially nested structs with custom allocators be allocator-coherent).
  • Move the serialize/deserialize parameters such that the allocator : Allocator is the first parameter, since this is a usual Zig idiom.

Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com>
Comment on lines -10 to +11
const implementsDecodeRLP = hasFn("decodeRLP");
const implementsDecodeRLP = hasFn("decodeFromRLP");
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I did this renaming since the encoder is named encodeToRLP -- to be coherent.
We could also remove the To in the encoder and have encodeRLP and decodeRLP but I think I like most this style.

Copy link
Owner

@gballet gballet left a comment

Choose a reason for hiding this comment

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

LGTM

@gballet gballet merged commit 38bbb33 into master Jan 11, 2024
4 checks passed
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