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

Don't ignore (unignore or keep) a struct or field #2469

Open
satvikpendem opened this issue Dec 26, 2024 · 4 comments
Open

Don't ignore (unignore or keep) a struct or field #2469

satvikpendem opened this issue Dec 26, 2024 · 4 comments
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request

Comments

@satvikpendem
Copy link
Contributor

Is your feature request related to a problem? Please describe.
FRB seems like it ignores structs it doesn't see in the code, but I want to use it as a way to share types in Rust and Dart. My use case is generated JSON and in Rust I can annotate a struct with serde's derive (in actuality, the library I am using to generate the JSON already uses serde internally so I usually don't have to annotate anything manually). Then I send that JSON to Dart and it'd be nice to share the Rust struct with Dart such that the class is autogenerated and thus kept in sync with Rust, as FRB already does.

Describe the solution you'd like
To fix this, currently I have to make a dummy method using the struct to make sure FRB sees it and generates the Dart class from the struct, but I shouldn't have to make such a dummy method. Instead, there should be some sort of annotation like unignore that will force that class to be created.

Describe alternatives you've considered
Writing a dummy method using the struct.

Additional context
NA

@satvikpendem satvikpendem added the enhancement New feature or request label Dec 26, 2024
@satvikpendem satvikpendem changed the title Don't ignore a struct or field Don't ignore (unignore or keep) a struct or field Dec 26, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Dec 26, 2024

Looks reasonable and feel free to PR! Since this is a feature request and has workaround (use a dummy function), I may not implement it in top priority.

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Dec 26, 2024
@VladTheJunior
Copy link

@satvikpendem I had same problem. You can add #[frb] attribute before struct definition, and it will be converted into dart, even if it not used on rust side

@satvikpendem
Copy link
Contributor Author

@VladTheJunior does it work fine with the frb attribute? @fzyzcjy is this a viable solution or do we still need to make a PR for this?

@VladTheJunior
Copy link

Yes, for me it works fine, you can try it yourself

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants