bincode
bincode copied to clipboard
enum encoding
I am new to bincode, I got a simple scenario to serialize/desrialize an enum, which has string in it. i.e.: pub enum E { STRING(String), INT(i32) }
After serialization, I found two things I am not happy:
- enum order number is a i32, used up 4 bytes. 1 byte should be enough.
- String length, use i64, i32 should be enough.
So is there anyway to configre bincode to serialize/deserialize using above 2 specs? i.e., the layout should look like:
0 x x x x Action String followed length (x x x x), 0 is the order 1 x x x x (this is i32), 1 is the order