serde-rs / bytes

Wrapper types to enable optimized handling of &[u8] and Vec<u8>
Apache License 2.0
306 stars 37 forks source link

Working with more complex types is difficult #14

Open petreeftime opened 5 years ago

petreeftime commented 5 years ago

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?

sfackler commented 5 years ago

This seems like a question for the serde repository rather than the bytes repository I think?