refactor parse_url: replace builder_opts! with a builder trait#678
Draft
Kinrany wants to merge 1 commit intoapache:mainfrom
Draft
refactor parse_url: replace builder_opts! with a builder trait#678Kinrany wants to merge 1 commit intoapache:mainfrom
parse_url: replace builder_opts! with a builder trait#678Kinrany wants to merge 1 commit intoapache:mainfrom
Conversation
Kinrany
commented
Mar 24, 2026
Comment on lines
-218
to
+207
| let url = &url[..url::Position::BeforePath]; | ||
| builder_opts!(crate::http::HttpBuilder, url, _options) | ||
| let url: Url = url[..url::Position::BeforePath] | ||
| .parse() | ||
| .expect("URL with empty path and no query or fragment must still be a valid URL"); | ||
| crate::http::HttpBuilder::build_from_url_and_options(&url, _options)? |
Contributor
Author
There was a problem hiding this comment.
Hopefully I'm not crazy and the logic here is valid.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Which issue does this PR close?
Purely internal, probably not worth being included in the logs?
Rationale for this change
I'd like to be able to represent object store locations as URLs (with bidirectional conversions), so I was reading the
parse_urlimplementation.I noticed that the
builder_opts!macro only exists because of the need to be generic over the builder types. So I replaced it with a trait that can create a builder from a URL and options.What changes are included in this PR?
New private trait
FromUrlBuilderwith provided methodbuild_from_url_and_options.It can be implemented for any builder that:
crate::Result<Box<dyn ObjectStore>>Implemented for AWS, GCP, Azure, HTTP.
Are there any user-facing changes?
No user-facing changes whatsoever.
It might make sense to include the trait in the public API in the future. Not sure.
I named it
FromUrlBuilderto limit scope, but I can see it being used more generally since a lot of the builder code is so similar.