pub struct TileServer {
pub cache: TileCache,
pub push_policy: PushPolicy,
pub prefetcher: TilePrefetcher,
}Expand description
Unified tile serving combining an LRU cache, push policy, and prefetcher.
Fields§
§cache: TileCacheThe underlying LRU tile cache.
push_policy: PushPolicyPolicy for generating HTTP/2 push hints.
prefetcher: TilePrefetcherPrefetcher for enumerating neighbouring tiles.
Implementations§
Source§impl TileServer
impl TileServer
Sourcepub fn new(base_url: impl Into<String>) -> Self
pub fn new(base_url: impl Into<String>) -> Self
Creates a TileServer with a 1 GiB / 1 024-entry cache.
Sourcepub fn serve(
&mut self,
key: &TileKey,
if_none_match: Option<&str>,
now: u64,
) -> TileResponse
pub fn serve( &mut self, key: &TileKey, if_none_match: Option<&str>, now: u64, ) -> TileResponse
Serves a tile request, returning data, response headers, and push hints.
- Cache miss →
NotFound. - Hit + matching
If-None-Match→NotModified(304). - Hit →
Okwith data,Cache-Control,ETag,Content-Type,Vary, and HTTP/2 push hints.
Sourcepub fn cache_tile(&mut self, key: TileKey, data: Vec<u8>, now: u64)
pub fn cache_tile(&mut self, key: TileKey, data: Vec<u8>, now: u64)
Stores a tile in the cache.
Sourcepub fn cache_stats(&self) -> CacheStats
pub fn cache_stats(&self) -> CacheStats
Returns a snapshot of cache statistics.
Auto Trait Implementations§
impl Freeze for TileServer
impl RefUnwindSafe for TileServer
impl Send for TileServer
impl Sync for TileServer
impl Unpin for TileServer
impl UnsafeUnpin for TileServer
impl UnwindSafe for TileServer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more