Skip to content

feat(templated_uri)!: API review and overall cleanup#391

Merged
martintmk merged 53 commits intomainfrom
u/mtomka/tempalted-uri-review
Apr 29, 2026
Merged

feat(templated_uri)!: API review and overall cleanup#391
martintmk merged 53 commits intomainfrom
u/mtomka/tempalted-uri-review

Conversation

@martintmk
Copy link
Copy Markdown
Member

@martintmk martintmk commented Apr 23, 2026

Broad API refinement of the templated_uri crate. Many breaking changes — review call sites against the updated surface.

⚠️ Breaking changes

  • Type renames — dropped the Uri prefix throughout:
    • UriPathPathAndQuery
    • UriTemplatePathAndQueryTemplate
    • UriSafe*Escaped*
    • UriParamEscape, UriUnsafeParamRaw
    • ValidationErrorUriError
    • Uri::to_http_path()Uri::to_path_and_query()
  • Origin / BaseUri now accept any URI scheme (not just HTTP/HTTPS).
    • Origin::port() returns Option<u16>.
    • Origin::try_from_parts replaced by infallible Origin::from_parts.
  • PathAndQuery redaction — now mirrors Uri: implements RedactedDisplay / RedactedDebug, and to_string() returns Sensitive<String>.
  • PathAndQueryTemplate trait refined — added render(); removed Display, to_uri_string(), into_uri(); swapped meanings of template() and
    format_template().
  • Re-exports — removed the http re-export module. Authority and Scheme are now re-exported at the crate root; Parts is no longer re-exported. Use
    http::uri::PathAndQuery directly when needed.

📚 Documentation

  • New _documentation::recipes module with usage recipes.
  • Polished examples (uri_templating, classified_templating) and README.

✅ Tests

  • Added coverage for renamed and new APIs; updated UI/compile-fail tests.

Copilot AI review requested due to automatic review settings April 23, 2026 13:34
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 23, 2026

⚠️ Breaking Changes Detected


--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_missing.ron

Failed in:
  struct http_extensions::UrlTemplateLabel, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/http_extensions/src/url_template_label.rs:27

--- failure trait_method_missing: pub trait method removed or renamed ---

Description:
A trait method is no longer callable, and may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#major-any-change-to-trait-item-signatures
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/trait_method_missing.ron

Failed in:
  method url_template_label of trait ExtensionsExt, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/http_extensions/src/extensions/extensions_ext.rs:19
  method url_template_label of trait RequestExt, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/http_extensions/src/extensions/request_ext.rs:22


--- failure enum_missing: pub enum removed or renamed ---

Description:
A publicly-visible enum cannot be imported by its prior path. A `pub use` may have been removed, or the enum itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/enum_missing.ron

Failed in:
  enum templated_uri::uri::TargetPathAndQuery, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:267

--- failure inherent_method_missing: pub method removed or renamed ---

Description:
A publicly-visible method or associated fn is no longer available under its prior name. It may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/inherent_method_missing.ron

Failed in:
  BaseUri::new, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/base_uri.rs:166
  BaseUri::from_uri_static, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/base_uri.rs:262
  BaseUri::from_uri_str, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/base_uri.rs:313
  BaseUri::from_http_uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/base_uri.rs:367
  Uri::with_base_and_path, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:80
  Uri::path_and_query, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:86
  Uri::base_uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:96
  Uri::target_path_and_query, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:114
  Uri::to_http_uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:137
  Uri::into_http_uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:146
  Origin::new, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/base_uri/origin.rs:37

--- failure method_parameter_count_changed: pub method parameter count changed ---

Description:
A publicly-visible method now takes a different number of parameters, not counting the receiver (self) parameter.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#fn-change-arity
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/method_parameter_count_changed.ron

Failed in:
  templated_uri::BaseUri::from_parts now takes 2 parameters instead of 4, in /home/runner/work/oxidizer/oxidizer/crates/templated_uri/src/base_uri.rs:150

--- failure method_requires_different_generic_type_params: method now requires a different number of generic type parameters ---

Description:
A method now requires a different number of generic type parameters than it used to. Uses of this method that supplied the previous number of generic types will be broken.
        ref: https://doc.rust-lang.org/reference/items/generics.html
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/method_requires_different_generic_type_params.ron

Failed in:
  templated_uri::BaseUri::with_path takes 0 generic types instead of 1, in /home/runner/work/oxidizer/oxidizer/crates/templated_uri/src/base_uri.rs:103

--- failure module_missing: pub module removed or renamed ---

Description:
A publicly-visible module cannot be imported by its prior path. A `pub use` may have been removed, or the module may have been renamed, removed, or made non-public.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/module_missing.ron

Failed in:
  mod templated_uri::uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:4

--- failure pub_module_level_const_missing: pub module-level const is missing ---

Description:
A public const is missing or renamed
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/pub_module_level_const_missing.ron

Failed in:
  DATA_CLASS_UNKNOWN_URI in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:20
  DATA_CLASS_UNKNOWN_URI in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:20

--- failure struct_missing: pub struct removed or renamed ---

Description:
A publicly-visible struct cannot be imported by its prior path. A `pub use` may have been removed, or the struct itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/struct_missing.ron

Failed in:
  struct templated_uri::UriSafeError, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri_safe.rs:79
  struct templated_uri::uri::Uri, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri.rs:51
  struct templated_uri::ValidationError, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/error.rs:22
  struct templated_uri::UriSafe, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri_safe.rs:25

--- failure trait_missing: pub trait removed or renamed ---

Description:
A publicly-visible trait cannot be imported by its prior path. A `pub use` may have been removed, or the trait itself may have been renamed or removed entirely.
        ref: https://doc.rust-lang.org/cargo/reference/semver.html#item-remove
       impl: https://github.com/obi1kenobi/cargo-semver-checks/tree/v0.46.0/src/lints/trait_missing.ron

Failed in:
  trait templated_uri::UriParam, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri_param.rs:15
  trait templated_uri::UriUnsafeParam, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/uri_param.rs:21
  trait templated_uri::TemplatedPathAndQuery, previously in file /home/runner/work/oxidizer/oxidizer/target/semver-checks/git-origin_main/4a45f6b96c19e80d457007a34181c95312ae0789/crates/templated_uri/src/templated.rs:85

If the breaking changes are intentional then everything is fine - this message is merely informative.

Remember to apply a version number bump with the correct severity when publishing a version with breaking changes (1.x.x -> 2.x.x or 0.1.x -> 0.2.x).

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 23, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 100.0%. Comparing base (b71990b) to head (03bd362).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff            @@
##             main     #391    +/-   ##
========================================
  Coverage   100.0%   100.0%            
========================================
  Files         224      225     +1     
  Lines       16187    16350   +163     
========================================
+ Hits        16187    16350   +163     

☔ 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.

Copy link
Copy Markdown
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 performs a breaking API cleanup of the templated_uri crate (and its proc-macro implementation) and updates downstream http_extensions integration to match the renamed types and new construction/conversion patterns.

Changes:

  • Rename core templating and path types (TemplatedPathAndQueryUriTemplate, TargetPathAndQueryUriPath) and unify URI errors (ValidationErrorUriError).
  • Introduce UriPath as the path/query wrapper and add templated_uri::http re-exports for http::uri types used in the public API.
  • Update http_extensions request extensions and template label plumbing (UrlTemplateLabelUriTemplateLabel, RequestExt::path_and_query()RequestExt::path()).

Reviewed changes

Copilot reviewed 29 out of 29 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
crates/templated_uri_macros_impl/src/struct_template.rs Update generated impls/From conversions to the new UriTemplate + UriPath APIs.
crates/templated_uri_macros_impl/src/lib.rs Refresh macro expansion tests to match renamed traits/types and new conversion methods.
crates/templated_uri_macros_impl/src/enum_template.rs Update enum template codegen to delegate via UriTemplate / to_http_path and convert into UriPath.
crates/templated_uri/tests/templated_uri.rs Adjust integration tests for Uri::with_base/with_path, UriPath, and new data class constant location.
crates/templated_uri/src/uri_safe.rs Refactor encoding/validation helpers (move logic into inner fns) and update docs for from_static behavior.
crates/templated_uri/src/uri_path.rs Add new UriPath type (static vs templated) with redaction-aware formatting and conversions.
crates/templated_uri/src/uri_param.rs Minor cleanup in trait module formatting.
crates/templated_uri/src/uri.rs Rework Uri to store UriPath, rename builder-style setters, add from_static, and switch conversions/errors to UriError.
crates/templated_uri/src/templated.rs Rename and reshape the core templating trait to UriTemplate and update into_uri conversion.
crates/templated_uri/src/origin.rs Rename constructors (newfrom_parts), add from_static, and migrate to UriError.
crates/templated_uri/src/macros.rs Update macro documentation to reference new names (UriTemplate, UriPath).
crates/templated_uri/src/lib.rs Restructure module exports: root re-exports, add templated_uri::http module, and make uri module private.
crates/templated_uri/src/error.rs Rename error type to UriError and update tests/labels accordingly.
crates/templated_uri/src/base_uri.rs Replace parsing/constructors with from_static, from_parts, from_host_and_port, and migrate to UriError.
crates/templated_uri/src/base_path.rs Add BasePath::from_static, adjust join helper signature, and migrate to UriError.
crates/templated_uri/examples/uri_templating.rs Update example to use with_base / with_path and BaseUri::from_static.
crates/templated_uri/examples/classified_templating.rs Update example to use with_base / with_path and BaseUri::from_static.
crates/templated_uri/README.md Regenerate docs/examples to match new public API and link targets.
crates/templated_uri/CHANGELOG.md Add an Unreleased breaking-change entry documenting the API rename sweep.
crates/http_extensions/src/uri_template_label.rs Rename UrlTemplateLabelUriTemplateLabel and update docs/tests.
crates/http_extensions/src/lib.rs Switch exports/modules to uri_template_label.
crates/http_extensions/src/http_request_builder.rs Insert UriPath into request extensions and convert templated_uri::Uri via TryFrom into http::Uri.
crates/http_extensions/src/extensions/request_ext.rs Rename request extension accessors to path() / uri_template_label() and update fallback behavior.
crates/http_extensions/src/extensions/extensions_ext.rs Rename extensions accessor to uri_template_label() and update UriPath usage.
crates/http_extensions/src/error.rs Update conversions/docs from templated_uri::ValidationError to templated_uri::UriError.
crates/http_extensions/src/_documentation/recipes.rs Qualify http import in docs to avoid name ambiguity.
crates/http_extensions/Cargo.toml Update allowed-external-types list to reflect templated_uri API surface changes.
crates/http_extensions/CHANGELOG.md Document breaking renames in http_extensions public API.
.spelling Add “infallible” to the spelling allowlist.

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

Comment thread crates/templated_uri/src/uri_path.rs Outdated
Comment thread crates/http_extensions/Cargo.toml
Comment thread crates/templated_uri/src/uri.rs Outdated
martintmk and others added 2 commits April 23, 2026 15:48
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings April 23, 2026 14:22
martintmk and others added 2 commits April 23, 2026 16:22
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Comment thread crates/templated_uri/src/escaped.rs
Copy link
Copy Markdown
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

Copilot reviewed 29 out of 29 changed files in this pull request and generated 11 comments.

Comments suppressed due to low confidence (2)

crates/templated_uri/src/base_path.rs:9

  • Because the crate now has a root http module, use http::uri::PathAndQuery; will resolve to crate::http instead of the external http dependency, and uri won’t be found. Prefer use ::http::uri::PathAndQuery; (or use crate::http::PathAndQuery;).
    crates/templated_uri/src/origin.rs:8
  • This import will break once templated_uri::http is introduced at the crate root: http::uri::{...} will resolve to crate::http not the external crate. Switch to ::http::uri::{Authority, Scheme} (or crate::http::{Authority, Scheme}) to avoid the collision.

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

Comment thread crates/templated_uri/src/path.rs Outdated
Comment thread crates/http_extensions/src/extensions/request_ext.rs Outdated
Comment thread crates/http_extensions/src/extensions/extensions_ext.rs Outdated
Comment thread crates/templated_uri/src/uri.rs Outdated
Comment thread crates/templated_uri/src/error.rs
Comment thread crates/templated_uri/src/path_and_query_template.rs
Comment thread crates/http_extensions/Cargo.toml
Comment thread crates/templated_uri/src/uri.rs
Comment thread crates/templated_uri/src/uri.rs Outdated
Comment thread crates/templated_uri/src/base_uri.rs
Comment thread crates/templated_uri/src/escape.rs Outdated
Comment thread crates/templated_uri/src/origin.rs Outdated
Comment thread crates/templated_uri/src/origin.rs
Comment thread crates/templated_uri/src/path_and_query.rs Outdated
Copilot AI review requested due to automatic review settings April 27, 2026 07:39
Copy link
Copy Markdown
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

Copilot reviewed 40 out of 40 changed files in this pull request and generated 3 comments.


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

Comment thread crates/http_extensions/src/extensions/extensions_ext.rs Outdated
Comment thread crates/http_extensions/src/extensions/request_ext.rs Outdated
Comment thread crates/http_extensions/src/extensions/request_ext.rs
Copilot AI review requested due to automatic review settings April 27, 2026 08:41
Copy link
Copy Markdown
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

Copilot reviewed 40 out of 40 changed files in this pull request and generated 3 comments.


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

Comment thread crates/templated_uri/README.md
Comment thread crates/templated_uri/src/origin.rs
Comment thread crates/templated_uri/src/path_and_query.rs
Copilot AI review requested due to automatic review settings April 27, 2026 09:01
Copy link
Copy Markdown
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

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.


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

Comment thread crates/templated_uri/src/escape.rs
Copilot AI review requested due to automatic review settings April 28, 2026 14:32
Copy link
Copy Markdown
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

Copilot reviewed 41 out of 41 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

crates/templated_uri/src/path_and_query_template.rs:28

  • The docs say all template values must implement Escape except {+foo}, but the generated code still requires {+foo} fields to implement Raw (and will call Raw::raw). Update this section to mention Raw explicitly so users know what trait is required for reserved expansions.

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

Comment thread crates/templated_uri/src/uri.rs
@martintmk martintmk merged commit 4081451 into main Apr 29, 2026
32 checks passed
@martintmk martintmk deleted the u/mtomka/tempalted-uri-review branch April 29, 2026 08:18
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.

4 participants