Closed bryanmehall closed 2 months ago
Hi! Thanks for opening your first issue here! :smile:
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,
but I'm happy to help with changes.
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.
I am running into the same issue as here #2212 with the into_into_dart
compiler error. I spent the afternoon trying to figure out how to add the IntoIntoDart
trait to codegen so I could create a PR but couldn't figure it out. Any ideas on where that should be added in? It looks like the IntoDart
and IntoIntoDart
traits are only generated for the Dco
codec mode.
Once that is fixed I'll add to the custom encoder docs explaining how to make it work with third-party types and use it to ignore struct fields.
Any ideas on where that should be added in?
For normal third party structs, that is created when MirStruct.mirror=true. Maybe mimic that code path and see what is going on.
See https://github.com/fzyzcjy/flutter_rust_bridge/issues/2212#issuecomment-2345141553 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.