fury icon indicating copy to clipboard operation
fury copied to clipboard

[Rust] add enum for fury macro derive

Open peacess opened this issue 2 years ago • 2 comments

as title

peacess avatar Mar 01 '24 23:03 peacess

Hi, could you please clarify if you intend to add an enum to the macro, or if you're suggesting that the macro should be modified to support enums? Additional details would be helpful as the request is a bit ambiguous. Thanks!

theweipeng avatar Mar 04 '24 02:03 theweipeng

https://github.com/apache/fury/blob/e99b46f4b83f79a23cf240466479da9e3657810d/rust/fury-derive/src/object/serializer.rs#L25-L29

It seems this is where we need to fix, please assign this issue to me. @theweipeng

jiacai2050 avatar Aug 09 '24 08:08 jiacai2050

This spec says enum are serialized as unsigned var int, but in Rust enum could carry payload, such as:

enum Location {
    Unknown,
    Anonymous,
    Known(Coord),
}

enum ComplexEnum {
    Nothing,
    Something(u32),
    LotsOfThings {
        usual_struct_stuff: bool,
        blah: String,
    }
}

Those are actually tagged unions, so in first version I will only support enum without any payload, and we may need to discuss how to serialize those union.

@theweipeng @chaokunyang

jiacai2050 avatar Aug 23 '24 01:08 jiacai2050

https://serde.rs/enum-representations.html

Serde has 4 methods to serialize enum.

jiacai2050 avatar Aug 23 '24 01:08 jiacai2050