feat(templated_uri)!: API review and overall cleanup#391
Conversation
|
Codecov Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
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 (
TemplatedPathAndQuery→UriTemplate,TargetPathAndQuery→UriPath) and unify URI errors (ValidationError→UriError). - Introduce
UriPathas the path/query wrapper and addtemplated_uri::httpre-exports forhttp::uritypes used in the public API. - Update
http_extensionsrequest extensions and template label plumbing (UrlTemplateLabel→UriTemplateLabel,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 (new → from_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 UrlTemplateLabel → UriTemplateLabel 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.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
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
httpmodule,use http::uri::PathAndQuery;will resolve tocrate::httpinstead of the externalhttpdependency, anduriwon’t be found. Preferuse ::http::uri::PathAndQuery;(oruse crate::http::PathAndQuery;).
crates/templated_uri/src/origin.rs:8 - This import will break once
templated_uri::httpis introduced at the crate root:http::uri::{...}will resolve tocrate::httpnot the external crate. Switch to::http::uri::{Authority, Scheme}(orcrate::http::{Authority, Scheme}) to avoid the collision.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
Escapeexcept{+foo}, but the generated code still requires{+foo}fields to implementRaw(and will callRaw::raw). Update this section to mentionRawexplicitly so users know what trait is required for reserved expansions.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Broad API refinement of the
templated_uricrate. Many breaking changes — review call sites against the updated surface.Uriprefix throughout:UriPath→PathAndQueryUriTemplate→PathAndQueryTemplateUriSafe*→Escaped*UriParam→Escape,UriUnsafeParam→RawValidationError→UriErrorUri::to_http_path()→Uri::to_path_and_query()Origin/BaseUrinow accept any URI scheme (not just HTTP/HTTPS).Origin::port()returnsOption<u16>.Origin::try_from_partsreplaced by infallibleOrigin::from_parts.PathAndQueryredaction — now mirrorsUri: implementsRedactedDisplay/RedactedDebug, andto_string()returnsSensitive<String>.PathAndQueryTemplatetrait refined — addedrender(); removedDisplay,to_uri_string(),into_uri(); swapped meanings oftemplate()andformat_template().httpre-export module.AuthorityandSchemeare now re-exported at the crate root;Partsis no longer re-exported. Usehttp::uri::PathAndQuerydirectly when needed.📚 Documentation
_documentation::recipesmodule with usage recipes.uri_templating,classified_templating) and README.✅ Tests