Open Wollac opened 5 months ago
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: https://github.com/alloy-rs/rlp/issues/10
Currently,
RlpEncodableWrapper
/RlpDecodableWrapper
can only be derived for single-field structs. This contradicts the documentation, which explicitly mentions more than one field: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.