bytes
bytes copied to clipboard
Working with more complex types is difficult
I'm trying to make some structures serialize into bytes in a nice way. However, these types contain both optional data and maps of bytes (Option<Vec<u8>> and BTreeMap<usize, Vec<u8>>). #[serde(with = "serde_bytes")] doesn't seem capable of dealing with these types. I've found a way to make them work by changing the types to Option<ByteBuf> and BTreeMap<usize, ByteBuf>, but it adds quite a lot of extra glue code. Is there a nicer way to achieve this?
This seems like a question for the serde repository rather than the bytes repository I think?