pub struct Builder { /* private fields */ }Expand description
URL builder.
Components are given literally (host, user info, query pairs) or
percent-encoded (path, query, fragment) and are normalized by
Builder::build. A builder created from a Url modifies that URL.
use urly::Url;
let url = Url::builder()
.scheme("https")
.userinfo("user", Some("p@ss"))
.host("example.com")
.port(8443)
.path("/search")
.query_pair("q", "a b")
.fragment("top")
.build()
.unwrap();
assert_eq!(url, "https://user:p%[email protected]:8443/search?q=a+b#top");
let url = urly::Builder::from(url).port(443).fragment("").build().unwrap();
assert_eq!(url, "https://user:p%[email protected]:443/search?q=a+b#");Implementations§
Source§impl Builder
impl Builder
Sets the raw authority: [userinfo "@"] host [":" port].
Host, user info and port set separately are applied afterwards.
Sourcepub fn host(self, host: &str) -> Self
pub fn host(self, host: &str) -> Self
Sets the literal host, see Url::set_host.
Sourcepub fn userinfo(self, username: &str, password: Option<&str>) -> Self
pub fn userinfo(self, username: &str, password: Option<&str>) -> Self
Sets the literal user name and password.
Sourcepub fn query_pair(self, key: &str, value: &str) -> Self
pub fn query_pair(self, key: &str, value: &str) -> Self
Appends a literal key-value pair to the query.
Sourcepub fn query_pairs<I, K, V>(self, pairs: I) -> Self
pub fn query_pairs<I, K, V>(self, pairs: I) -> Self
Appends literal key-value pairs to the query.
Sourcepub fn build(self) -> Result<Url, InvalidUrl>
pub fn build(self) -> Result<Url, InvalidUrl>
Builds the URL.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Builder
impl RefUnwindSafe for Builder
impl Send for Builder
impl Sync for Builder
impl Unpin for Builder
impl UnsafeUnpin for Builder
impl UnwindSafe for Builder
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more