lerouxrgd / rsgen-avro

Command line and library for generating Rust types from Avro schemas
MIT License
36 stars 29 forks source link

Add `Bytes` variant to union visitors #69

Closed mati865 closed 2 months ago

mati865 commented 2 months ago

Fixes https://github.com/lerouxrgd/rsgen-avro/issues/68

Reverting implementation commit makes testsuite fail:

...
<impl From<Vec<u8>> for UnionStringLongDoubleBooleanBytes {
<    fn from(v: Vec<u8>) -> Self {
<        Self::Bytes(v)
<    }
<}
<
<impl TryFrom<UnionStringLongDoubleBooleanBytes> for Vec<u8> {
<    type Error = UnionStringLongDoubleBooleanBytes;
<
<    fn try_from(v: UnionStringLongDoubleBooleanBytes) -> Result<Self, Self::Error> {
<        if let UnionStringLongDoubleBooleanBytes::Bytes(v) = v {
<            Ok(v)
<        } else {
<            Err(v)
<        }
<    }
<}

I think modified test should suffice because the problem in #68 was due to Bytes variant being ignored.

lerouxrgd commented 2 months ago

Thanks for the fix !