Skip to content

Commit

Permalink
Add Directory::get_approx_byte_size and bump MSRV (#29)
Browse files Browse the repository at this point in the history
For cache eviction purposes, it is important to know the size of the directory objects.  Also, I ran `cargo msrv` to figure out the minimal one.
  • Loading branch information
nyurik authored Dec 24, 2023
1 parent 594535e commit e95a0a3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
[package]
name = "pmtiles"
version = "0.5.1"
version = "0.5.2"
edition = "2021"
authors = ["Luke Seelenbinder <[email protected]>"]
license = "MIT OR Apache-2.0"
description = "Implementation of the PMTiles v3 spec with multiple sync and async backends."
repository = "https://github.com/stadiamaps/pmtiles-rs"
keywords = ["pmtiles", "gis", "geo"]
rust-version = "1.61.0"
rust-version = "1.68.2"
categories = ["science::geo"]

[features]
Expand Down
7 changes: 7 additions & 0 deletions src/directory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ impl Debug for Directory {
}

impl Directory {
/// Find the directory entry for a given tile ID.
#[cfg(any(feature = "http-async", feature = "mmap-async-tokio"))]
#[must_use]
pub fn find_tile_id(&self, tile_id: u64) -> Option<&DirEntry> {
Expand All @@ -37,6 +38,12 @@ impl Directory {
}
}
}

/// Get an estimated byte size of the directory object. Use this for cache eviction.
#[must_use]
pub fn get_approx_byte_size(&self) -> usize {
self.entries.capacity() * std::mem::size_of::<DirEntry>()
}
}

impl TryFrom<Bytes> for Directory {
Expand Down

0 comments on commit e95a0a3

Please sign in to comment.