Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Rust] add enum for fury macro derive #1393

Closed
peacess opened this issue Mar 1, 2024 · 4 comments · Fixed by #1817
Closed

[Rust] add enum for fury macro derive #1393

peacess opened this issue Mar 1, 2024 · 4 comments · Fixed by #1817
Assignees
Labels
enhancement New feature or request

Comments

@peacess
Copy link

peacess commented Mar 1, 2024

as title

@peacess peacess added the enhancement New feature or request label Mar 1, 2024
@theweipeng
Copy link
Member

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 theweipeng changed the title add enum for fury macro derive [Rust] add enum for fury macro derive Mar 4, 2024
@jiacai2050
Copy link
Contributor

let fields = match &ast.data {
syn::Data::Struct(s) => sorted_fields(&s.fields),
_ => {
panic!("only struct be supported")
}

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

@jiacai2050
Copy link
Contributor

jiacai2050 commented Aug 23, 2024

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
Copy link
Contributor

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

Serde has 4 methods to serialize enum.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants