Closed codehearts closed 3 years ago
I think this is a really good solution given what is doable with avro-rs
!
If you're happy with it I think we can merge it, but if you'd like to spend more time on it there's no problem.
I'd be happy to go ahead and merge it, it can always be improved further in the future as code changes and discussion happens on my avro-rs ticket!
I've released this in 0.9.6
.
Thanks again !
The
use_avro_rs_unions
option has been added to generate a customserde::Deserialize
implementation which can deserialize from avro-rs union types. Note that only int, long, float, double, and boolean values can be deserialized, strings and other types are not supported.This is a pretty rough pass. It'll support the
["null", "int", "long"]
union I'm trying to support in my own codebase, but it doesn't support strings because of thedeserialize_any
implementation in avro-rs. I also don't think this implementation could support variants with the same Rust type (i.e.Int
andDate
) because it doesn't know the variant name or the type being parsed.I looked into implementing a
Deserializer
that could parse theavro_rs::types::Value
enum instead of using avro-rs's deserializer, but enum parsing looks rather complex and I wasn't sure how to do it. I'll keep trying and will update this PR if I come up with anything.