Closed emirror-de closed 6 months ago
Yeah so apparently JsFuture
(exported by wasm_bindgen_futures
) which is the underpinning type of this crate does not implement Send
which async_trait
imposes on the methods.
As WASM (at least right now) is not multithreaded anyway having a Send
requirement doesn't really make sense to begin with.
To solve this you can either use the "proper" async trait
that's currently in nightly but will be stable with 1.75.0 since that doesn't require the Send
bound,
or you disable the Send
bound in the async_trait macro like shown here https://docs.rs/async-trait/0.1.74/async_trait/#non-threadsafe-futures
Ah awesome! Thanks for this detailed explanation!
Hi, thanks for this great library!
I was trying to use the
invoke
function in a trait implementation but received an error regarding thread safety.Is this behavior intentionally?
See example and error below.
Cargo.toml
main.rs
Output: