As a helpful tip, looking at the full error message that is printed to your terminal when you run cargo check
in your project is often times better, as IDEs are notorious for removing useful output from error messages.
As to your error, kuchikiki::NodeRef
can't be shared between threads because it is !Send
as it stores an Rc
(not threadsafe reference counted pointer type) internally.
To fix your problem, avoid keeping a NodeRef
across .await
points. When you hit an .await
, your future might get suspended and rescheduled to a different thread, so the state captured by the future must be Send
.[1] get_total_pages
does not need to be async
(you never .await
anything in it) so just making it synchronous should be enough to solve your problem.
This is not an inherent part of the
Future
API—i.e. futures don't need to beSend
per se—but an implementation detail of the multithreaded async Tokio runtime used under the hood of Tauri. ↩︎