diff --git a/martin/src/file_config.rs b/martin/src/file_config.rs index e222017cc..c9d9f052b 100644 --- a/martin/src/file_config.rs +++ b/martin/src/file_config.rs @@ -12,7 +12,7 @@ use crate::config::{copy_unrecognized_config, UnrecognizedValues}; use crate::file_config::FileError::{ InvalidFilePath, InvalidSourceFilePath, InvalidSourceUrl, IoError, }; -use crate::source::{Source, TileInfoSources}; +use crate::source::{TileInfoSource, TileInfoSources}; use crate::utils::{IdResolver, OptMainCache, OptOneMany}; use crate::MartinResult; use crate::OptOneMany::{Many, One}; @@ -70,13 +70,13 @@ pub trait SourceConfigExtras: ConfigExtras { &self, id: String, path: PathBuf, - ) -> impl std::future::Future>> + Send; + ) -> impl std::future::Future> + Send; fn new_sources_url( &self, id: String, url: Url, - ) -> impl std::future::Future>> + Send; + ) -> 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 2488098a0..31e6768d8 100644 --- a/martin/src/mbtiles/mod.rs +++ b/martin/src/mbtiles/mod.rs @@ -14,7 +14,7 @@ use url::Url; use crate::config::UnrecognizedValues; use crate::file_config::FileError::{AcquireConnError, InvalidMetadata, IoError}; use crate::file_config::{ConfigExtras, FileResult, SourceConfigExtras}; -use crate::source::{TileData, UrlQuery}; +use crate::source::{TileData, TileInfoSource, UrlQuery}; use crate::{MartinResult, Source}; #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] @@ -30,14 +30,14 @@ impl ConfigExtras for MbtConfig { } impl SourceConfigExtras for MbtConfig { - async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { + 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> { + async fn new_sources_url(&self, _id: String, _url: Url) -> FileResult { unreachable!() } } @@ -96,7 +96,7 @@ impl Source for MbtSource { self.tile_info } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/pg/pg_source.rs b/martin/src/pg/pg_source.rs index 8f1b34712..bfc989788 100644 --- a/martin/src/pg/pg_source.rs +++ b/martin/src/pg/pg_source.rs @@ -9,7 +9,7 @@ use tilejson::TileJSON; use crate::pg::pool::PgPool; use crate::pg::utils::query_to_json; use crate::pg::PgError::{GetTileError, GetTileWithQueryError, PrepareQueryError}; -use crate::source::{Source, TileData, UrlQuery}; +use crate::source::{Source, TileData, TileInfoSource, UrlQuery}; use crate::MartinResult; #[derive(Clone, Debug)] @@ -46,7 +46,7 @@ impl Source for PgSource { TileInfo::new(Mvt, Uncompressed) } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/pmtiles/mod.rs b/martin/src/pmtiles/mod.rs index c24b823b7..159b33b32 100644 --- a/martin/src/pmtiles/mod.rs +++ b/martin/src/pmtiles/mod.rs @@ -20,7 +20,7 @@ use url::Url; use crate::config::UnrecognizedValues; use crate::file_config::FileError::{InvalidMetadata, InvalidUrlMetadata, IoError}; use crate::file_config::{ConfigExtras, FileError, FileResult, SourceConfigExtras}; -use crate::source::UrlQuery; +use crate::source::{TileInfoSource, UrlQuery}; use crate::utils::cache::get_cached_value; use crate::utils::{CacheKey, CacheValue, OptMainCache}; use crate::{MartinResult, Source, TileData}; @@ -134,13 +134,13 @@ impl SourceConfigExtras for PmtConfig { true } - async fn new_sources(&self, id: String, path: PathBuf) -> FileResult> { + async fn new_sources(&self, id: String, path: PathBuf) -> FileResult { Ok(Box::new( PmtFileSource::new(self.new_cached_source(), id, path).await?, )) } - async fn new_sources_url(&self, id: String, url: Url) -> FileResult> { + async fn new_sources_url(&self, id: String, url: Url) -> FileResult { Ok(Box::new( PmtHttpSource::new( self.client.clone().unwrap(), @@ -250,7 +250,7 @@ macro_rules! impl_pmtiles_source { self.tile_info } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { Box::new(self.clone()) } diff --git a/martin/src/source.rs b/martin/src/source.rs index 879fa4592..d95f2fd51 100644 --- a/martin/src/source.rs +++ b/martin/src/source.rs @@ -18,7 +18,7 @@ pub type TileInfoSource = Box; pub type TileInfoSources = Vec; #[derive(Default, Clone)] -pub struct TileSources(HashMap>); +pub struct TileSources(HashMap); pub type TileCatalog = BTreeMap; impl TileSources { @@ -107,7 +107,7 @@ pub trait Source: Send + Debug { fn get_tile_info(&self) -> TileInfo; - fn clone_source(&self) -> Box; + fn clone_source(&self) -> TileInfoSource; fn support_url_query(&self) -> bool { false @@ -139,7 +139,7 @@ pub trait Source: Send + Debug { } } -impl Clone for Box { +impl Clone for TileInfoSource { fn clone(&self) -> Self { self.clone_source() } diff --git a/martin/src/srv/server.rs b/martin/src/srv/server.rs index 75af0e6b2..a33d39a4f 100755 --- a/martin/src/srv/server.rs +++ b/martin/src/srv/server.rs @@ -201,7 +201,7 @@ pub mod tests { use tilejson::TileJSON; use super::*; - use crate::source::{Source, TileData}; + use crate::source::{Source, TileData, TileInfoSource}; use crate::UrlQuery; #[derive(Debug, Clone)] @@ -225,7 +225,7 @@ pub mod tests { TileInfo::new(Format::Mvt, Encoding::Uncompressed) } - fn clone_source(&self) -> Box { + fn clone_source(&self) -> TileInfoSource { unimplemented!() }