#rlp #ethereum #serialization

no-std alloy-rlp

Implementation of Ethereum RLP serialization

7 releases

0.3.4 Dec 22, 2023
0.3.3 Sep 23, 2023
0.3.2 Jul 26, 2023
0.2.0 Jun 23, 2023
0.1.0 Jun 13, 2023

#1010 in Magic Beans

Download history 27000/week @ 2024-01-03 33765/week @ 2024-01-10 40277/week @ 2024-01-17 41029/week @ 2024-01-24 36206/week @ 2024-01-31 42913/week @ 2024-02-07 44480/week @ 2024-02-14 45656/week @ 2024-02-21 41891/week @ 2024-02-28 49224/week @ 2024-03-06 58214/week @ 2024-03-13 48977/week @ 2024-03-20 48129/week @ 2024-03-27 60076/week @ 2024-04-03 56811/week @ 2024-04-10 41529/week @ 2024-04-17

215,368 downloads per month
Used in 52 crates (17 directly)

MIT/Apache

41KB
953 lines

alloy-rlp

This crate provides Ethereum RLP (de)serialization functionality. RLP is commonly used for Ethereum EL datastructures, and its documentation can be found at ethereum.org.

Usage

We strongly recommend deriving RLP traits via the RlpEncodable and RlpDecodable derive macros.

Trait methods can then be accessed via the Encodable and Decodable traits.

Example

# #[cfg(feature = "derive")] {
use alloy_rlp::{RlpEncodable, RlpDecodable, Decodable, Encodable};

#[derive(Debug, RlpEncodable, RlpDecodable, PartialEq)]
pub struct MyStruct {
    pub a: u64,
    pub b: Vec<u8>,
}

let my_struct = MyStruct {
    a: 42,
    b: vec![1, 2, 3],
};

let mut buffer = Vec::<u8>::new();
let encoded = my_struct.encode(&mut buffer);
let decoded = MyStruct::decode(&mut buffer.as_slice()).unwrap();
assert_eq!(my_struct, decoded);
# }

Dependencies

~135–305KB