-
Notifications
You must be signed in to change notification settings - Fork 258
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
WASM tracking #35
Comments
A possible workaround for the Send+Sync issue could be a macro attribute like
which adds the bound for non-wasm targets. |
Required proc macro: (Requires syn and quote crates) use proc_macro::TokenStream;
use quote::quote;
use syn::{parse_macro_input, parse_quote, ItemTrait};
/// Attribute to use `Send + Sync` for everything but wasm32
#[proc_macro_attribute]
pub fn send_sync(_attr: TokenStream, input: TokenStream) -> TokenStream {
// Parse the input tokens into a syntax tree
let mut input = parse_macro_input!(input as ItemTrait);
let send_trait_bound = parse_quote!(std::marker::Send);
let sync_trait_bound = parse_quote!(std::marker::Sync);
input.supertraits.push(send_trait_bound);
input.supertraits.push(sync_trait_bound);
TokenStream::from(quote!(#input))
} |
And a specific macro for async_trait on EventEmitter as the send_sync macro doesn't work: /// A wasm32 compatible wrapper for the async_trait::async_trait macro
#[proc_macro_attribute]
pub fn async_trait(_attr: TokenStream, item: TokenStream) -> TokenStream {
let attrs = r#"
#[cfg_attr(target_arch = "wasm32", async_trait::async_trait(?Send))]
#[cfg_attr(not(target_arch = "wasm32"), async_trait::async_trait)]
"#;
let mut out: TokenStream = attrs.parse().unwrap();
out.extend(item);
out
} it replaces |
Also the async_trait macro needs to be used on all impl. You might use |
I forgot to mention this over here, but we have a prototype It uses a fork of indexeddb-rs since the upstream one doesn't compile, fork is over here. |
Closing as all boxes are checked. Thanks @gnunicorn for the missing piece. |
Send + Sync
(Do wasm sepcific changes #60)Instant
is using the instant crate butwasm-timer
provides anInstant
as well, so could get potentially changedfutures-locks
once a new version gets published (Release 0.5.1 asomers/futures-locks#38) (matrix-sdk-common: Switch futures-locks to crates.io version #94)Extracted from: #31 (review)
The text was updated successfully, but these errors were encountered: