fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.

Home Page:https://fzyzcjy.github.io/flutter_rust_bridge/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

jquesada2016 opened this issue · comments

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

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.

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

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.