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

Generated class implements non-exist class #2484

Closed
Xudiwen opened this issue Jan 7, 2025 · 4 comments
Closed

Generated class implements non-exist class #2484

Xudiwen opened this issue Jan 7, 2025 · 4 comments

Comments

@Xudiwen
Copy link

Xudiwen commented Jan 7, 2025

Greetings.
I was new to this and ran into trouble soon.
I have Rust codes like:

pub struct Photo {
  ...
}
impl Datum for Photo {
  ...
}

It generates

abstract class Photo implements RustOpaqueInterface, Datum {
  ...
}

However, the Datum class is not generated.
I tried to add #[frb(ignore)] above impl Datum for Photo, which is like:

pub struct Photo {
  ...
}
#[frb(ignore)]
impl Datum for Photo {
  ...
}

Then the methods of Datum disappeared in Photo Dart code, but the implements Datum is still there.
I've searched for docs and existing issues but unfortunately cannot find something helpful.
So is there any suggestions?
I'm now working on flutter_rust_bridge_codegen 2.7.0.

Copy link

welcome bot commented Jan 7, 2025

Hi! Thanks for opening your first issue here! 😄

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 8, 2025

Hmm how is your Datum defined? Is it third-party or something like that? Looks like this may an edge case that has not been considered. A workaround is to use dart_preamble: import "my_dummy_definitions.dart", and in that dart file, manually write down an empty class class Datum {}.

@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jan 8, 2025
@Xudiwen
Copy link
Author

Xudiwen commented Jan 8, 2025

Hmm how is your Datum defined? Is it third-party or something like that? Looks like this may an edge case that has not been considered. A workaround is to use dart_preamble: import "my_dummy_definitions.dart", and in that dart file, manually write down an empty class class Datum {}.

Thank you for replying.

I'm not sure but the Datum trait is not a dyn trait, i.e. it contains some function and is Sized.
I wonder if traits like this (non-dyn) should not be considered an interface and implements by dart class.
I haven't tried to compare behavior differences between dyn trait or non-dyn trait, but at least the Datum was not translated into dart class.

The workaround works fine. Thanks a lot! This issue is free to be closed now.

@fzyzcjy
Copy link
Owner

fzyzcjy commented Jan 8, 2025

Hmm, I guess it may be reasonable to be an interface. Though currently &dyn MyTrait is translated, but later &impl MyTrait may also be technically possible to have.

The workaround works fine. Thanks a lot! This issue is free to be closed now.

You are welcome!

@fzyzcjy fzyzcjy closed this as completed Jan 8, 2025
@fzyzcjy fzyzcjy removed the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Jan 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants