A minimal, dependency-free implementation of Recursive-Length Prefix (RLP) encoding and decoding in Rust.
-
✅ Encode:
- Empty string (
"") - Boolean
false(encoded as empty) - Empty list (
[]) - Single byte (
0x00–0x7f) - Short strings (≤ 55 bytes)
- Long strings (≥ 56 bytes)
- Empty string (
-
✅ Decode:
- Single byte
- Short strings
- Long strings
-
🚫 List decoding (not implemented by design)
Clone the repository:
git clone https://github.com/iammrjude/rlp-rs.git
cd rlp-rsuse rlp_rs::{Rlp, encode, decode};
fn main() {
let data = Rlp::Bytes(b"dog".to_vec());
let encoded = encode(&data);
assert_eq!(encoded, vec![0x83, b'd', b'o', b'g']);
let (decoded, _) = decode(&encoded).unwrap();
assert_eq!(decoded, data);
}Recursive Length Prefix (RLP) is a serialization method used in systems like Ethereum to encode arbitrarily nested arrays of binary data.
cargo test- List decoding is not implemented
- No support for integers or higher-level types
- Focused on correctness and minimalism
rlp-rs/
├── Cargo.toml
├── src/
│ └── lib.rs
└── tests/
└── tests.rs
- List decoding
- Zero-copy decoding
-
no_stdsupport - Ethereum compatibility