-
Notifications
You must be signed in to change notification settings - Fork 307
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
Use #[frb(ignore)] on struct fields #2201
Comments
Hi! Thanks for opening your first issue here! 😄 |
That looks reasonable. I guess it is not hard if the struct is only used as a return type, because we can simply treat the field as not existing at all and done. But if it is used as an argument, maybe we need to explicitly ask users to provide a value. Btw, I wonder whether https://cjycode.com/flutter_rust_bridge/guides/types/translatable/custom will help? For example,
Looking forward to your PR! |
I tried the custom translation and it still had the same Rust compiler error. Maybe I am missing something but it didn't seem to affect the rust bindings at all, just the generated dart code. That's a good point with arguments. I'll dig into it a bit and see how to make it work. Thanks! |
You are welcome! Btw, you can paste the whole error stack trace and that may be slightly more helpful in debugging when is going on. |
Ok, after some thought I think the best way to solve it is with the custom encoder. That prevents the problem you mentioned of translating a type back to rust. |
For normal third party structs, that is created when MirStruct.mirror=true. Maybe mimic that code path and see what is going on. |
See #2212 (comment) for updates. Feel free to reopen if you have any questions! |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new issue. |
I'm having issues translating a struct where one of the fields is from an external crate and I don't care about its contents in flutter.
Something like:
When I run codegen, I get a
cannot find type ExternalStruct in this scope
compiler error on frb_generated.rs.The doc page on ignoring functions says: "Currently
#[frb(ignore)]
doesn't support enums and structs yet - feel free to open an issue if your scenario needs it."It would be useful to have an ignore macro for struct fields:
I've tried making the
ExternalStruct
opaque but still get errors and would prefer not to use RustAutoOpaque because theMyStruct
type is used elsewhere.Not sure if ignoring fields is possible with the memory model of flutter rust bridge but I'm happy to help with changes.
The text was updated successfully, but these errors were encountered: