Skip to content

Comments

Make header methods publicly readable#110

Merged
nyurik merged 3 commits intostadiamaps:mainfrom
michaelkirk:mkirk/api-for-show-cli
Feb 20, 2026
Merged

Make header methods publicly readable#110
nyurik merged 3 commits intostadiamaps:mainfrom
michaelkirk:mkirk/api-for-show-cli

Conversation

@michaelkirk
Copy link
Contributor

Followup to #108, in which I attempted to add a CLI bin to this crate. There was a bit of friction, so instead I've extracted the CLI code to https://github.com/michaelkirk/pmtiles-rs-cli

Still, it requires some modest changes to the library code.

This was in pursuit of adding a CLI client for the pmtiles-rs crate.

See github.com/michaelkirk/pmtiles-rs-cli
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes additional read-only Header information via public accessor methods, to support external consumers (e.g., the extracted CLI tool) without making the underlying fields publicly mutable.

Changes:

  • Add public getters on Header for spec version, addressed/entry/content tile counts, clustering flag, and internal directory compression.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

src/header.rs Outdated
}
}

/// Get the version specification of the archive
Copy link

Copilot AI Feb 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Doc comment wording here is a bit unclear/grammatically awkward ("version specification"), and it’s missing a trailing period. Consider rephrasing to something like “Get the PMTiles spec version of the archive.” for clearer public API docs.

Suggested change
/// Get the version specification of the archive
/// Get the PMTiles spec version of the archive.

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please apply this - it seems you created this PR either from an org or without giving maintainers edit rights. Otherwise good to go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I did previously, but then pedantic clippy got mad, so I reverted it, because it didn't seem worth it.

I'll dig around for an appropriate allow rule so we can all feel really good about this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@codecov
Copy link

codecov bot commented Feb 17, 2026

Codecov Report

❌ Patch coverage is 0% with 18 lines in your changes missing coverage. Please review.
✅ Project coverage is 77.84%. Comparing base (739fa21) to head (640afeb).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
src/header.rs 0.00% 18 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #110      +/-   ##
==========================================
- Coverage   78.84%   77.84%   -1.00%     
==========================================
  Files          11       11              
  Lines        1404     1422      +18     
  Branches     1404     1422      +18     
==========================================
  Hits         1107     1107              
- Misses        192      210      +18     
  Partials      105      105              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@michaelkirk michaelkirk force-pushed the mkirk/api-for-show-cli branch from ba750ec to 178760c Compare February 17, 2026 23:23
@lseelenbinder
Copy link
Member

Looks good to me @michaelkirk. Why the use of #[must_use], though? I don't think that's standard practice for functions that don't return a Result.

@michaelkirk
Copy link
Contributor Author

michaelkirk commented Feb 19, 2026

🤓 Methods that return Result get must_use "for free" since it's annotated on the Result type. There's no need to annotate methods that return a Result with must_use.

I was trying to follow existing patterns, but I don't really care either way. I see now that the code base isn't entirely consistent about this.

must_use getters:

getters without must_use:

FWIW, my own thinking is that must_use is helpful for certain kinds of methods, but it's silly to add must_use to every single method. I've never tried to write out the "rules" for when to use must_use, but off the cuff:

  1. to ensure errors aren't ignored (we get this for free with Result type)
  2. to disambiguate mutating methods from "return a mutated copy methods", e.g. geo crate's scale vs scale_mut. If you don't know about scale_mut you might assume scale is a mutating method. We marked it as must_use to help avoid this case. This rationale doesn't apply to getters.

Do you want me to remove the must_use annotations from this PR?

@nyurik
Copy link
Collaborator

nyurik commented Feb 19, 2026

must_use use is usually driven by clippy complaining :)

@nyurik
Copy link
Collaborator

nyurik commented Feb 19, 2026

i would just keep it if it makes clippy happy

@michaelkirk
Copy link
Contributor Author

Indeed clippy complains if they are removed. It makes me question the projects use of clippy pedantic, but that's out of scope for this PR.

@nyurik
Copy link
Collaborator

nyurik commented Feb 19, 2026

heh, one of those minor pesky things... i did find must_use useful as a user of the lib, and its a small price to pay i guess

src/header.rs Outdated
}
}

#[allow(clippy::doc_markdown)]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not simply fix the doc comment with backticks?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had McDonald's for lunch.

I had McDonalds for lunch.

I'm writing documentation for people, not to appease clippy!

It just so happens that PMTiles PMTiles is conventionally capitalized in a way that it looks like a type in rust, but I'm referring to the proper noun, not to any code element (we don't even have a PMTiles type).

All that said, I don't really care that much. If you want me to write docs for clippy rather than people, I'll do it!

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are you unhappy with our machine overlord?!? Borgs won't be happy with you... You should have had Burger King... that said, if you look in the code base, all PMTiles have backticks around them in the docs - keeps things simpler :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ST-TNG-PRIF-Adult_ShortSleeve_Tshirt-RO_1445x jpg

@nyurik
Copy link
Collaborator

nyurik commented Feb 19, 2026

P.S. @lseelenbinder as mentioned above, I wouldn't worry about a few extra must_use - they did save me a few times, not really worth excluding that lint

@lseelenbinder
Copy link
Member

Agreed @nyurik! Let's keep clippy happy. 😃

I was mainly curious.

@nyurik nyurik merged commit babb11e into stadiamaps:main Feb 20, 2026
7 of 8 checks passed
nyurik pushed a commit that referenced this pull request Feb 20, 2026
## 🤖 New release

* `pmtiles`: 0.19.2 -> 0.20.0 (⚠ API breaking changes)

### ⚠ `pmtiles` breaking changes

```text
--- failure enum_variant_added: enum variant added on exhaustive enum ---

Description:
A publicly-visible enum without #[non_exhaustive] has a new variant.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#enum-variant-new
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_variant_added.ron

Failed in:
  variant PmtError:InvalidTileId in /tmp/.tmpxfPXJO/pmtiles-rs/src/error.rs:93
```

<details><summary><i><b>Changelog</b></i></summary><p>

<blockquote>

##
[0.20.0](v0.19.2...v0.20.0)
- 2026-02-20

### Other

- Make header methods publicly readable
([#110](#110))
- Return Result from TileId::new instead of Option
([#107](#107))
</blockquote>


</p></details>

---
This PR was generated with
[release-plz](https://github.com/release-plz/release-plz/).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants