Skip to content

Conversation

lightsing
Copy link
Contributor

Motivation

This change adds support for the rkyv serialization framework for the Uint<BITS, LIMBS> type. rkyv enables zero-copy deserialization, making it ideal for performance-critical applications such as memory-mapped files, shared memory, or inter-process communication (IPC).

ruint has [rkyv] support starts from 1.16.0.

The project already supports other serialization formats like serde and rlp, so supporting rkyv extends compatibility with a high-performance, archive-based serialization format.

Solution

  • Adds a rkyv feature gate enables optional dependency rkyv and feature rkyv of ruint.
  • Adds rkyv feature gated derives macro.
  • Adds some modules named rkyv adds some helper function between archived types and original ones.

Thoses codes was previously maintained as a patch used internally in scroll for last year.

PR Checklist

  • Added Tests
  • Added Documentation
  • Breaking changes

@lightsing
Copy link
Contributor Author

strange cargo doc fails, no issue on my local worktree

Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

lgtm

smol q

pending @DaniPopes

Copy link
Member

@DaniPopes DaniPopes left a comment

Choose a reason for hiding this comment

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

makes sense, please rebase and fix ci

fn deserialize(&self, _deserializer: &mut D) -> Result<Bytes, D::Error> {
let mut result = BytesMut::new();
result.extend_from_slice(self.as_slice());
Ok(Bytes(result.freeze()))
Copy link
Member

Choose a reason for hiding this comment

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

Bytes::copy_from_slice

@github-project-automation github-project-automation bot moved this to Reviewed in Alloy Sep 21, 2025
@DaniPopes DaniPopes merged commit c1b9d23 into alloy-rs:main Sep 21, 2025
32 checks passed
@github-project-automation github-project-automation bot moved this from Reviewed to Done in Alloy Sep 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants