Skip to content

Latest commit

 

History

History
21 lines (16 loc) · 699 Bytes

File metadata and controls

21 lines (16 loc) · 699 Bytes

Recursive Length Prefix (RLP) encoding

This is a simple implementation of the RLP encoding in Rust. I am writing this to understand the basics of rlp encoding and decoding. This is not a full implementation of the Ethereum RLP encoding.

Usage

use rlp::{encode, decode, types::RLPItem};

fn main() {
    let data: RLPItem = vec![
        "hello".into(), 
        "world".into()
    ].into();
    let encoded = encode(&data);
    let decoded = decode(&encoded);
    assert_eq!(data, decoded);
}

I have taken the inspiration from: https://ethereum.org/en/developers/docs/data-structures-and-encoding/rlp/