Skip to content

feat: implement tuple trait impls and flatten field attribute#48

Open
stevencartavia wants to merge 4 commits into
alloy-rs:v1from
stevencartavia:decoder-encoder-lib
Open

feat: implement tuple trait impls and flatten field attribute#48
stevencartavia wants to merge 4 commits into
alloy-rs:v1from
stevencartavia:decoder-encoder-lib

Conversation

@stevencartavia
Copy link
Copy Markdown

Closes #14

Implements the remaining items from the new library and macro API:

  • RlpEncodable/RlpDecodable impls for tuples (arity 1–12), encoding as RLP lists
  • #[rlp(flatten)] field attribute using rlp_encode_raw/rlp_decode_raw/rlp_len_raw
  • Tagged enum trailing-bytes validation
  • Compile-time rejection of #[rlp(flatten)] on Option<T> fields
  • Saturating arithmetic in Decoder::bytepos
  • Sentinel-aware optional decoding in rlp_decode_raw

Comment thread crates/rlp/src/error.rs Outdated
Comment thread crates/rlp/src/error.rs Outdated
Comment thread crates/rlp/src/error.rs
Comment thread crates/rlp/src/header.rs
@@ -190,7 +190,7 @@ pub enum PayloadView<'a> {
#[inline(always)]
fn get_next_byte(buf: &[u8]) -> Result<u8> {
if buf.is_empty() {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

these should likely become methods on deserializer that keeps track of the position and does like return Err(self.mk_error()) so that the position is propagated

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Added decode_header, decode_bytes, and decode_str on Decoder with position-aware errors. Moving the parsing logic itself would require changing the RlpDecodable::rlp_decode signature from &mut &[u8] to &mut Decoder.

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