Fix async_trait usage

This commit is contained in:
Maximilian Ammann 2022-01-09 14:49:21 +01:00
parent c43a718056
commit 71ac754ec3
5 changed files with 12 additions and 6 deletions

View File

@ -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<Vec<u8>, 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;

View File

@ -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 {}

View File

@ -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 {

View File

@ -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())

View File

@ -16,7 +16,8 @@ impl From<JsValue> 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 {}