-
Notifications
You must be signed in to change notification settings - Fork 319
Introduce a Uri Builder #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Maybe it makes sense to have 4 distinct builders, one for each form? (Though the asterisk form doesn't really need one). |
src/uri/mod.rs
Outdated
@@ -289,6 +296,11 @@ impl Uri { | |||
parse_full(s) | |||
} | |||
|
|||
/// dox | |||
pub fn into_builder(self) -> Builder { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe leave this fn off for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lgtm. Just needs docs
@@ -22,6 +22,22 @@ pub trait HttpTryFrom<T>: Sized + Sealed { | |||
fn try_from(t: T) -> Result<Self, Self::Error>; | |||
} | |||
|
|||
pub(crate) trait HttpTryInto<T>: Sized { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this added for internal convenience or does it impact the public api somehow.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, it was internal convenience, allowing arg.http_try_into()
instead of <T as HttpTryFrom<U>>::try_from(arg)
. Since the trait isn't public, and no one can import it, it exposes no public contract.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good to me.
Yeah, just needs docs + it looks like CI is busted for some reason. |
950cdc0
to
5d99fa3
Compare
@carllerche took a while, but I finally cleaned this up. |
5d99fa3
to
a64bd79
Compare
a64bd79
to
6a5c407
Compare
This introduces a
Builder
type for manipulating and building upUri
s. Instead of having mutators onUri
directly, which would need to return errors, instead this suggests that a user either use aBuilder
from the start, or to convert aUri
into viauri.into_builder()
.An example looks like:
It currently only supports setting the 3 distinct parts, not any sub parts (like host or path), but I expect those could be added. This is however generic over
HttpTryFrom
, so you can easily build pieces with&str
, orBytes
, etc.It's only a start, but related to #206.