I want to run code temporarly on playground () , but that code involve some depedencies like RlpStream etc... so can i run that code without doing any extra work .. like making project, giving cargo.toml file, and then write some dependencies , and then compile/run...
Detail of rlp.drain()
I want to know the details of drain function on rlp.. As i am not a expert, so please explain with example. I shall be very thankful to you.
Rust Playground has the most popular crates available. You can use them like if they are already in your dependencies (example). It's not possible to import arbitrary dependencies, though.
after the stream has finished you can "drain" the inner buffer and return the contents as a ElasticArray1024 although rlp.out() seems like the encouraged way from the docs
let mut stream = RlpStream::new_list(2);
stream.append(&"cat");
assert_eq!(stream.is_finished(), false);
stream.append(&"dog");
assert_eq!(stream.is_finished(), true);
let out = stream.out();
assert_eq!(out, vec![0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g']);
in our rlp list there are two items i.e. cat and dog, then what are these values , 0xc8, 0x83 and then again 0x83 ???? i am confused ... would you elaborate further about these values ... why not it would be assert_eq!(out, vec![ b'c', b'a', b't', b'd', b'o', b'g']); or why not it would be assert_eq!(out, vec![ b"cat", b"dog"']);
They are control characters 0x83 looks like a separation character. I'm not sure about the other one, looking through the code my guess is its the length.
There are 30,547 crates that have to be in some way compiled and stored, personally I'd want to avoid paying for all that storage space.
then what about the following code. .. here are three hex number in the starting. ..
main () {
/// let mut stream = RlpStream::new_list(2);
/// stream.begin_list(2).append(&"cat").append(&"dog");
/// stream.append(&"");
/// let out = stream.out();
/// assert_eq!(out, vec![0xca, 0xc8, 0x83, b'c', b'a', b't', 0x83, b'd', b'o', b'g', 0x80]);
/// }
0xca and c8 are for?