chaokunyang opened a new issue, #2851:
URL: https://github.com/apache/fory/issues/2851
### Feature Request
Currently Fory Rust only allow c-style enum, we don't allow tagged union
enum since it can't be expressed in other languages.
But for pure rust serialization, it's ok to support such enum:
```rust
enum TestEnum {
V1(String, i32),
V2(String, bool),
}
```
### Is your feature request related to a problem? Please describe
_No response_
### Describe the solution you'd like
We can extend `ForyObject` macro to generate code like:
```rust
match home {
V1(v1, v2) => {
context.writer.write_tag(0);
context.writer.write_str(v1);
context.writer.write_i32(v2);
}
V2(v1, v2) => {
context.writer.write_tag(1);
context.writer.write_str(v1);
context.writer.write_bool(v2);
}
}
```
And for deserialization, we can generate code like:
```rust
let tag = context.reader.read_tag();
match tag {
0 => {
let v1 = context.reader.read_str();
let v2 = context.reader.read_i32();
TestEnum::V1(v1, v2)
}
1 => {
let v1 = context.reader.read_str();
let v2 = context.reader.read_bool();
TestEnum::V2(v1, v2)
}
}
```
### Describe alternatives you've considered
_No response_
### Additional context
_No response_
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]