Closed niuhuan closed 3 weeks ago
At first glance, I guess it is because async fn
really need to be Send, because it can be executed in multi threads.
So my first guess is, try to ensure things are Send, e.g.
dyn futures_util::Future<Output = Result<Vec<entities::ComicCategory>, anyhow::Error>> + 'static
change to
dyn futures_util::Future<Output = Result<Vec<entities::ComicCategory>, anyhow::Error>> + Send + 'static
Thanks for your help.
Solving the problem:
codes
from
pin: Pin<Box<dyn Future<Output=anyhow::Result<T>>>>,
to
pin: Pin<Box<dyn Future<Output=anyhow::Result<T>> + Send>>,
Happy to see it is solved!
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.
flutter_rust_bridge supported async fn is a cool feature. I have tried it in other code repositories and it works very well, but I encountered difficulties upgrading frb in some old code repositories.
I had upgrade flutter_rust_bridge from
v1.54.0
tov2.4.0
.Due to the difficulty of description, please refer to my different versions of code.
This is code with
v1.54.0
, I had make a staticRUNTIME
andblock_on
use it, It has run success.I am urgently using the new version of FRB, which has much higher asynchronous efficiency than mine. This is code with
v2.4.0
, I deletedblock_on
andRUNTIME
,Wow, The code becomes neat.
But it can't be compiled. there has logs
I think the problem lies in the mutex or pin parameter, But I don't know how to modify it, and I have many functions with this problem.
I have tried to wrap each function into a struct and then call a method of it to avoid this problem. But it is a lot of work. I hope someone can tell me the right way.