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

RlpEncodableWrapper for structs with more than one field #12

Closed
Wollac opened this issue Feb 4, 2024 · 1 comment · Fixed by #22
Closed

RlpEncodableWrapper for structs with more than one field #12

Wollac opened this issue Feb 4, 2024 · 1 comment · Fixed by #22

Comments

@Wollac
Copy link
Contributor

Wollac commented Feb 4, 2024

Currently, RlpEncodableWrapper/RlpDecodableWrapper can only be derived for single-field structs.
This contradicts the documentation, which explicitly mentions more than one field:

Derives Encodable for the type which encodes the fields as-is, without a header: <fields...>

There are several use cases where "headerless" encoding would be very helpful. So it should be considered if the documented behavior should be added. Otherwise, at least the documentation should be corrected to match the implementation.

An example of such a use case would be to implement something like #[serde(flatten)] by manually calling the headerless encoding of the structs to be flattened. This could, e.g., be useful for simplifying EIP-2718 transaction encoding.

@Rjected
Copy link

Rjected commented Feb 4, 2024

This makes sense, although I'd say the current documentation should be changed to say field instead of fields since it's mainly used for the newtype pattern.

Traits for headerless encoding, length, and rlp(flatten) would make it possible to replace lots of existing manual rlp implementations with derived encoding / decoding, basically this suggestion: #10

@linear linear bot closed this as not planned Won't fix, can't repro, duplicate, stale Aug 4, 2024
@DaniPopes DaniPopes reopened this Aug 4, 2024
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 a pull request may close this issue.

3 participants