fn main() { // We define a set of data to encode. The `.as_bytes().to_vec() part converts the str to a Vec. // The type of `data` is Vec<(u8, Vec)>, which looks complicated. In reality, it can usually be treated as a key-value list of u8 keys and String values. let data = vec![ (1, "Hello".as_bytes().to_vec()), (2, ", ".as_bytes().to_vec()), (4, "world".as_bytes().to_vec()), (1, "!".as_bytes().to_vec()), ]; // We encode the data using kvds. The data is now stored in a compact format, of type Vec. // We unwrap the Result and panic!() on an Err. In reality, you should not panic!(). let encoded_data = match kvds::encode(data) { Ok(d) => d, Err(e) => panic!("Err: {:?}", e), }; // We print the encoded data -- it should print as a vector of u8. println!("{:?}", encoded_data); // We decode the data using kvds. It should now be back to a Vec<(u8, Vec)>. let decoded_data = match kvds::decode(encoded_data) { Ok(d) => d, Err(e) => panic!("Err: {:?}", e), }; // We print it. It should look like a Vec<(u8, Vec)>, same as the original `data`! println!("{:?}", decoded_data); }