mirror of
https://github.com/maplibre/maplibre-rs.git
synced 2025-12-08 19:05:57 +00:00
Fix async_trait usage
This commit is contained in:
parent
c43a718056
commit
71ac754ec3
@ -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;
|
||||
|
||||
|
||||
@ -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 {}
|
||||
|
||||
@ -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 {
|
||||
|
||||
@ -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())
|
||||
|
||||
@ -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 {}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user