bincode icon indicating copy to clipboard operation
bincode copied to clipboard

enum encoding

Open szguoxz opened this issue 3 years ago • 0 comments

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:

  1. enum order number is a i32, used up 4 bytes. 1 byte should be enough.
  2. 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

szguoxz avatar Aug 10 '22 02:08 szguoxz