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

Methods aren't being generated for structs declared at the api root #1841

Closed
jquesada2016 opened this issue Mar 27, 2024 · 2 comments · Fixed by #1956 or #2000
Closed

Methods aren't being generated for structs declared at the api root #1841

jquesada2016 opened this issue Mar 27, 2024 · 2 comments · Fixed by #1956 or #2000
Labels
awaiting Waiting for responses, PR, further discussions, upstream release, etc bug Something isn't working

Comments

@jquesada2016
Copy link

Describe the bug

If I put a struct at the root of the api, i.e. src/api/mod.rs, structs are converted to classes, but no methods are added to them.

struct MyStruct {}

impl MyStruct {
  #[frb(sync)]
  pub fn do_it(&self) {}
}

The class MyStruct is generated, but with no methods. This behavior is the same whether the struct is opaque or not.

If I move the struct anywhere else in the api sub-module, it then works.

Steps to reproduce

  1. Copy the above example into src/api/mod.rs
  2. Generate the code
  3. Observe the lack of methods
  4. Move the example to src/api/works.rs
  5. Generate the code
  6. Observe it now works

Logs

N/A

Expected behavior

No response

Generated binding code

No response

OS

No response

Version of flutter_rust_bridge_codegen

No response

Flutter info

No response

Version of clang++

No response

Additional context

No response

@jquesada2016 jquesada2016 added the bug Something isn't working label Mar 27, 2024
@fzyzcjy fzyzcjy added the awaiting Waiting for responses, PR, further discussions, upstream release, etc label Mar 27, 2024
@fzyzcjy
Copy link
Owner

fzyzcjy commented Mar 27, 2024

Good observation, that looks like a bug, but the workaround is to try to put it at non-mod.rs. I may look at it later to see whether there is an easy fix.

@fzyzcjy
Copy link
Owner

fzyzcjy commented May 31, 2024

Hope #2000 will make declared at api root supported :)

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 bug Something isn't working
Projects
None yet
2 participants