From 99db6d771d7ccb21089e06742e53922f6bcc52d2 Mon Sep 17 00:00:00 2001 From: Yuri Astrakhan Date: Thu, 11 Apr 2024 03:36:19 -0400 Subject: [PATCH] Upgrade to pmtiles, rm async-trait in a trait (#1300) * Bump to pmtiles that doesn't use `async_trait` crate * `trait SourceConfigExtras` no longer needs `#[async_trait]` --- Cargo.lock | 5 ++--- Cargo.toml | 2 +- martin/src/file_config.rs | 15 +++++++++++---- martin/src/mbtiles/mod.rs | 4 +++- martin/src/pmtiles/mod.rs | 3 +-- martin/src/sprites/mod.rs | 2 -- 6 files changed, 18 insertions(+), 13 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 0e79a609..b2e9c7bd 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2892,13 +2892,12 @@ dependencies = [ [[package]] name = "pmtiles" -version = "0.8.0" +version = "0.9.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5382dab62c7151c9fb050626ad18560b4900e133257033782abb3b7ae23f2234" +checksum = "a1336029dbfe273811a751f91e85a6011bcfe399c9b8d1ad9662e96df2a2d74e" dependencies = [ "async-compression", "async-recursion", - "async-trait", "bytes", "fmmap", "hilbert_2d", diff --git a/Cargo.toml b/Cargo.toml index 7c6c15d3..1a96e23f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -55,7 +55,7 @@ mbtiles = { path = "./mbtiles", version = "0.9.0" } moka = { version = "0.12", features = ["future"] } num_cpus = "1" pbf_font_tools = { version = "2.5.1", features = ["freetype"] } -pmtiles = { version = "0.8", features = ["http-async", "mmap-async-tokio", "tilejson", "reqwest-rustls-tls-native-roots"] } +pmtiles = { version = "0.9", features = ["http-async", "mmap-async-tokio", "tilejson", "reqwest-rustls-tls-native-roots"] } postgis = "0.9" postgres = { version = "0.19", features = ["with-time-0_3", "with-uuid-1", "with-serde_json-1"] } postgres-protocol = "0.6" diff --git a/martin/src/file_config.rs b/martin/src/file_config.rs index d79c008d..695ef9d0 100644 --- a/martin/src/file_config.rs +++ b/martin/src/file_config.rs @@ -3,7 +3,6 @@ use std::fmt::Debug; use std::mem; use std::path::{Path, PathBuf}; -use async_trait::async_trait; use futures::TryFutureExt; use log::{info, warn}; use serde::{Deserialize, Serialize}; @@ -61,15 +60,23 @@ pub trait ConfigExtras: Clone + Debug + Default + PartialEq + Send { fn get_unrecognized(&self) -> &UnrecognizedValues; } -#[async_trait] pub trait SourceConfigExtras: ConfigExtras { #[must_use] fn parse_urls() -> bool { false } - async fn new_sources(&self, id: String, path: PathBuf) -> FileResult>; - async fn new_sources_url(&self, id: String, url: Url) -> FileResult>; + fn new_sources( + &self, + id: String, + path: PathBuf, + ) -> impl std::future::Future>> + Send; + + fn new_sources_url( + &self, + id: String, + url: Url, + ) -> impl std::future::Future>> + Send; } #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] diff --git a/martin/src/mbtiles/mod.rs b/martin/src/mbtiles/mod.rs index d9ea2dfc..b9e446f2 100644 --- a/martin/src/mbtiles/mod.rs +++ b/martin/src/mbtiles/mod.rs @@ -29,12 +29,14 @@ impl ConfigExtras for MbtConfig { } } -#[async_trait] impl SourceConfigExtras for MbtConfig { async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { Ok(Box::new(MbtSource::new(id, path).await?)) } + // TODO: Remove #[allow] after switching to Rust/Clippy v1.78+ in CI + // See https://github.com/rust-lang/rust-clippy/pull/12323 + #[allow(clippy::no_effect_underscore_binding)] async fn new_sources_url(&self, _id: String, _url: Url) -> FileResult> { unreachable!() } diff --git a/martin/src/pmtiles/mod.rs b/martin/src/pmtiles/mod.rs index 4a972ff0..3b0c134f 100644 --- a/martin/src/pmtiles/mod.rs +++ b/martin/src/pmtiles/mod.rs @@ -39,7 +39,6 @@ impl PmtCache { } } -#[async_trait] impl DirectoryCache for PmtCache { async fn get_dir_entry(&self, offset: usize, tile_id: u64) -> DirCacheResult { if let Some(dir) = get_cached_value!(&self.cache, CacheValue::PmtDirectory, { @@ -129,7 +128,7 @@ impl ConfigExtras for PmtConfig { &self.unrecognized } } -#[async_trait] + impl SourceConfigExtras for PmtConfig { fn parse_urls() -> bool { true diff --git a/martin/src/sprites/mod.rs b/martin/src/sprites/mod.rs index 7dce53c8..07e1c769 100644 --- a/martin/src/sprites/mod.rs +++ b/martin/src/sprites/mod.rs @@ -3,7 +3,6 @@ use std::collections::{BTreeMap, HashMap}; use std::fmt::Debug; use std::path::PathBuf; -use async_trait::async_trait; use futures::future::try_join_all; use log::{info, warn}; use serde::{Deserialize, Serialize}; @@ -65,7 +64,6 @@ pub struct SpriteConfig { pub unrecognized: UnrecognizedValues, } -#[async_trait] impl ConfigExtras for SpriteConfig { fn get_unrecognized(&self) -> &UnrecognizedValues { &self.unrecognized