diff --git a/src/io/mod.rs b/src/io/mod.rs index d4753861..011797fa 100644 --- a/src/io/mod.rs +++ b/src/io/mod.rs @@ -6,14 +6,16 @@ pub mod cache; pub mod static_tile_fetcher; pub mod web_tile_fetcher; -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] pub trait HttpFetcher { fn new() -> Self; async fn fetch(&self, url: &str) -> Result, Error>; } -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] pub trait TileFetcher { fn new() -> Self; diff --git a/src/io/static_tile_fetcher.rs b/src/io/static_tile_fetcher.rs index 162e5c45..8e382d97 100644 --- a/src/io/static_tile_fetcher.rs +++ b/src/io/static_tile_fetcher.rs @@ -19,7 +19,8 @@ impl StaticTileFetcher { } } -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl TileFetcher for StaticTileFetcher { fn new() -> Self { Self {} diff --git a/src/io/web_tile_fetcher.rs b/src/io/web_tile_fetcher.rs index 96e6a671..bbb1197b 100644 --- a/src/io/web_tile_fetcher.rs +++ b/src/io/web_tile_fetcher.rs @@ -8,7 +8,8 @@ pub struct WebTileFetcher { http_fetcher: PlatformHttpFetcher, } -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl TileFetcher for WebTileFetcher { fn new() -> Self { Self { diff --git a/src/platform/noweb/mod.rs b/src/platform/noweb/mod.rs index a776d0f1..4ed1bc1c 100644 --- a/src/platform/noweb/mod.rs +++ b/src/platform/noweb/mod.rs @@ -25,7 +25,8 @@ pub struct PlatformHttpFetcher { client: ClientWithMiddleware, } -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl HttpFetcher for PlatformHttpFetcher { fn new() -> Self { let client = ClientBuilder::new(Client::new()) diff --git a/src/platform/web/http_fetcher.rs b/src/platform/web/http_fetcher.rs index 1e9552e0..010465b6 100644 --- a/src/platform/web/http_fetcher.rs +++ b/src/platform/web/http_fetcher.rs @@ -16,7 +16,8 @@ impl From for Error { pub struct PlatformHttpFetcher; -#[async_trait(?Send)] +#[cfg_attr(target_arch = "wasm32", async_trait(?Send))] +#[cfg_attr(not(target_arch = "wasm32"), async_trait)] impl HttpFetcher for PlatformHttpFetcher { fn new() -> Self { Self {}