I want to do some manipulation on RlpStream manually. But I am confused how it work. For example considered following program;
extern crate rlp;
use rlp::*;fn main () {
let name = "amir";
let age: u8 = 38;
let fname = "ali";
let mut stream = RlpStream::new_list(3);
stream.append(&name).append(&age).append(&fname);
let out = stream.drain();
println!("My RlpStream : {:?}",out);
}
The output of above programe is :
My RlpStream : [202, 132, 97, 109, 105, 114, 38, 131, 97, 108, 105]
as you can see there are 11 bytes in rlp list, whereas my code has 8 byte [i.e. "amir" = 4 bytes, age=38 = 1 byte, and "ali"=3 bytes]. I know amir=97, 109, 105, 114, age = 38 and ali=97, 108, 105... then why and how 202, 132, and 131 are inserted ????? If we want to calculate these bytes manually, is there any method/formula ????
Making it more complex, if I want to insert a structure type variable (say i.e. Student (name, class, roll no, etc..) then how these bytes are calculated ?