fzyzcjy / flutter_rust_bridge

Flutter/Dart <-> Rust binding generator, feature-rich, but seamless and simple.
https://fzyzcjy.github.io/flutter_rust_bridge/
MIT License
4.22k stars 290 forks source link

Getting started with third party packages #2352

Open ethicnology opened 19 hours ago

ethicnology commented 19 hours ago

Is your feature request related to a problem? Please describe. Hey there, I love to see it getting more and more mature. I would like to start to use it on some projects but I'm facing "getting started" problem. The one-liner to generate a flutter app with some rust functions is great but when it comes to third parties libraries I feel lost. I've read various sections of the documentation but it miss step by step approach so we can step in without many doubts

Describe the solution you'd like

Describe what you've tried

  1. flutter_rust_bridge one liner
  2. cd rust
  3. Import a third party library: cargo add nostr
  4. cd ..
  5. flutter_rust_bridge_codegen generate

error:

flutter_rust_bridge_codegen-2.5.0/src/library/codegen/ir/mir/ty/enumeration.rs:51:32:
enum_pool does not contain MirTypeEnumRef { ident: MirEnumIdent(NamespacedName { namespace: Namespace { joined_path: "nostr::nips::nip19" }, name: "Nip19" }), is_exception: false }
thread 'main' panicked at flutter_rust_bridge_codegen-2.5.0/src/library/codegen/ir/mir/ty/enumeration.rs:51:32:
enum_pool does not contain MirTypeEnumRef { ident: MirEnumIdent(NamespacedName { namespace: Namespace { joined_path: "nostr::nips::nip19" }, name: "Nip19" }), is_exception: false }
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

Additional context I give here the example with the nostr third party package but I do not seek a specific answer for this, I'm looking for a more comprehensive way of using your tool his limits and how to work around.

fzyzcjy commented 15 hours ago

Hi, automatically scanning a whole third party package is experimental feature and may not support too complex arbitrary packages (since there are so many corner cases for Rust). Looks like nostr may contain some edge cases that does not support yet. But feel free to use the https://cjycode.com/flutter_rust_bridge/guides/third-party/manual manual way or to improve this experimental feature!