Open dtolnay opened 7 years ago
Wow, serde appears to have progressed quite a bit. My complements in particular on the newer docs.
So, besides zero-copy support, the main things that come to mind (reading the release docs):
If the comment at the bottom of serde_bytes is correct, there's still the issue of, e.g., Vec<u8>
serialising as a list of integers rather than a byte array. Looks like serde's plan here is to use specialisation; fourleaf currently uses a much more painful workaround that works on stable.
fourleaf uses predefined integer tags for identifying struct fields and enum variants. I suppose you could infer tags from field encounter order / variant_index
, but I'm not sure if there would be any benefit over just using bincode instead at that point. I think fourleaf could work around this unilaterally by having an additional trait (or a schema definition value) to translate between enum indices / field indices and tags, though this would still require something akin to fourleaf_retrofit!
or a proc macro to generate implementations for the trait. I'm conflicted as to whether serde should provide the tags itself; one one hand, it'd be convenient here, but on the other it's more complexity for serde and breaks down as soon as someone needs two binary formats with different tags.
I imagine there could be some things in std that serialise differently via serde vs fourleaf. I think specialisation would help here, but I could just accept the breakage since I don't know of anything actually serialising things like SocketAddr
.
I'll definitely look into implementing this once zero-copy in serde lands. Thanks for bringing this to my attention! I didn't think anyone knew about this crate.
Really sorry for taking so long on this, some personal stuff came up and then I forgot for a while.
I've been working on this off and on, and it looks like everything should be doable as-is. So serde support will probably come eventually; sooner, if some immediate need for it arises.
@AltSysrq do you have any sense of what functionality would be required from Serde before fourleaf could take advantage of Serde's serialize and deserialize traits?
The only one I could discern from the docs is zero-copy deserialization of &str and &[u8] which has already been merged in Serde and will be available in the next release: