Closed oo-work closed 2 weeks ago
Hi! Thanks for opening your first issue here! :smile:
Here your CustomError should auto implements FrbException
but indeed it does not.
Since you are using the experimental feature of auto scanning a whole third party crate, I guess this may be the cause.
A workaround may be, could you please try to have your CustomError in your main crate (instead of third party crate), or use the manual way of mirroring the 3rd party crate?
After I use mirror
, Rust struct can be translated into FrbException. But Rust enum cannot be used as FrbException, it will always be translated into RustOpaqueInterface
https://cjycode.com/flutter_rust_bridge/guides/third-party/manual/external-types#example Seems that mirror
is:
Enums with struct variants are not yet supported
A workaround may be, create your own enum in first party package (and convert it between the 3rd party one).
I tried changing the enum to a normal struct and it working.
Happy to see that!
Close since this seems to be solved, but 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.
Now there is an Error in a third-party crate, which may be like this.
flutter_rust_bridge.yaml
When returning a
Result<(), CustomError)
, Dart uses print(e.runtimeType); to print outCustomErrorImpl
.I want it to be a CustomError and have access to the type in the enum and call toString().
But dart generates such code, and the Exception type is not CustomError.