[ 
https://issues.apache.org/jira/browse/AVRO-3668?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Martin Tzvetanov Grigorov resolved AVRO-3668.
---------------------------------------------
    Resolution: Duplicate

(de)serializing complex Rust enums is worked on in AVRO-3646.

> Rust AvroSchema derive should support non-unit enums
> ----------------------------------------------------
>
>                 Key: AVRO-3668
>                 URL: https://issues.apache.org/jira/browse/AVRO-3668
>             Project: Apache Avro
>          Issue Type: New Feature
>          Components: rust
>            Reporter: Aaron Spiegel
>            Priority: Major
>
> The idiomatic way to create type unions in Rust is to create a non-unit Enum 
> with unnamed fields. As a user, I would like to derive an Avro schema from 
> this type of object:
> {code:java}
> #[derive(AvroSchema)]
> enum MyEnum {
>     AsAString(String),
>     AsAnInt(i32),
> }
> #[derive(AvroSchema)]
> struct MyStuct {
>   my_enum: MyEnum,
> }{code}
> Which would create a schema of:
> {code:java}
> {
>   "name" : "my_struct",
>   "type" : "record",
>   "fields" :
>   [
>     {
>       "name" : "my_enum",
>       "type" : [
>         "string",
>         "int"
>       ]
>     }
>   ]
> }{code}
>  
> Rust also supports named fields for structure types, and multi-field unnamed, 
> similar to tuple types:
> {code:java}
> #[derive(AvroSchema(union)]
> enum MyEnum {
>     MultiFieldUnnamed(String, i32),
>     NamedField: {
>         value: String,
>         count: i32,
>     }
> }
> {code}
> While the Rust enum supports named and multi-field unnamed variants to 
> represent embedded structs, tuple-like and a mix of unit fields, named, and 
> unnamed fields. I would consider these variations outside the scope of this 
> issue, since the formats may not be easily interoperable with other 
> languages. In the future, these variations may also be supported by the 
> AvroSchema derive with embedded records similar to the approach describe in 
> AVRO-3646.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to