forked from Maximkaaa/galileo
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Limit render bundle cache size (Maximkaaa#28)
* Fix vector tiles for web target * Improve raster tiles caching * Refactor vector tile layer with data providers
- Loading branch information
Showing
26 changed files
with
1,193 additions
and
537 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
pub mod file_cache; | ||
pub mod url_data_provider; | ||
pub mod url_image_provider; | ||
|
||
use crate::error::GalileoError; | ||
use bytes::Bytes; | ||
use maybe_sync::{MaybeSend, MaybeSync}; | ||
use std::future::Future; | ||
|
||
pub trait DataProvider<Key, Data, Context>: MaybeSend + MaybeSync | ||
where | ||
Key: MaybeSend + MaybeSync + ?Sized, | ||
Context: MaybeSend + MaybeSync, | ||
{ | ||
fn load_raw(&self, key: &Key) -> impl Future<Output = Result<Bytes, GalileoError>> + MaybeSend; | ||
fn decode(&self, bytes: Bytes, context: Context) -> Result<Data, GalileoError>; | ||
fn load( | ||
&self, | ||
key: &Key, | ||
context: Context, | ||
) -> impl Future<Output = Result<Data, GalileoError>> + MaybeSend { | ||
async { | ||
let raw = self.load_raw(key).await?; | ||
self.decode(raw, context) | ||
} | ||
} | ||
} | ||
|
||
pub trait DataProcessor { | ||
type Input; | ||
type Output; | ||
type Context; | ||
|
||
fn process( | ||
&self, | ||
input: Self::Input, | ||
context: Self::Context, | ||
) -> Result<Self::Output, GalileoError>; | ||
} | ||
|
||
pub trait PersistentCacheController<Key: ?Sized, Data> { | ||
fn get(&self, key: &Key) -> Option<Data>; | ||
fn insert(&self, key: &Key, data: &Data) -> Result<(), GalileoError>; | ||
} | ||
|
||
pub struct EmptyCache {} | ||
impl<Key: ?Sized, Data> PersistentCacheController<Key, Data> for EmptyCache { | ||
fn get(&self, _key: &Key) -> Option<Data> { | ||
None | ||
} | ||
|
||
fn insert(&self, _key: &Key, _data: &Data) -> Result<(), GalileoError> { | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.