Files
google-apis-rs/url/struct.Url.html
2021-04-02 00:20:57 +08:00

782 lines
157 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="API documentation for the Rust `Url` struct in crate `url`."><meta name="keywords" content="rust, rustlang, rust-lang, Url"><title>url::Url - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc struct"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../url/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Struct Url</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#implementations">Methods</a><div class="sidebar-links"><a href="#method.as_str">as_str</a><a href="#method.cannot_be_a_base">cannot_be_a_base</a><a href="#method.domain">domain</a><a href="#method.fragment">fragment</a><a href="#method.from_directory_path">from_directory_path</a><a href="#method.from_file_path">from_file_path</a><a href="#method.has_authority">has_authority</a><a href="#method.has_host">has_host</a><a href="#method.host">host</a><a href="#method.host_str">host_str</a><a href="#method.into_string">into_string</a><a href="#method.join">join</a><a href="#method.options">options</a><a href="#method.origin">origin</a><a href="#method.parse">parse</a><a href="#method.parse_with_params">parse_with_params</a><a href="#method.password">password</a><a href="#method.path">path</a><a href="#method.path_segments">path_segments</a><a href="#method.path_segments_mut">path_segments_mut</a><a href="#method.port">port</a><a href="#method.port_or_known_default">port_or_known_default</a><a href="#method.query">query</a><a href="#method.query_pairs">query_pairs</a><a href="#method.query_pairs_mut">query_pairs_mut</a><a href="#method.scheme">scheme</a><a href="#method.set_fragment">set_fragment</a><a href="#method.set_host">set_host</a><a href="#method.set_ip_host">set_ip_host</a><a href="#method.set_password">set_password</a><a href="#method.set_path">set_path</a><a href="#method.set_port">set_port</a><a href="#method.set_query">set_query</a><a href="#method.set_scheme">set_scheme</a><a href="#method.set_username">set_username</a><a href="#method.socket_addrs">socket_addrs</a><a href="#method.to_file_path">to_file_path</a><a href="#method.username">username</a></div><a class="sidebar-title" href="#trait-implementations">Trait Implementations</a><div class="sidebar-links"><a href="#impl-AsRef%3Cstr%3E">AsRef&lt;str&gt;</a><a href="#impl-Clone">Clone</a><a href="#impl-Debug">Debug</a><a href="#impl-Display">Display</a><a href="#impl-Eq">Eq</a><a href="#impl-FromStr">FromStr</a><a href="#impl-Hash">Hash</a><a href="#impl-Index%3CRange%3CPosition%3E%3E">Index&lt;Range&lt;Position&gt;&gt;</a><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E">Index&lt;RangeFrom&lt;Position&gt;&gt;</a><a href="#impl-Index%3CRangeFull%3E">Index&lt;RangeFull&gt;</a><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E">Index&lt;RangeTo&lt;Position&gt;&gt;</a><a href="#impl-Ord">Ord</a><a href="#impl-PartialEq%3CUrl%3E">PartialEq&lt;Url&gt;</a><a href="#impl-PartialOrd%3CUrl%3E">PartialOrd&lt;Url&gt;</a><a href="#impl-TryFrom%3C%26%27a%20str%3E">TryFrom&lt;&amp;&#39;a str&gt;</a></div><a class="sidebar-title" href="#synthetic-implementations">Auto Trait Implementations</a><div class="sidebar-links"><a href="#impl-RefUnwindSafe">RefUnwindSafe</a><a href="#impl-Send">Send</a><a href="#impl-Sync">Sync</a><a href="#impl-Unpin">Unpin</a><a href="#impl-UnwindSafe">UnwindSafe</a></div><a class="sidebar-title" href="#blanket-implementations">Blanket Implementations</a><div class="sidebar-links"><a href="#impl-Any">Any</a><a href="#impl-Borrow%3CT%3E">Borrow&lt;T&gt;</a><a href="#impl-BorrowMut%3CT%3E">BorrowMut&lt;T&gt;</a><a href="#impl-From%3CT%3E">From&lt;T&gt;</a><a href="#impl-Into%3CU%3E">Into&lt;U&gt;</a><a href="#impl-ToOwned">ToOwned</a><a href="#impl-ToString">ToString</a><a href="#impl-TryFrom%3CU%3E">TryFrom&lt;U&gt;</a><a href="#impl-TryInto%3CU%3E">TryInto&lt;U&gt;</a></div></div><p class="location"><a href="index.html">url</a></p><div id="sidebar-vars" data-name="Url" data-ty="struct" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" class="help-button">?</button>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Struct <a href="index.html">url</a>::<wbr><a class="struct" href="">Url</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../src/url/lib.rs.html#166-188" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust struct">pub struct Url { /* fields omitted */ }</pre></div><div class="docblock"><p>A parsed URL record.</p>
</div><h2 id="implementations" class="small-section-header">Implementations<a href="#implementations" class="anchor"></a></h2><h3 id="impl" class="impl"><code class="in-band">impl <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#252-2350" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.parse" class="method"><code>pub fn <a href="#method.parse" class="fnname">parse</a>(input: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#275-277" title="goto source code">[src]</a></h4><div class="docblock"><p>Parse an absolute URL from a string.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net&quot;</span>)<span class="question-mark">?</span>;</pre></div>
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
<p>If the function can not parse an absolute URL from the given string,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div><h4 id="method.parse_with_params" class="method"><code>pub fn <a href="#method.parse_with_params" class="fnname">parse_with_params</a>&lt;I, K, V&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;input: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br>&nbsp;&nbsp;&nbsp;&nbsp;iter: I<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;I: <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;I::<a class="type" href="https://doc.rust-lang.org/nightly/core/iter/traits/collect/trait.IntoIterator.html#associatedtype.Item" title="type core::iter::traits::collect::IntoIterator::Item">Item</a>: <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">(</a>K, V<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.tuple.html">)</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;,&nbsp;</span></code><a class="srclink" href="../src/url/lib.rs.html#305-319" title="goto source code">[src]</a></h4><div class="docblock"><p>Parse an absolute URL from a string and add params to its query string.</p>
<p>Existing params are not removed.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse_with_params</span>(<span class="string">&quot;https://example.net?dont=clobberme&quot;</span>,
<span class="kw-2">&amp;</span>[(<span class="string">&quot;lang&quot;</span>, <span class="string">&quot;rust&quot;</span>), (<span class="string">&quot;browser&quot;</span>, <span class="string">&quot;servo&quot;</span>)])<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">&quot;https://example.net/?dont=clobberme&amp;lang=rust&amp;browser=servo&quot;</span>, <span class="ident">url</span>.<span class="ident">as_str</span>());</pre></div>
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
<p>If the function can not parse an absolute URL from the given string,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div><h4 id="method.join" class="method"><code>pub fn <a href="#method.join" class="fnname">join</a>(&amp;self, input: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#353-355" title="goto source code">[src]</a></h4><div class="docblock"><p>Parse a string as an URL, with this URL as the base URL.</p>
<p>Note: a trailing slash is significant.
Without it, the last path component is considered to be a “file” name
to be removed to get at the “directory” that is used as the base:</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net/a/b.html&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">join</span>(<span class="string">&quot;c.png&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.net/a/c.png&quot;</span>); <span class="comment">// Not /a/b.html/c.png</span>
<span class="kw">let</span> <span class="ident">base</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net/a/b/&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">base</span>.<span class="ident">join</span>(<span class="string">&quot;c.png&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.net/a/b/c.png&quot;</span>);</pre></div>
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
<p>If the function can not parse an URL from the given string
with this URL as the base URL, a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div><h4 id="method.options" class="method"><code>pub fn <a href="#method.options" class="fnname">options</a>&lt;'a&gt;() -&gt; <a class="struct" href="../url/struct.ParseOptions.html" title="struct url::ParseOptions">ParseOptions</a>&lt;'a&gt;</code><a class="srclink" href="../src/url/lib.rs.html#376-382" title="goto source code">[src]</a></h4><div class="docblock"><p>Return a default <code>ParseOptions</code> that can fully configure the URL parser.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<p>Get default <code>ParseOptions</code>, then change base url</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">options</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">options</span>();
<span class="kw">let</span> <span class="ident">api</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://api.example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">base_url</span> <span class="op">=</span> <span class="ident">options</span>.<span class="ident">base_url</span>(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span><span class="ident">api</span>));
<span class="kw">let</span> <span class="ident">version_url</span> <span class="op">=</span> <span class="ident">base_url</span>.<span class="ident">parse</span>(<span class="string">&quot;version.json&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">version_url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://api.example.com/version.json&quot;</span>);</pre></div>
</div><h4 id="method.as_str" class="method"><code>pub fn <a href="#method.as_str" class="fnname">as_str</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/lib.rs.html#403-405" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the serialization of this URL.</p>
<p>This is fast since that serialization is already stored in the <code>Url</code> struct.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url_str</span> <span class="op">=</span> <span class="string">&quot;https://example.net/&quot;</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="ident">url_str</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="ident">url_str</span>);</pre></div>
</div><h4 id="method.into_string" class="method"><code>pub fn <a href="#method.into_string" class="fnname">into_string</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="../src/url/lib.rs.html#426-428" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the serialization of this URL.</p>
<p>This consumes the <code>Url</code> and takes ownership of the <code>String</code> stored in it.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url_str</span> <span class="op">=</span> <span class="string">&quot;https://example.net/&quot;</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="ident">url_str</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">into_string</span>(), <span class="ident">url_str</span>);</pre></div>
</div><h4 id="method.origin" class="method"><code>pub fn <a href="#method.origin" class="fnname">origin</a>(&amp;self) -&gt; <a class="enum" href="../url/enum.Origin.html" title="enum url::Origin">Origin</a></code><a class="srclink" href="../src/url/lib.rs.html#625-627" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the origin of this URL (<a href="https://url.spec.whatwg.org/#origin">https://url.spec.whatwg.org/#origin</a>)</p>
<p>Note: this returns an opaque origin for <code>file:</code> URLs, which causes
<code>url.origin() != url.origin()</code>.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<p>URL with <code>ftp</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://example.com/foo&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">origin</span>(),
<span class="ident">Origin</span>::<span class="ident">Tuple</span>(<span class="string">&quot;ftp&quot;</span>.<span class="ident">into</span>(),
<span class="ident">Host</span>::<span class="ident">Domain</span>(<span class="string">&quot;example.com&quot;</span>.<span class="ident">into</span>()),
<span class="number">21</span>));</pre></div>
<p>URL with <code>blob</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;blob:https://example.com/foo&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">origin</span>(),
<span class="ident">Origin</span>::<span class="ident">Tuple</span>(<span class="string">&quot;https&quot;</span>.<span class="ident">into</span>(),
<span class="ident">Host</span>::<span class="ident">Domain</span>(<span class="string">&quot;example.com&quot;</span>.<span class="ident">into</span>()),
<span class="number">443</span>));</pre></div>
<p>URL with <code>file</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;file:///tmp/foo&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">origin</span>().<span class="ident">is_tuple</span>());
<span class="kw">let</span> <span class="ident">other_url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;file:///tmp/foo&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">origin</span>() <span class="op">!</span><span class="op">=</span> <span class="ident">other_url</span>.<span class="ident">origin</span>());</pre></div>
<p>URL with other scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Host</span>, <span class="ident">Origin</span>, <span class="ident">Url</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo:bar&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">origin</span>().<span class="ident">is_tuple</span>());</pre></div>
</div><h4 id="method.scheme" class="method"><code>pub fn <a href="#method.scheme" class="fnname">scheme</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/lib.rs.html#645-647" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the scheme of this URL, lower-cased, as an ASCII string without the ':' delimiter.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;file:///tmp/foo&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">scheme</span>(), <span class="string">&quot;file&quot;</span>);</pre></div>
</div><h4 id="method.has_authority" class="method"><code>pub fn <a href="#method.has_authority" class="fnname">has_authority</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../src/url/lib.rs.html#675-678" title="goto source code">[src]</a></h4><div class="docblock"><p>Return whether the URL has an 'authority',
which can contain a username, password, host, and port number.</p>
<p>URLs that do <em>not</em> are either path-only like <code>unix:/run/foo.socket</code>
or cannot-be-a-base like <code>data:text/plain,Stuff</code>.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">has_authority</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;unix:/run/foo.socket&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_authority</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,Stuff&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_authority</span>());</pre></div>
</div><h4 id="method.cannot_be_a_base" class="method"><code>pub fn <a href="#method.cannot_be_a_base" class="fnname">cannot_be_a_base</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../src/url/lib.rs.html#706-708" title="goto source code">[src]</a></h4><div class="docblock"><p>Return whether this URL is a cannot-be-a-base URL,
meaning that parsing a relative URL string with this URL as the base will return an error.</p>
<p>This is the case if the scheme and <code>:</code> delimiter are not followed by a <code>/</code> slash,
as is typically the case of <code>data:</code> and <code>mailto:</code> URLs.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;unix:/run/foo.socket&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,Stuff&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">cannot_be_a_base</span>());</pre></div>
</div><h4 id="method.username" class="method"><code>pub fn <a href="#method.username" class="fnname">username</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/lib.rs.html#732-739" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the username for this URL (typically the empty string)
as a percent-encoded ASCII string.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">&quot;rms&quot;</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://:secret123@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">&quot;&quot;</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">&quot;&quot;</span>);</pre></div>
</div><h4 id="method.password" class="method"><code>pub fn <a href="#method.password" class="fnname">password</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#765-777" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the password for this URL, if any, as a percent-encoded ASCII string.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms:secret123@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;secret123&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://:secret123@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;secret123&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">None</span>);</pre></div>
</div><h4 id="method.has_host" class="method"><code>pub fn <a href="#method.has_host" class="fnname">has_host</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../src/url/lib.rs.html#800-802" title="goto source code">[src]</a></h4><div class="docblock"><p>Equivalent to <code>url.host().is_some()</code>.</p>
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">has_host</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;unix:/run/foo.socket&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_host</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,Stuff&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">url</span>.<span class="ident">has_host</span>());</pre></div>
</div><h4 id="method.host_str" class="method"><code>pub fn <a href="#method.host_str" class="fnname">host_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#837-843" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the string representation of the host (domain or IP address) for this URL, if any.</p>
<p>Non-ASCII domains are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.
IPv6 addresses are given between <code>[</code> and <code>]</code> brackets.</p>
<p>Cannot-be-a-base URLs (typical of <code>data:</code> and <code>mailto:</code>) and some <code>file:</code> URLs
dont have a host.</p>
<p>See also the <code>host</code> method.</p>
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://127.0.0.1/index.html&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;127.0.0.1&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;example.com&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;unix:/run/foo.socket&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,Stuff&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">None</span>);</pre></div>
</div><h4 id="method.host" class="method"><code>pub fn <a href="#method.host" class="fnname">host</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="../url/enum.Host.html" title="enum url::Host">Host</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;&gt;</code><a class="srclink" href="../src/url/lib.rs.html#876-883" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the parsed representation of the host for this URL.
Non-ASCII domain labels are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.</p>
<p>Cannot-be-a-base URLs (typical of <code>data:</code> and <code>mailto:</code>) and some <code>file:</code> URLs
dont have a host.</p>
<p>See also the <code>host_str</code> method.</p>
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://127.0.0.1/index.html&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_some</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_some</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;unix:/run/foo.socket&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,Stuff&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host</span>().<span class="ident">is_none</span>());</pre></div>
</div><h4 id="method.domain" class="method"><code>pub fn <a href="#method.domain" class="fnname">domain</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#908-913" title="goto source code">[src]</a></h4><div class="docblock"><p>If this URL has a host and it is a domain name (not an IP address), return it.
Non-ASCII domains are punycode-encoded per IDNA if this is the host
of a special URL, or percent encoded for non-special URLs.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://127.0.0.1/&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rms@example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">domain</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;example.com&quot;</span>));</pre></div>
</div><h4 id="method.port" class="method"><code>pub fn <a href="#method.port" class="fnname">port</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#940-942" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the port number for this URL, if any.</p>
<p>Note that default port numbers are never reflected by the serialization,
use the <code>port_or_known_default()</code> method if you want a default port number returned.</p>
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com:443/&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ssh://example.com:22&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port</span>(), <span class="prelude-val">Some</span>(<span class="number">22</span>));</pre></div>
</div><h4 id="method.port_or_known_default" class="method"><code>pub fn <a href="#method.port_or_known_default" class="fnname">port_or_known_default</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#972-974" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the port number for this URL, or the default port number if it is known.</p>
<p>This method only knows the default port number
of the <code>http</code>, <code>https</code>, <code>ws</code>, <code>wss</code> and <code>ftp</code> schemes.</p>
<p>For URLs in these schemes, this method always returns <code>Some(_)</code>.
For other schemes, it is the same as <code>Url::port()</code>.</p>
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo://example.com:1456&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">Some</span>(<span class="number">1456</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port_or_known_default</span>(), <span class="prelude-val">Some</span>(<span class="number">443</span>));</pre></div>
</div><h4 id="method.socket_addrs" class="method"><code>pub fn <a href="#method.socket_addrs" class="fnname">socket_addrs</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;self, <br>&nbsp;&nbsp;&nbsp;&nbsp;default_port_number: impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>&gt;<br>) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/std/net/addr/enum.SocketAddr.html" title="enum std::net::addr::SocketAddr">SocketAddr</a>&gt;&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1003-1029" title="goto source code">[src]</a></h4><div class="docblock"><p>Resolve a URLs host and port number to <code>SocketAddr</code>.</p>
<p>If the URL has the default port number of a scheme that is unknown to this library,
<code>default_port_number</code> provides an opportunity to provide the actual port number.
In non-example code this should be implemented either simply as <code>|| None</code>,
or by matching on the URLs <code>.scheme()</code>.</p>
<p>If the host is a domain, it is resolved using the standard librarys DNS support.</p>
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">url</span>::<span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net/&quot;</span>).<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">addrs</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">socket_addrs</span>(<span class="op">|</span><span class="op">|</span> <span class="prelude-val">None</span>).<span class="ident">unwrap</span>();
<span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">TcpStream</span>::<span class="ident">connect</span>(<span class="kw-2">&amp;</span><span class="kw-2">*</span><span class="ident">addrs</span>)</pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="doccomment">/// With application-specific known default port numbers</span>
<span class="kw">fn</span> <span class="ident">socket_addrs</span>(<span class="ident">url</span>: <span class="ident">url</span>::<span class="ident">Url</span>) <span class="op">-</span><span class="op">&gt;</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">std</span>::<span class="ident">net</span>::<span class="ident">SocketAddr</span><span class="op">&gt;</span><span class="op">&gt;</span> {
<span class="ident">url</span>.<span class="ident">socket_addrs</span>(<span class="op">|</span><span class="op">|</span> <span class="kw">match</span> <span class="ident">url</span>.<span class="ident">scheme</span>() {
<span class="string">&quot;socks5&quot;</span> <span class="op">|</span> <span class="string">&quot;socks5h&quot;</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">Some</span>(<span class="number">1080</span>),
<span class="kw">_</span> <span class="op">=</span><span class="op">&gt;</span> <span class="prelude-val">None</span>,
})
}</pre></div>
</div><h4 id="method.path" class="method"><code>pub fn <a href="#method.path" class="fnname">path</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/lib.rs.html#1054-1061" title="goto source code">[src]</a></h4><div class="docblock"><p>Return the path for this URL, as a percent-encoded ASCII string.
For cannot-be-a-base URLs, this is an arbitrary string that doesnt start with '/'.
For other URLs, this starts with a '/' slash
and continues with slash-separated path segments.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/api/versions?page=2&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">&quot;/api/versions&quot;</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">&quot;/&quot;</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/countries/việt nam&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">&quot;/countries/vi%E1%BB%87t%20nam&quot;</span>);</pre></div>
</div><h4 id="method.path_segments" class="method"><code>pub fn <a href="#method.path_segments" class="fnname">path_segments</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/str/iter/struct.Split.html" title="struct core::str::iter::Split">Split</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.char.html">char</a>&gt;&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1102-1109" title="goto source code">[src]</a></h4><div class="docblock"><p>Unless this URL is cannot-be-a-base,
return an iterator of '/' slash-separated path segments,
each as a percent-encoded ASCII string.</p>
<p>Return <code>None</code> for cannot-be-a-base URLs.</p>
<p>When <code>Some</code> is returned, the iterator always contains at least one string
(which may be empty).</p>
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/foo/bar&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;foo&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;bar&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">None</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;data:text/plain,HelloWorld&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/countries/việt nam&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">path_segments</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">path_segments</span>().<span class="ident">ok_or_else</span>(<span class="op">|</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;countries&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">path_segments</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;vi%E1%BB%87t%20nam&quot;</span>));</pre></div>
</div><h4 id="method.query" class="method"><code>pub fn <a href="#method.query" class="fnname">query</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1135-1147" title="goto source code">[src]</a></h4><div class="docblock"><p>Return this URLs query string, if any, as a percent-encoded ASCII string.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">fn</span> <span class="ident">run</span>() <span class="op">-</span><span class="op">&gt;</span> <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">ParseError</span><span class="op">&gt;</span> {
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/products?page=2&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">query</span>, <span class="prelude-val">Some</span>(<span class="string">&quot;page=2&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/products&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">query</span>.<span class="ident">is_none</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/?country=español&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">query</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">query</span>, <span class="prelude-val">Some</span>(<span class="string">&quot;country=espa%C3%B1ol&quot;</span>));</pre></div>
</div><h4 id="method.query_pairs" class="method"><code>pub fn <a href="#method.query_pairs" class="fnname">query_pairs</a>(&amp;self) -&gt; <a class="struct" href="../form_urlencoded/struct.Parse.html" title="struct form_urlencoded::Parse">Parse</a>&lt;'_&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1174-1176" title="goto source code">[src]</a></h4><div class="docblock"><p>Parse the URLs query string, if any, as <code>application/x-www-form-urlencoded</code>
and return an iterator of (key, value) pairs.</p>
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">borrow</span>::<span class="ident">Cow</span>;
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/products?page=2&amp;sort=desc&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">pairs</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">query_pairs</span>();
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">pairs</span>.<span class="ident">count</span>(), <span class="number">2</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">pairs</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>((<span class="ident">Cow</span>::<span class="ident">Borrowed</span>(<span class="string">&quot;page&quot;</span>), <span class="ident">Cow</span>::<span class="ident">Borrowed</span>(<span class="string">&quot;2&quot;</span>))));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">pairs</span>.<span class="ident">next</span>(), <span class="prelude-val">Some</span>((<span class="ident">Cow</span>::<span class="ident">Borrowed</span>(<span class="string">&quot;sort&quot;</span>), <span class="ident">Cow</span>::<span class="ident">Borrowed</span>(<span class="string">&quot;desc&quot;</span>))));</pre></div>
</div><h4 id="method.fragment" class="method"><code>pub fn <a href="#method.fragment" class="fnname">fragment</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1210-1215" title="goto source code">[src]</a></h4><div class="docblock"><p>Return this URLs fragment identifier, if any.</p>
<p>A fragment is the part of the URL after the <code>#</code> symbol.
The fragment is optional and, if present, contains a fragment identifier
that identifies a secondary resource, such as a section heading
of a document.</p>
<p>In HTML, the fragment identifier is usually the id attribute of a an element
that is scrolled to on load. Browsers typically will not send the fragment portion
of a URL to the server.</p>
<p><strong>Note:</strong> the parser did <em>not</em> percent-encode this component,
but the input may have been percent-encoded already.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/data.csv#row=4&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;row=4&quot;</span>));
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/data.csv#cell=4,1-6,2&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;cell=4,1-6,2&quot;</span>));</pre></div>
</div><h4 id="method.set_fragment" class="method"><code>pub fn <a href="#method.set_fragment" class="fnname">set_fragment</a>(&amp;mut self, fragment: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;)</code><a class="srclink" href="../src/url/lib.rs.html#1247-1261" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs fragment identifier.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/data.csv&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/data.csv&quot;</span>);
<span class="ident">url</span>.<span class="ident">set_fragment</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;cell=4,1-6,2&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/data.csv#cell=4,1-6,2&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;cell=4,1-6,2&quot;</span>));
<span class="ident">url</span>.<span class="ident">set_fragment</span>(<span class="prelude-val">None</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/data.csv&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">fragment</span>().<span class="ident">is_none</span>());</pre></div>
</div><h4 id="method.set_query" class="method"><code>pub fn <a href="#method.set_query" class="fnname">set_query</a>(&amp;mut self, query: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;)</code><a class="srclink" href="../src/url/lib.rs.html#1300-1325" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs query string.</p>
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/products&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/products&quot;</span>);
<span class="ident">url</span>.<span class="ident">set_query</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;page=2&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/products?page=2&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;page=2&quot;</span>));</pre></div>
</div><h4 id="method.query_pairs_mut" class="method"><code>pub fn <a href="#method.query_pairs_mut" class="fnname">query_pairs_mut</a>(&amp;mut self) -&gt; <a class="struct" href="../form_urlencoded/struct.Serializer.html" title="struct form_urlencoded::Serializer">Serializer</a>&lt;'_, <a class="struct" href="../url/struct.UrlQuery.html" title="struct url::UrlQuery">UrlQuery</a>&lt;'_&gt;&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1359-1377" title="goto source code">[src]</a></h4><div class="docblock"><p>Manipulate this URLs query string, viewed as a sequence of name/value pairs
in <code>application/x-www-form-urlencoded</code> syntax.</p>
<p>The return value has a method-chaining API:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net?lang=fr#nav&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;lang=fr&quot;</span>));
<span class="ident">url</span>.<span class="ident">query_pairs_mut</span>().<span class="ident">append_pair</span>(<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;lang=fr&amp;foo=bar&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.net/?lang=fr&amp;foo=bar#nav&quot;</span>);
<span class="ident">url</span>.<span class="ident">query_pairs_mut</span>()
.<span class="ident">clear</span>()
.<span class="ident">append_pair</span>(<span class="string">&quot;foo&quot;</span>, <span class="string">&quot;bar &amp; baz&quot;</span>)
.<span class="ident">append_pair</span>(<span class="string">&quot;saisons&quot;</span>, <span class="string">&quot;\u{00C9}t\u{00E9}+hiver&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">query</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;foo=bar+%26+baz&amp;saisons=%C3%89t%C3%A9%2Bhiver&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(),
<span class="string">&quot;https://example.net/?foo=bar+%26+baz&amp;saisons=%C3%89t%C3%A9%2Bhiver#nav&quot;</span>);</pre></div>
<p>Note: <code>url.query_pairs_mut().clear();</code> is equivalent to <code>url.set_query(Some(&quot;&quot;))</code>,
not <code>url.set_query(None)</code>.</p>
<p>The state of <code>Url</code> is unspecified if this return value is leaked without being dropped.</p>
</div><h4 id="method.set_path" class="method"><code>pub fn <a href="#method.set_path" class="fnname">set_path</a>(&amp;mut self, path: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>)</code><a class="srclink" href="../src/url/lib.rs.html#1412-1431" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs path.</p>
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_path</span>(<span class="string">&quot;api/comments&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/api/comments&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">&quot;/api/comments&quot;</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.com/api&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_path</span>(<span class="string">&quot;data/report.csv&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.com/data/report.csv&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">path</span>(), <span class="string">&quot;/data/report.csv&quot;</span>);</pre></div>
</div><h4 id="method.path_segments_mut" class="method"><code>pub fn <a href="#method.path_segments_mut" class="fnname">path_segments_mut</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.PathSegmentsMut.html" title="struct url::PathSegmentsMut">PathSegmentsMut</a>&lt;'_&gt;, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1437-1443" title="goto source code">[src]</a></h4><div class="docblock"><p>Return an object with methods to manipulate this URLs path segments.</p>
<p>Return <code>Err(())</code> if this URL is cannot-be-a-base.</p>
</div><h4 id="method.set_port" class="method"><code>pub fn <a href="#method.set_port" class="fnname">set_port</a>(&amp;mut self, port: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1521-1531" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs port number.</p>
<p>Note that default port numbers are not reflected in the serialization.</p>
<p>If this URL is cannot-be-a-base, does not have a host, or has the <code>file</code> scheme;
do nothing and return <code>Err</code>.</p>
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ssh://example.net:2048/&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">4096</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;ssh://example.net:4096/&quot;</span>);
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">None</span>).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;ssh://example.net/&quot;</span>);</pre></div>
<p>Known default port numbers are not reflected:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.org/&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">443</span>)).<span class="ident">map_err</span>(<span class="op">|</span><span class="kw">_</span><span class="op">|</span> <span class="string">&quot;cannot be base&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">port</span>().<span class="ident">is_none</span>());</pre></div>
<p>Cannot set port for cannot-be-a-base URLs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rms@example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">Some</span>(<span class="number">80</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_port</span>(<span class="prelude-val">None</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
</div><h4 id="method.set_host" class="method"><code>pub fn <a href="#method.set_host" class="fnname">set_host</a>(&amp;mut self, host: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1654-1709" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs host.</p>
<p>Removing the host (calling this with <code>None</code>)
will also remove any username, password, and port number.</p>
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
<p>Change host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;rust-lang.org&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://rust-lang.org/&quot;</span>);</pre></div>
<p>Remove host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;foo:/&quot;</span>);</pre></div>
<p>Cannot remove host for 'special' schemes (e.g. <code>http</code>):</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.net/&quot;</span>);</pre></div>
<p>Cannot change or remove host for cannot-be-a-base URLs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rms@example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;rust-lang.org&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;mailto:rms@example.net&quot;</span>);
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_host</span>(<span class="prelude-val">None</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;mailto:rms@example.net&quot;</span>);</pre></div>
<h1 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h1>
<p>If this URL is cannot-be-a-base or there is an error parsing the given <code>host</code>,
a <a href="enum.ParseError.html"><code>ParseError</code></a> variant will be returned.</p>
</div><h4 id="method.set_ip_host" class="method"><code>pub fn <a href="#method.set_ip_host" class="fnname">set_ip_host</a>(&amp;mut self, address: <a class="enum" href="https://doc.rust-lang.org/nightly/std/net/ip/enum.IpAddr.html" title="enum std::net::ip::IpAddr">IpAddr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1792-1803" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs host to the given IP address.</p>
<p>If this URL is cannot-be-a-base, do nothing and return <code>Err</code>.</p>
<p>Compared to <code>Url::set_host</code>, this skips the host parser.</p>
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;http://example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="ident">url</span>.<span class="ident">set_ip_host</span>(<span class="string">&quot;127.0.0.1&quot;</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">host_str</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;127.0.0.1&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;http://127.0.0.1/&quot;</span>);</pre></div>
<p>Cannot change URL's from mailto(cannot-be-base) to ip:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rms@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_ip_host</span>(<span class="string">&quot;127.0.0.1&quot;</span>.<span class="ident">parse</span>().<span class="ident">unwrap</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;mailto:rms@example.com&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
</div><h4 id="method.set_password" class="method"><code>pub fn <a href="#method.set_password" class="fnname">set_password</a>(&amp;mut self, password: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1832-1887" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs password.</p>
<p>If this URL is cannot-be-a-base or does not have a host, do nothing and return <code>Err</code>.</p>
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rmz@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;secret_password&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://user1:secret1@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;secret_password&quot;</span>));
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;secret_password&quot;</span>));
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://user2:@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_password</span>(<span class="prelude-val">Some</span>(<span class="string">&quot;secret2&quot;</span>));
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">password</span>(), <span class="prelude-val">Some</span>(<span class="string">&quot;secret2&quot;</span>));</pre></div>
</div><h4 id="method.set_username" class="method"><code>pub fn <a href="#method.set_username" class="fnname">set_username</a>(&amp;mut self, username: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#1925-1974" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs username.</p>
<p>If this URL is cannot-be-a-base or does not have a host, do nothing and return <code>Err</code>.</p>
<h1 id="examples-31" class="section-header"><a href="#examples-31">Examples</a></h1>
<p>Cannot setup username from mailto(cannot-be-base)</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rmz@example.com&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_username</span>(<span class="string">&quot;user1&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;mailto:rmz@example.com&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
<p>Setup username to user1</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::{<span class="ident">Url</span>, <span class="ident">ParseError</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;ftp://:secre1@example.com/&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_username</span>(<span class="string">&quot;user1&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">username</span>(), <span class="string">&quot;user1&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;ftp://user1:secre1@example.com/&quot;</span>);</pre></div>
</div><h4 id="method.set_scheme" class="method"><code>pub fn <a href="#method.set_scheme" class="fnname">set_scheme</a>(&amp;mut self, scheme: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2087-2136" title="goto source code">[src]</a></h4><div class="docblock"><p>Change this URLs scheme.</p>
<p>Do nothing and return <code>Err</code> under the following circumstances:</p>
<ul>
<li>If the new scheme is not in <code>[a-zA-Z][a-zA-Z0-9+.-]+</code></li>
<li>If this URL is cannot-be-a-base and the new scheme is one of
<code>http</code>, <code>https</code>, <code>ws</code>, <code>wss</code> or <code>ftp</code></li>
<li>If either the old or new scheme is <code>http</code>, <code>https</code>, <code>ws</code>,
<code>wss</code> or <code>ftp</code> and the other is not one of these</li>
<li>If the new scheme is <code>file</code> and this URL includes credentials
or has a non-null port</li>
<li>If this URL's scheme is <code>file</code> and its host is empty or null</li>
</ul>
<p>See also <a href="https://url.spec.whatwg.org/#scheme-state">the URL specification's section on legal scheme state
overrides</a>.</p>
<h1 id="examples-32" class="section-header"><a href="#examples-32">Examples</a></h1>
<p>Change the URLs scheme from <code>https</code> to <code>foo</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;http&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;http://example.net/&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());</pre></div>
<p>Change the URLs scheme from <code>foo</code> to <code>bar</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;bar&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;bar://example.net&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_ok</span>());</pre></div>
<p>Cannot change URLs scheme from <code>https</code> to <code>foõ</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;https://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;foõ&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;https://example.net/&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
<p>Cannot change URLs scheme from <code>mailto</code> (cannot-be-a-base) to <code>https</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;mailto:rms@example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;https&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;mailto:rms@example.net&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
<p>Cannot change the URLs scheme from <code>foo</code> to <code>https</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;foo://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;https&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;foo://example.net&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
<p>Cannot change the URLs scheme from <code>http</code> to <code>foo</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">parse</span>(<span class="string">&quot;http://example.net&quot;</span>)<span class="question-mark">?</span>;
<span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">set_scheme</span>(<span class="string">&quot;foo&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;http://example.net/&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());</pre></div>
</div><h4 id="method.from_file_path" class="method"><code>pub fn <a href="#method.from_file_path" class="fnname">from_file_path</a>&lt;P:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;&gt;(path: P) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2167-2183" title="goto source code">[src]</a></h4><div class="docblock"><p>Convert a file name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
<p>This returns <code>Err</code> if the given path is not absolute or,
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>) or a UNC prefix (<code>\\</code>).</p>
<h1 id="examples-33" class="section-header"><a href="#examples-33">Examples</a></h1>
<p>On Unix-like platforms:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">Url</span>;
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">from_file_path</span>(<span class="string">&quot;/tmp/foo.txt&quot;</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">as_str</span>(), <span class="string">&quot;file:///tmp/foo.txt&quot;</span>);
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">from_file_path</span>(<span class="string">&quot;../foo.txt&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">is_err</span>());
<span class="kw">let</span> <span class="ident">url</span> <span class="op">=</span> <span class="ident">Url</span>::<span class="ident">from_file_path</span>(<span class="string">&quot;https://google.com/&quot;</span>);
<span class="macro">assert</span><span class="macro">!</span>(<span class="ident">url</span>.<span class="ident">is_err</span>());</pre></div>
</div><h4 id="method.from_directory_path" class="method"><code>pub fn <a href="#method.from_directory_path" class="fnname">from_directory_path</a>&lt;P:&nbsp;<a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>&gt;&gt;(path: P) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2204-2210" title="goto source code">[src]</a></h4><div class="docblock"><p>Convert a directory name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
<p>This returns <code>Err</code> if the given path is not absolute or,
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>) or a UNC prefix (<code>\\</code>).</p>
<p>Compared to <code>from_file_path</code>, this ensure that URLs the path has a trailing slash
so that the entire path is considered when using this URL as a base URL.</p>
<p>For example:</p>
<ul>
<li><code>&quot;index.html&quot;</code> parsed with <code>Url::from_directory_path(Path::new(&quot;/var/www&quot;))</code>
as the base URL is <code>file:///var/www/index.html</code></li>
<li><code>&quot;index.html&quot;</code> parsed with <code>Url::from_file_path(Path::new(&quot;/var/www&quot;))</code>
as the base URL is <code>file:///var/index.html</code>, which might not be what was intended.</li>
</ul>
<p>Note that <code>std::path</code> does not consider trailing slashes significant
and usually does not include them (e.g. in <code>Path::parent()</code>).</p>
</div><h4 id="method.to_file_path" class="method"><code>pub fn <a href="#method.to_file_path" class="fnname">to_file_path</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2321-2334" title="goto source code">[src]</a></h4><div class="docblock"><p>Assuming the URL is in the <code>file</code> scheme or similar,
convert its path to an absolute <code>std::path::Path</code>.</p>
<p><strong>Note:</strong> This does not actually check the URLs <code>scheme</code>,
and may give nonsensical results for other schemes.
It is the users responsibility to check the URLs scheme before calling this.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">let</span> <span class="ident">path</span> <span class="op">=</span> <span class="ident">url</span>.<span class="ident">to_file_path</span>();</pre></div>
<p>Returns <code>Err</code> if the host is neither empty nor <code>&quot;localhost&quot;</code> (except on Windows, where
<code>file:</code> URLs may have a non-local host),
or if <code>Path::new_opt()</code> returns <code>None</code>.
(That is, if the percent-decoded path contains a NUL byte or,
for a Windows path, is not UTF-8.)</p>
</div></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><h3 id="impl-AsRef%3Cstr%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-AsRef%3Cstr%3E" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2435-2440" title="goto source code">[src]</a></h3><div class="docblock"><p>Return the serialization of this URL.</p>
</div><div class="impl-items"><h4 id="method.as_ref" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fnname">as_ref</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/lib.rs.html#2437-2439" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-Clone" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Clone" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#165" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.clone" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fnname">clone</a>(&amp;self) -&gt; <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a class="srclink" href="../src/url/lib.rs.html#165" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
</div><h4 id="method.clone_from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fnname">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self)</code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#128" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
</div></div><h3 id="impl-Debug" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Debug" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2379-2394" title="goto source code">[src]</a></h3><div class="docblock"><p>Debug the serialization of this URL.</p>
</div><div class="impl-items"><h4 id="method.fmt" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/url/lib.rs.html#2381-2393" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Display" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Display" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2371-2376" title="goto source code">[src]</a></h3><div class="docblock"><p>Display the serialization of this URL.</p>
</div><div class="impl-items"><h4 id="method.fmt-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></code><a class="srclink" href="../src/url/lib.rs.html#2373-2375" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></div><h3 id="impl-Eq" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Eq" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2397" title="goto source code">[src]</a></h3><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"></div><h3 id="impl-FromStr" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr">FromStr</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-FromStr" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2353-2360" title="goto source code">[src]</a></h3><div class="docblock"><p>Parse a string as an URL, without a base URL or encoding override.</p>
</div><div class="impl-items"><h4 id="associatedtype.Err" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#associatedtype.Err" class="type">Err</a> = <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a></code></h4><div class='docblock'><p>The associated error which can be returned from parsing.</p>
</div><h4 id="method.from_str" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#tymethod.from_str" class="fnname">from_str</a>(input: &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2357-2359" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/nightly/core/str/traits/trait.FromStr.html#tymethod.from_str">Read more</a></p>
</div></div><h3 id="impl-Hash" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Hash" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2424-2432" title="goto source code">[src]</a></h3><div class="docblock"><p>URLs hash like their serialization.</p>
</div><div class="impl-items"><h4 id="method.hash" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash" class="fnname">hash</a>&lt;H&gt;(&amp;self, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>H) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,&nbsp;</span></code><a class="srclink" href="../src/url/lib.rs.html#2426-2431" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Feeds this value into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash">Read more</a></p>
</div><h4 id="method.hash_slice" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice" class="fnname">hash_slice</a>&lt;H&gt;(data: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>H) <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,&nbsp;</span></code><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#184-186" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html" title="Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice">Read more</a></p>
</div></div><h3 id="impl-Index%3CRange%3CPosition%3E%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Index%3CRange%3CPosition%3E%3E" class="anchor"></a><a class="srclink" href="../src/url/slicing.rs.html#33-38" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-3" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="type">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></h4><div class='docblock'><p>The returned type after indexing.</p>
</div><h4 id="method.index-3" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/slicing.rs.html#35-37" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the indexing (<code>container[index]</code>) operation.</p>
</div></div><h3 id="impl-Index%3CRangeFrom%3CPosition%3E%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E" class="anchor"></a><a class="srclink" href="../src/url/slicing.rs.html#19-24" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="type">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></h4><div class='docblock'><p>The returned type after indexing.</p>
</div><h4 id="method.index-1" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/slicing.rs.html#21-23" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the indexing (<code>container[index]</code>) operation.</p>
</div></div><h3 id="impl-Index%3CRangeFull%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFull.html" title="struct core::ops::range::RangeFull">RangeFull</a>&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Index%3CRangeFull%3E" class="anchor"></a><a class="srclink" href="../src/url/slicing.rs.html#12-17" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="type">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></h4><div class='docblock'><p>The returned type after indexing.</p>
</div><h4 id="method.index" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&amp;self, _: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeFull.html" title="struct core::ops::range::RangeFull">RangeFull</a>) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/slicing.rs.html#14-16" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the indexing (<code>container[index]</code>) operation.</p>
</div></div><h3 id="impl-Index%3CRangeTo%3CPosition%3E%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E" class="anchor"></a><a class="srclink" href="../src/url/slicing.rs.html#26-31" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Output-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#associatedtype.Output" class="type">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></h4><div class='docblock'><p>The returned type after indexing.</p>
</div><h4 id="method.index-2" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/ops/index/trait.Index.html#tymethod.index" class="fnname">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/nightly/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a>&lt;<a class="enum" href="../url/enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a class="srclink" href="../src/url/slicing.rs.html#28-30" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the indexing (<code>container[index]</code>) operation.</p>
</div></div><h3 id="impl-Ord" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Ord" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2408-2413" title="goto source code">[src]</a></h3><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><h4 id="method.cmp" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp" class="fnname">cmp</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></code><a class="srclink" href="../src/url/lib.rs.html#2410-2412" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method returns an <a href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
</div><h4 id="method.max" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max" class="fnname">max</a>(self, other: Self) -&gt; Self</code><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#723-725" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.max">Read more</a></p>
</div><h4 id="method.min" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min" class="fnname">min</a>(self, other: Self) -&gt; Self</code><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#743-745" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.min">Read more</a></p>
</div><h4 id="method.clamp" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp" class="fnname">clamp</a>(self, min: Self, max: Self) -&gt; Self</code><span class="since" title="Stable since Rust version 1.50.0">1.50.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#768-770" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#method.clamp">Read more</a></p>
</div></div><h3 id="impl-PartialEq%3CUrl%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-PartialEq%3CUrl%3E" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2400-2405" title="goto source code">[src]</a></h3><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><h4 id="method.eq" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fnname">eq</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><a class="srclink" href="../src/url/lib.rs.html#2402-2404" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
</div><h4 id="method.ne" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fnname">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#213" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests for <code>!=</code>.</p>
</div></div><h3 id="impl-PartialOrd%3CUrl%3E" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>&lt;<a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a>&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-PartialOrd%3CUrl%3E" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2416-2421" title="goto source code">[src]</a></h3><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><h4 id="method.partial_cmp" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fnname">partial_cmp</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2418-2420" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
</div><h4 id="method.lt" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt" class="fnname">lt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#963" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
</div><h4 id="method.le" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le" class="fnname">le</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#982" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&lt;=</code>
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
</div><h4 id="method.gt" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt" class="fnname">gt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1000" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
</div><h4 id="method.ge" class="method hidden"><code><span class="docblock attributes">#[must_use]</span>pub fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge" class="fnname">ge</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>Rhs) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#1019" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>&gt;=</code>
operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
</div></div><h3 id="impl-TryFrom%3C%26%27a%20str%3E" class="impl"><code class="in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>&gt; for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-TryFrom%3C%26%27a%20str%3E" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#2362-2368" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="../url/enum.ParseError.html" title="enum url::ParseError">ParseError</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_from" class="method hidden"><code>fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(s: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, Self::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="../src/url/lib.rs.html#2365-2367" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div><h2 id="synthetic-implementations" class="small-section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor"></a></h2><div id="synthetic-implementations-list"><h3 id="impl-RefUnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.RefUnwindSafe.html" title="trait std::panic::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-RefUnwindSafe" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Send" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Send" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Sync" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Sync" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-Unpin" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-Unpin" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div><h3 id="impl-UnwindSafe" class="impl"><code class="in-band">impl <a class="trait" href="https://doc.rust-lang.org/nightly/std/panic/trait.UnwindSafe.html" title="trait std::panic::UnwindSafe">UnwindSafe</a> for <a class="struct" href="../url/struct.Url.html" title="struct url::Url">Url</a></code><a href="#impl-UnwindSafe" class="anchor"></a><a class="srclink" href="../src/url/lib.rs.html#1" title="goto source code">[src]</a></h3><div class="impl-items"></div></div><h2 id="blanket-implementations" class="small-section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor"></a></h2><div id="blanket-implementations-list"><h3 id="impl-Any" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Any" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#131-135" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.type_id" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fnname">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#132" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></p>
</div></div><h3 id="impl-Borrow%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-Borrow%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#207-211" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fnname">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;</a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></p>
</div></div><h3 id="impl-BorrowMut%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-BorrowMut%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#214-218" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.borrow_mut" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fnname">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#215" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></p>
</div></div><h3 id="impl-From%3CT%3E" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</code><a href="#impl-From%3CT%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#545-549" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.from" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fnname">from</a>(t: T) -&gt; T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#546" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-Into%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-Into%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#534-541" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fnname">into</a>(self) -&gt; U</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#538" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-ToOwned" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,&nbsp;</span></code><a href="#impl-ToOwned" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#80-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="type">Owned</a> = T</code></h4><div class='docblock'><p>The resulting type after obtaining ownership.</p>
</div><h4 id="method.to_owned" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fnname">to_owned</a>(&amp;self) -&gt; T</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#85" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></p>
</div><h4 id="method.clone_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fnname">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&amp;mut </a>T)</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#89" title="goto source code">[src]</a></h4><div class="item-info hidden"><div class="stab unstable"><details><summary><span class="emoji">🔬</span> This is a nightly-only experimental API. (<code>toowned_clone_into</code>)</summary><p>recently added</p>
</details></div></div><div class='docblock hidden'><p>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></p>
</div></div><h3 id="impl-ToString" class="impl"><code class="in-band">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,&nbsp;</span></code><a href="#impl-ToString" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2203-2216" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.to_string" class="method hidden"><code>pub default fn <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string" class="fnname">to_string</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/alloc/string.rs.html#2209" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/nightly/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></p>
</div></div><h3 id="impl-TryFrom%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryFrom%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#582-591" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-1" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="type">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_from-1" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fnname">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#588" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div><h3 id="impl-TryInto%3CU%3E" class="impl"><code class="in-band">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,&nbsp;</span></code><a href="#impl-TryInto%3CU%3E" class="anchor"></a><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#568-577" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Error-2" class="type"><code>type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="type">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></code></h4><div class='docblock'><p>The type returned in the event of a conversion error.</p>
</div><h4 id="method.try_into" class="method hidden"><code>pub fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fnname">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="type" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</code><a class="srclink" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#574" title="goto source code">[src]</a></h4><div class='docblock hidden'><p>Performs the conversion.</p>
</div></div></div></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="url"></div>
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>