13 releases

new 0.3.10 Dec 6, 2024
0.3.9 Oct 23, 2024
0.3.8 Aug 5, 2024
0.3.7 Jun 28, 2024
0.3.2 Jul 26, 2023

#553 in Magic Beans

Download history 70226/week @ 2024-08-21 80810/week @ 2024-08-28 87045/week @ 2024-09-04 75468/week @ 2024-09-11 79505/week @ 2024-09-18 79336/week @ 2024-09-25 94597/week @ 2024-10-02 92887/week @ 2024-10-09 98247/week @ 2024-10-16 103815/week @ 2024-10-23 95319/week @ 2024-10-30 93941/week @ 2024-11-06 84491/week @ 2024-11-13 89413/week @ 2024-11-20 93544/week @ 2024-11-27 104967/week @ 2024-12-04

389,695 downloads per month
Used in 291 crates (53 directly)

MIT/Apache

47KB
1K SLoC

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–295KB