#[frb(opaque)] and async funcs for struct #1575
Unanswered
Corban-Dallas
asked this question in
Q&A
Replies: 1 comment 1 reply
-
After some investigation, it looks like the core problem is in error: future cannot be sent between threads safely
--> src/frb_generated.rs:43:33
|
43 | FLUTTER_RUST_BRIDGE_HANDLER.wrap_async::<flutter_rust_bridge::for_generated::DcoCodec, _, _, _>(
| ^^^^^^^^^^ future created by async block is not `Send`
|
= help: within `{async block@src/frb_generated.rs:52:28: 62:14}`, the trait `std::marker::Send` is not implemented for `std::sync::RwLockReadGuard<'_, frb_books::WrappedCtr>`
note: future is not `Send` as this value is used across an await
--> src/frb_generated.rs:57:91
|
55 | let api_that = api_that.rust_auto_opaque_decode_ref()?;
| -------- has type `std::sync::RwLockReadGuard<'_, frb_books::WrappedCtr>` which is not `Send`
56 | Result::<_, anyhow::Error>::Ok(
57 | crate::api::frb_books::WrappedCtr::create(&api_that, api_draft).await,
| ^^^^^ await occurs here, with `api_that` maybe used later
note: required by a bound in `wrap_async`
--> /Users/grigory.k/.cargo/registry/src/index.crates.io-6f17d22bba15001f/flutter_rust_bridge-2.0.0-dev.9/src/handler/handler.rs:63:15
|
55 | fn wrap_async<Rust2DartCodec, PrepareFn, TaskFn, TaskRetFut>(
| ---------- required by a bound in this associated function
...
63 | + TaskRetFutTrait
| ^^^^^^^^^^^^^^^ required by this bound in `Handler::wrap_async` I am not so good in Rust, hoped that to mark |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I have a complex struct,
Ctr
for simplicity, which I want to wrap and send to Dart to work with. However, generated code complains about UnwindSafe and other related issues for every asynchronous function, even when I use AssertUnwindSafe and catch_unwind. Is there a correct way to resolve this issue?Beta Was this translation helpful? Give feedback.
All reactions