edlang/url/struct.Url.html
2024-07-26 09:42:18 +00:00

800 lines
148 KiB
HTML
Raw Permalink 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="A parsed URL record."><title>Url in url - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="url" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../url/index.html">url</a><span class="version">2.5.2</span></h2></div><h2 class="location"><a href="#">Url</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.as_str">as_str</a></li><li><a href="#method.authority">authority</a></li><li><a href="#method.cannot_be_a_base">cannot_be_a_base</a></li><li><a href="#method.domain">domain</a></li><li><a href="#method.fragment">fragment</a></li><li><a href="#method.from_directory_path">from_directory_path</a></li><li><a href="#method.from_file_path">from_file_path</a></li><li><a href="#method.has_authority">has_authority</a></li><li><a href="#method.has_host">has_host</a></li><li><a href="#method.host">host</a></li><li><a href="#method.host_str">host_str</a></li><li><a href="#method.into_string">into_string</a></li><li><a href="#method.is_special">is_special</a></li><li><a href="#method.join">join</a></li><li><a href="#method.make_relative">make_relative</a></li><li><a href="#method.options">options</a></li><li><a href="#method.origin">origin</a></li><li><a href="#method.parse">parse</a></li><li><a href="#method.parse_with_params">parse_with_params</a></li><li><a href="#method.password">password</a></li><li><a href="#method.path">path</a></li><li><a href="#method.path_segments">path_segments</a></li><li><a href="#method.path_segments_mut">path_segments_mut</a></li><li><a href="#method.port">port</a></li><li><a href="#method.port_or_known_default">port_or_known_default</a></li><li><a href="#method.query">query</a></li><li><a href="#method.query_pairs">query_pairs</a></li><li><a href="#method.query_pairs_mut">query_pairs_mut</a></li><li><a href="#method.scheme">scheme</a></li><li><a href="#method.set_fragment">set_fragment</a></li><li><a href="#method.set_host">set_host</a></li><li><a href="#method.set_ip_host">set_ip_host</a></li><li><a href="#method.set_password">set_password</a></li><li><a href="#method.set_path">set_path</a></li><li><a href="#method.set_port">set_port</a></li><li><a href="#method.set_query">set_query</a></li><li><a href="#method.set_scheme">set_scheme</a></li><li><a href="#method.set_username">set_username</a></li><li><a href="#method.socket_addrs">socket_addrs</a></li><li><a href="#method.to_file_path">to_file_path</a></li><li><a href="#method.username">username</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsRef%3Cstr%3E-for-Url">AsRef&lt;str&gt;</a></li><li><a href="#impl-Clone-for-Url">Clone</a></li><li><a href="#impl-Debug-for-Url">Debug</a></li><li><a href="#impl-Display-for-Url">Display</a></li><li><a href="#impl-Eq-for-Url">Eq</a></li><li><a href="#impl-From%3CUrl%3E-for-String">From&lt;Url&gt;</a></li><li><a href="#impl-FromStr-for-Url">FromStr</a></li><li><a href="#impl-Hash-for-Url">Hash</a></li><li><a href="#impl-Index%3CRange%3CPosition%3E%3E-for-Url">Index&lt;Range&lt;Position&gt;&gt;</a></li><li><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E-for-Url">Index&lt;RangeFrom&lt;Position&gt;&gt;</a></li><li><a href="#impl-Index%3CRangeFull%3E-for-Url">Index&lt;RangeFull&gt;</a></li><li><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E-for-Url">Index&lt;RangeTo&lt;Position&gt;&gt;</a></li><li><a href="#impl-Ord-for-Url">Ord</a></li><li><a href="#impl-PartialEq-for-Url">PartialEq</a></li><li><a href="#impl-PartialOrd-for-Url">PartialOrd</a></li><li><a href="#impl-TryFrom%3C%26str%3E-for-Url">TryFrom&lt;&amp;&#x27;a str&gt;</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Url">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Url">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Url">Send</a></li><li><a href="#impl-Sync-for-Url">Sync</a></li><li><a href="#impl-Unpin-for-Url">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Url">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow&lt;T&gt;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut&lt;T&gt;</a></li><li><a href="#impl-From%3CT%3E-for-T">From&lt;T&gt;</a></li><li><a href="#impl-Into%3CU%3E-for-T">Into&lt;U&gt;</a></li><li><a href="#impl-ToOwned-for-T">ToOwned</a></li><li><a href="#impl-ToString-for-T">ToString</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom&lt;U&gt;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto&lt;U&gt;</a></li></ul></section><h2><a href="index.html">In crate url</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">url</a>::<wbr><a class="struct" href="#">Url</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/url/lib.rs.html#187-209">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub struct Url { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A parsed URL record.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#277-2654">source</a><a href="#impl-Url" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.parse" class="method"><a class="src rightside" href="../src/url/lib.rs.html#300-302">source</a><h4 class="code-header">pub fn <a href="#method.parse" class="fn">parse</a>(input: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</h4></section></summary><div class="docblock"><p>Parse an absolute URL from a string.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;</code></pre></div>
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
<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></details><details class="toggle method-toggle" open><summary><section id="method.parse_with_params" class="method"><a class="src rightside" href="../src/url/lib.rs.html#330-344">source</a><h4 class="code-header">pub fn <a href="#method.parse_with_params" class="fn">parse_with_params</a>&lt;I, K, V&gt;(
input: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>,
iter: I,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;<div class="where">where
I: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/iter/traits/collect/trait.IntoIterator.html" title="trait core::iter::traits::collect::IntoIterator">IntoIterator</a>,
I::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.tuple.html">(K, V)</a>&gt;,
K: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;,
V: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;,</div></h4></section></summary><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>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse_with_params(<span class="string">"https://example.net?dont=clobberme"</span>,
<span class="kw-2">&amp;</span>[(<span class="string">"lang"</span>, <span class="string">"rust"</span>), (<span class="string">"browser"</span>, <span class="string">"servo"</span>)])<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(<span class="string">"https://example.net/?dont=clobberme&amp;lang=rust&amp;browser=servo"</span>, url.as_str());</code></pre></div>
<h5 id="errors-1"><a class="doc-anchor" href="#errors-1">§</a>Errors</h5>
<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></details><details class="toggle method-toggle" open><summary><section id="method.join" class="method"><a class="src rightside" href="../src/url/lib.rs.html#425-427">source</a><h4 class="code-header">pub fn <a href="#method.join" class="fn">join</a>(&amp;self, input: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</h4></section></summary><div class="docblock"><p>Parse a string as an URL, with this URL as the base URL.</p>
<p>The inverse of this is <a href="#method.make_relative"><code>make_relative</code></a>.</p>
<h5 id="notes"><a class="doc-anchor" href="#notes">§</a>Notes</h5>
<ul>
<li>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.</li>
<li>A <a href="https://url.spec.whatwg.org/#scheme-relative-special-url-string">scheme relative special URL</a>
as input replaces everything in the base URL after the scheme.</li>
<li>An absolute URL (with a scheme) as input replaces the whole base URL (even the scheme).</li>
</ul>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="comment">// Base without a trailing slash
</span><span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b.html"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = base.join(<span class="string">"c.png"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.net/a/c.png"</span>); <span class="comment">// Not /a/b.html/c.png
// Base with a trailing slash
</span><span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = base.join(<span class="string">"c.png"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.net/a/b/c.png"</span>);
<span class="comment">// Input as scheme relative special URL
</span><span class="kw">let </span>base = Url::parse(<span class="string">"https://alice.com/a"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = base.join(<span class="string">"//eve.com/b"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://eve.com/b"</span>);
<span class="comment">// Input as absolute URL
</span><span class="kw">let </span>base = Url::parse(<span class="string">"https://alice.com/a"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = base.join(<span class="string">"http://eve.com/b"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"http://eve.com/b"</span>); <span class="comment">// http instead of https</span></code></pre></div>
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</h5>
<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></details><details class="toggle method-toggle" open><summary><section id="method.make_relative" class="method"><a class="src rightside" href="../src/url/lib.rs.html#470-559">source</a><h4 class="code-header">pub fn <a href="#method.make_relative" class="fn">make_relative</a>(&amp;self, url: &amp;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>&gt;</h4></section></summary><div class="docblock"><p>Creates a relative URL if possible, with this URL as the base URL.</p>
<p>This is the inverse of <a href="#method.join"><code>join</code></a>.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b.html"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.net/a/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>relative = base.make_relative(<span class="kw-2">&amp;</span>url);
<span class="macro">assert_eq!</span>(relative.as_ref().map(|s| s.as_str()), <span class="prelude-val">Some</span>(<span class="string">"c.png"</span>));
<span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.net/a/b/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>relative = base.make_relative(<span class="kw-2">&amp;</span>url);
<span class="macro">assert_eq!</span>(relative.as_ref().map(|s| s.as_str()), <span class="prelude-val">Some</span>(<span class="string">"c.png"</span>));
<span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b/"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.net/a/d/c.png"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>relative = base.make_relative(<span class="kw-2">&amp;</span>url);
<span class="macro">assert_eq!</span>(relative.as_ref().map(|s| s.as_str()), <span class="prelude-val">Some</span>(<span class="string">"../d/c.png"</span>));
<span class="kw">let </span>base = Url::parse(<span class="string">"https://example.net/a/b.html?c=d"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.net/a/b.html?e=f"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>relative = base.make_relative(<span class="kw-2">&amp;</span>url);
<span class="macro">assert_eq!</span>(relative.as_ref().map(|s| s.as_str()), <span class="prelude-val">Some</span>(<span class="string">"?e=f"</span>));</code></pre></div>
<h5 id="errors-3"><a class="doc-anchor" href="#errors-3">§</a>Errors</h5>
<p>If this URL cant be a base for the given URL, <code>None</code> is returned.
This is for example the case if the scheme, host or port are not the same.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.options" class="method"><a class="src rightside" href="../src/url/lib.rs.html#580-586">source</a><h4 class="code-header">pub fn <a href="#method.options" class="fn">options</a>&lt;'a&gt;() -&gt; <a class="struct" href="struct.ParseOptions.html" title="struct url::ParseOptions">ParseOptions</a>&lt;'a&gt;</h4></section></summary><div class="docblock"><p>Return a default <code>ParseOptions</code> that can fully configure the URL parser.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<p>Get default <code>ParseOptions</code>, then change base url</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>options = Url::options();
<span class="kw">let </span>api = Url::parse(<span class="string">"https://api.example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>base_url = options.base_url(<span class="prelude-val">Some</span>(<span class="kw-2">&amp;</span>api));
<span class="kw">let </span>version_url = base_url.parse(<span class="string">"version.json"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(version_url.as_str(), <span class="string">"https://api.example.com/version.json"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_str" class="method"><a class="src rightside" href="../src/url/lib.rs.html#607-609">source</a><h4 class="code-header">pub fn <a href="#method.as_str" class="fn">as_str</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><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>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url_str = <span class="string">"https://example.net/"</span>;
<span class="kw">let </span>url = Url::parse(url_str)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), url_str);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_string" class="method"><a class="src rightside" href="../src/url/lib.rs.html#631-633">source</a><h4 class="code-header">pub fn <a href="#method.into_string" class="fn">into_string</a>(self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated since 2.3.0: use Into&lt;String&gt;</span></div></span></summary><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>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url_str = <span class="string">"https://example.net/"</span>;
<span class="kw">let </span>url = Url::parse(url_str)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(String::from(url), url_str);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.origin" class="method"><a class="src rightside" href="../src/url/lib.rs.html#837-839">source</a><h4 class="code-header">pub fn <a href="#method.origin" class="fn">origin</a>(&amp;self) -&gt; <a class="enum" href="enum.Origin.html" title="enum url::Origin">Origin</a></h4></section></summary><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>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<p>URL with <code>ftp</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Host, Origin, Url};
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://example.com/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.origin(),
Origin::Tuple(<span class="string">"ftp"</span>.into(),
Host::Domain(<span class="string">"example.com"</span>.into()),
<span class="number">21</span>));</code></pre></div>
<p>URL with <code>blob</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Host, Origin, Url};
<span class="kw">let </span>url = Url::parse(<span class="string">"blob:https://example.com/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.origin(),
Origin::Tuple(<span class="string">"https"</span>.into(),
Host::Domain(<span class="string">"example.com"</span>.into()),
<span class="number">443</span>));</code></pre></div>
<p>URL with <code>file</code> scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Host, Origin, Url};
<span class="kw">let </span>url = Url::parse(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.origin().is_tuple());
<span class="kw">let </span>other_url = Url::parse(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.origin() != other_url.origin());</code></pre></div>
<p>URL with other scheme:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Host, Origin, Url};
<span class="kw">let </span>url = Url::parse(<span class="string">"foo:bar"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.origin().is_tuple());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.scheme" class="method"><a class="src rightside" href="../src/url/lib.rs.html#857-859">source</a><h4 class="code-header">pub fn <a href="#method.scheme" class="fn">scheme</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the scheme of this URL, lower-cased, as an ASCII string without the : delimiter.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.scheme(), <span class="string">"file"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_special" class="method"><a class="src rightside" href="../src/url/lib.rs.html#877-880">source</a><h4 class="code-header">pub fn <a href="#method.is_special" class="fn">is_special</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Return whether the URL is special (has a special scheme)</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="macro">assert!</span>(Url::parse(<span class="string">"http:///tmp/foo"</span>)<span class="question-mark">?</span>.is_special());
<span class="macro">assert!</span>(Url::parse(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>.is_special());
<span class="macro">assert!</span>(!Url::parse(<span class="string">"moz:///tmp/foo"</span>)<span class="question-mark">?</span>.is_special());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.has_authority" class="method"><a class="src rightside" href="../src/url/lib.rs.html#910-913">source</a><h4 class="code-header">pub fn <a href="#method.has_authority" class="fn">has_authority</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><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>
<p>See also the <code>authority</code> method.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.has_authority());
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.has_authority());
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.has_authority());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.authority" class="method"><a class="src rightside" href="../src/url/lib.rs.html#947-954">source</a><h4 class="code-header">pub fn <a href="#method.authority" class="fn">authority</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the authority of this URL as an ASCII string.</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.
Ports are omitted if they match the well known port of a special URL.</p>
<p>Username and password are percent-encoded.</p>
<p>See also the <code>has_authority</code> method.</p>
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.authority(), <span class="string">""</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"file:///tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.authority(), <span class="string">""</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://user:password@example.com/tmp/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.authority(), <span class="string">"user:password@example.com"</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"irc://àlex.рф.example.com:6667/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.authority(), <span class="string">"%C3%A0lex.%D1%80%D1%84.example.com:6667"</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"http://àlex.рф.example.com:80/foo"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.authority(), <span class="string">"xn--lex-8ka.xn--p1ai.example.com"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.cannot_be_a_base" class="method"><a class="src rightside" href="../src/url/lib.rs.html#982-984">source</a><h4 class="code-header">pub fn <a href="#method.cannot_be_a_base" class="fn">cannot_be_a_base</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><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>
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.cannot_be_a_base());
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.cannot_be_a_base());
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.cannot_be_a_base());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.username" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1008-1015">source</a><h4 class="code-header">pub fn <a href="#method.username" class="fn">username</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class="docblock"><p>Return the username for this URL (typically the empty string)
as a percent-encoded ASCII string.</p>
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.username(), <span class="string">"rms"</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.username(), <span class="string">""</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.username(), <span class="string">""</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.password" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1041-1053">source</a><h4 class="code-header">pub fn <a href="#method.password" class="fn">password</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><div class="docblock"><p>Return the password for this URL, if any, as a percent-encoded ASCII string.</p>
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">Some</span>(<span class="string">"secret123"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://:secret123@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">Some</span>(<span class="string">"secret123"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.has_host" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1076-1078">source</a><h4 class="code-header">pub fn <a href="#method.has_host" class="fn">has_host</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Equivalent to <code>url.host().is_some()</code>.</p>
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.has_host());
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.has_host());
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(!url.has_host());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.host_str" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1113-1119">source</a><h4 class="code-header">pub fn <a href="#method.host_str" class="fn">host_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><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>
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://127.0.0.1/index.html"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.host_str(), <span class="prelude-val">Some</span>(<span class="string">"127.0.0.1"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.host_str(), <span class="prelude-val">Some</span>(<span class="string">"example.com"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.host_str(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.host_str(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.host" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1152-1159">source</a><h4 class="code-header">pub fn <a href="#method.host" class="fn">host</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="enum.Host.html" title="enum url::Host">Host</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;&gt;</h4></section></summary><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>
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://127.0.0.1/index.html"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.host().is_some());
<span class="kw">let </span>url = Url::parse(<span class="string">"ftp://rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.host().is_some());
<span class="kw">let </span>url = Url::parse(<span class="string">"unix:/run/foo.socket"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.host().is_none());
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,Stuff"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.host().is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.domain" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1184-1189">source</a><h4 class="code-header">pub fn <a href="#method.domain" class="fn">domain</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><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>
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://127.0.0.1/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.domain(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.domain(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.domain(), <span class="prelude-val">Some</span>(<span class="string">"example.com"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.port" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1216-1218">source</a><h4 class="code-header">pub fn <a href="#method.port" class="fn">port</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.u16.html">u16</a>&gt;</h4></section></summary><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>
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com:443/"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"ssh://example.com:22"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port(), <span class="prelude-val">Some</span>(<span class="number">22</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.port_or_known_default" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1248-1250">source</a><h4 class="code-header">pub fn <a href="#method.port_or_known_default" class="fn">port_or_known_default</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.u16.html">u16</a>&gt;</h4></section></summary><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>
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"foo://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port_or_known_default(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"foo://example.com:1456"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port_or_known_default(), <span class="prelude-val">Some</span>(<span class="number">1456</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.port_or_known_default(), <span class="prelude-val">Some</span>(<span class="number">443</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.socket_addrs" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1280-1306">source</a><h4 class="code-header">pub fn <a href="#method.socket_addrs" class="fn">socket_addrs</a>(
&amp;self,
default_port_number: impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/function/trait.Fn.html" title="trait core::ops::function::Fn">Fn</a>() -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.u16.html">u16</a>&gt;,
) -&gt; <a class="type" href="https://doc.rust-lang.org/1.80.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.80.0/core/net/socket_addr/enum.SocketAddr.html" title="enum core::net::socket_addr::SocketAddr">SocketAddr</a>&gt;&gt;</h4></section></summary><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>
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>url = url::Url::parse(<span class="string">"https://example.net/"</span>).unwrap();
<span class="kw">let </span>addrs = url.socket_addrs(|| <span class="prelude-val">None</span>).unwrap();
std::net::TcpStream::connect(<span class="kw-2">&amp;*</span>addrs)</code></pre></div>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="doccomment">/// With application-specific known default port numbers
</span><span class="kw">fn </span>socket_addrs(url: url::Url) -&gt; std::io::Result&lt;Vec&lt;std::net::SocketAddr&gt;&gt; {
url.socket_addrs(|| <span class="kw">match </span>url.scheme() {
<span class="string">"socks5" </span>| <span class="string">"socks5h" </span>=&gt; <span class="prelude-val">Some</span>(<span class="number">1080</span>),
<span class="kw">_ </span>=&gt; <span class="prelude-val">None</span>,
})
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.path" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1331-1338">source</a><h4 class="code-header">pub fn <a href="#method.path" class="fn">path</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><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>
<h5 id="examples-22"><a class="doc-anchor" href="#examples-22">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/api/versions?page=2"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/api/versions"</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/"</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/countries/việt nam"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/countries/vi%E1%BB%87t%20nam"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.path_segments" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1378-1381">source</a><h4 class="code-header">pub fn <a href="#method.path_segments" class="fn">path_segments</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/core/str/iter/struct.Split.html" title="struct core::str::iter::Split">Split</a>&lt;'_, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.char.html">char</a>&gt;&gt;</h4></section></summary><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>
<h5 id="examples-23"><a class="doc-anchor" href="#examples-23">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/foo/bar"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>path_segments = url.path_segments().ok_or_else(|| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">Some</span>(<span class="string">"foo"</span>));
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">Some</span>(<span class="string">"bar"</span>));
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>path_segments = url.path_segments().ok_or_else(|| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">Some</span>(<span class="string">""</span>));
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">None</span>);
<span class="kw">let </span>url = Url::parse(<span class="string">"data:text/plain,HelloWorld"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.path_segments().is_none());
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/countries/việt nam"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>path_segments = url.path_segments().ok_or_else(|| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">Some</span>(<span class="string">"countries"</span>));
<span class="macro">assert_eq!</span>(path_segments.next(), <span class="prelude-val">Some</span>(<span class="string">"vi%E1%BB%87t%20nam"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.query" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1407-1419">source</a><h4 class="code-header">pub fn <a href="#method.query" class="fn">query</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><div class="docblock"><p>Return this URLs query string, if any, as a percent-encoded ASCII string.</p>
<h5 id="examples-24"><a class="doc-anchor" href="#examples-24">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">fn </span>run() -&gt; <span class="prelude-ty">Result</span>&lt;(), ParseError&gt; {
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/products?page=2"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>query = url.query();
<span class="macro">assert_eq!</span>(query, <span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/products"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>query = url.query();
<span class="macro">assert!</span>(query.is_none());
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/?country=español"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>query = url.query();
<span class="macro">assert_eq!</span>(query, <span class="prelude-val">Some</span>(<span class="string">"country=espa%C3%B1ol"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.query_pairs" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1446-1448">source</a><h4 class="code-header">pub fn <a href="#method.query_pairs" class="fn">query_pairs</a>(&amp;self) -&gt; <a class="struct" href="../form_urlencoded/struct.Parse.html" title="struct form_urlencoded::Parse">Parse</a>&lt;'_&gt;</h4></section></summary><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>
<h5 id="examples-25"><a class="doc-anchor" href="#examples-25">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::borrow::Cow;
<span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/products?page=2&amp;sort=desc"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span><span class="kw-2">mut </span>pairs = url.query_pairs();
<span class="macro">assert_eq!</span>(pairs.count(), <span class="number">2</span>);
<span class="macro">assert_eq!</span>(pairs.next(), <span class="prelude-val">Some</span>((Cow::Borrowed(<span class="string">"page"</span>), Cow::Borrowed(<span class="string">"2"</span>))));
<span class="macro">assert_eq!</span>(pairs.next(), <span class="prelude-val">Some</span>((Cow::Borrowed(<span class="string">"sort"</span>), Cow::Borrowed(<span class="string">"desc"</span>))));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.fragment" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1482-1487">source</a><h4 class="code-header">pub fn <a href="#method.fragment" class="fn">fragment</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;</h4></section></summary><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>
<h5 id="examples-26"><a class="doc-anchor" href="#examples-26">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/data.csv#row=4"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.fragment(), <span class="prelude-val">Some</span>(<span class="string">"row=4"</span>));
<span class="kw">let </span>url = Url::parse(<span class="string">"https://example.com/data.csv#cell=4,1-6,2"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.fragment(), <span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_fragment" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1519-1534">source</a><h4 class="code-header">pub fn <a href="#method.set_fragment" class="fn">set_fragment</a>(&amp;mut self, fragment: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;)</h4></section></summary><div class="docblock"><p>Change this URLs fragment identifier.</p>
<h5 id="examples-27"><a class="doc-anchor" href="#examples-27">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com/data.csv"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/data.csv"</span>);
url.set_fragment(<span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/data.csv#cell=4,1-6,2"</span>);
<span class="macro">assert_eq!</span>(url.fragment(), <span class="prelude-val">Some</span>(<span class="string">"cell=4,1-6,2"</span>));
url.set_fragment(<span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/data.csv"</span>);
<span class="macro">assert!</span>(url.fragment().is_none());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_query" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1574-1604">source</a><h4 class="code-header">pub fn <a href="#method.set_query" class="fn">set_query</a>(&amp;mut self, query: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;)</h4></section></summary><div class="docblock"><p>Change this URLs query string. If <code>query</code> is <code>None</code>, this URLs
query string will be cleared.</p>
<h5 id="examples-28"><a class="doc-anchor" href="#examples-28">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com/products"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/products"</span>);
url.set_query(<span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/products?page=2"</span>);
<span class="macro">assert_eq!</span>(url.query(), <span class="prelude-val">Some</span>(<span class="string">"page=2"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.query_pairs_mut" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1638-1656">source</a><h4 class="code-header">pub fn <a href="#method.query_pairs_mut" class="fn">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="struct.UrlQuery.html" title="struct url::UrlQuery">UrlQuery</a>&lt;'_&gt;&gt;</h4></section></summary><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"><code>
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.net?lang=fr#nav"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.query(), <span class="prelude-val">Some</span>(<span class="string">"lang=fr"</span>));
url.query_pairs_mut().append_pair(<span class="string">"foo"</span>, <span class="string">"bar"</span>);
<span class="macro">assert_eq!</span>(url.query(), <span class="prelude-val">Some</span>(<span class="string">"lang=fr&amp;foo=bar"</span>));
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.net/?lang=fr&amp;foo=bar#nav"</span>);
url.query_pairs_mut()
.clear()
.append_pair(<span class="string">"foo"</span>, <span class="string">"bar &amp; baz"</span>)
.append_pair(<span class="string">"saisons"</span>, <span class="string">"\u{00C9}t\u{00E9}+hiver"</span>);
<span class="macro">assert_eq!</span>(url.query(), <span class="prelude-val">Some</span>(<span class="string">"foo=bar+%26+baz&amp;saisons=%C3%89t%C3%A9%2Bhiver"</span>));
<span class="macro">assert_eq!</span>(url.as_str(),
<span class="string">"https://example.net/?foo=bar+%26+baz&amp;saisons=%C3%89t%C3%A9%2Bhiver#nav"</span>);</code></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></details><details class="toggle method-toggle" open><summary><section id="method.set_path" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1704-1727">source</a><h4 class="code-header">pub fn <a href="#method.set_path" class="fn">set_path</a>(&amp;mut self, path: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>)</h4></section></summary><div class="docblock"><p>Change this URLs path.</p>
<h5 id="examples-29"><a class="doc-anchor" href="#examples-29">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
url.set_path(<span class="string">"api/comments"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/api/comments"</span>);
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/api/comments"</span>);
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com/api"</span>)<span class="question-mark">?</span>;
url.set_path(<span class="string">"data/report.csv"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/data/report.csv"</span>);
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/data/report.csv"</span>);
<span class="comment">// `set_path` percent-encodes the given string if it's not already percent-encoded.
</span><span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
url.set_path(<span class="string">"api/some comments"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/api/some%20comments"</span>);
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/api/some%20comments"</span>);
<span class="comment">// `set_path` will not double percent-encode the string if it's already percent-encoded.
</span><span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.com"</span>)<span class="question-mark">?</span>;
url.set_path(<span class="string">"api/some%20comments"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.com/api/some%20comments"</span>);
<span class="macro">assert_eq!</span>(url.path(), <span class="string">"/api/some%20comments"</span>);
</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.path_segments_mut" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1733-1739">source</a><h4 class="code-header">pub fn <a href="#method.path_segments_mut" class="fn">path_segments_mut</a>(&amp;mut self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.PathSegmentsMut.html" title="struct url::PathSegmentsMut">PathSegmentsMut</a>&lt;'_&gt;, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="method.set_port" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1817-1827">source</a><h4 class="code-header">pub fn <a href="#method.set_port" class="fn">set_port</a>(&amp;mut self, port: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.u16.html">u16</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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>
<h5 id="examples-30"><a class="doc-anchor" href="#examples-30">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"ssh://example.net:2048/"</span>)<span class="question-mark">?</span>;
url.set_port(<span class="prelude-val">Some</span>(<span class="number">4096</span>)).map_err(|<span class="kw">_</span>| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"ssh://example.net:4096/"</span>);
url.set_port(<span class="prelude-val">None</span>).map_err(|<span class="kw">_</span>| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"ssh://example.net/"</span>);</code></pre></div>
<p>Known default port numbers are not reflected:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.org/"</span>)<span class="question-mark">?</span>;
url.set_port(<span class="prelude-val">Some</span>(<span class="number">443</span>)).map_err(|<span class="kw">_</span>| <span class="string">"cannot be base"</span>)<span class="question-mark">?</span>;
<span class="macro">assert!</span>(url.port().is_none());</code></pre></div>
<p>Cannot set port for cannot-be-a-base URLs:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_port(<span class="prelude-val">Some</span>(<span class="number">80</span>));
<span class="macro">assert!</span>(result.is_err());
<span class="kw">let </span>result = url.set_port(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(result.is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_host" class="method"><a class="src rightside" href="../src/url/lib.rs.html#1950-2012">source</a><h4 class="code-header">pub fn <a href="#method.set_host" class="fn">set_host</a>(&amp;mut self, host: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</h4></section></summary><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>
<h5 id="examples-31"><a class="doc-anchor" href="#examples-31">§</a>Examples</h5>
<p>Change host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_host(<span class="prelude-val">Some</span>(<span class="string">"rust-lang.org"</span>));
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://rust-lang.org/"</span>);</code></pre></div>
<p>Remove host:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_host(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"foo:/"</span>);</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_host(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(result.is_err());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.net/"</span>);</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_host(<span class="prelude-val">Some</span>(<span class="string">"rust-lang.org"</span>));
<span class="macro">assert!</span>(result.is_err());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"mailto:rms@example.net"</span>);
<span class="kw">let </span>result = url.set_host(<span class="prelude-val">None</span>);
<span class="macro">assert!</span>(result.is_err());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"mailto:rms@example.net"</span>);</code></pre></div>
<h5 id="errors-4"><a class="doc-anchor" href="#errors-4">§</a>Errors</h5>
<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></details><details class="toggle method-toggle" open><summary><section id="method.set_ip_host" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2095-2106">source</a><h4 class="code-header">pub fn <a href="#method.set_ip_host" class="fn">set_ip_host</a>(&amp;mut self, address: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/net/ip_addr/enum.IpAddr.html" title="enum core::net::ip_addr::IpAddr">IpAddr</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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>
<h5 id="examples-32"><a class="doc-anchor" href="#examples-32">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"http://example.com"</span>)<span class="question-mark">?</span>;
url.set_ip_host(<span class="string">"127.0.0.1"</span>.parse().unwrap());
<span class="macro">assert_eq!</span>(url.host_str(), <span class="prelude-val">Some</span>(<span class="string">"127.0.0.1"</span>));
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"http://127.0.0.1/"</span>);</code></pre></div>
<p>Cannot change URLs from mailto(cannot-be-base) to ip:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rms@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_ip_host(<span class="string">"127.0.0.1"</span>.parse().unwrap());
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"mailto:rms@example.com"</span>);
<span class="macro">assert!</span>(result.is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_password" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2135-2191">source</a><h4 class="code-header">pub fn <a href="#method.set_password" class="fn">set_password</a>(&amp;mut self, password: <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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>
<h5 id="examples-33"><a class="doc-anchor" href="#examples-33">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rmz@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_password(<span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="macro">assert!</span>(result.is_err());
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"ftp://user1:secret1@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_password(<span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">Some</span>(<span class="string">"secret_password"</span>));
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"ftp://user2:@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_password(<span class="prelude-val">Some</span>(<span class="string">"secret2"</span>));
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(url.password(), <span class="prelude-val">Some</span>(<span class="string">"secret2"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_username" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2229-2278">source</a><h4 class="code-header">pub fn <a href="#method.set_username" class="fn">set_username</a>(&amp;mut self, username: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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>
<h5 id="examples-34"><a class="doc-anchor" href="#examples-34">§</a>Examples</h5>
<p>Cannot setup username from mailto(cannot-be-base)</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rmz@example.com"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_username(<span class="string">"user1"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"mailto:rmz@example.com"</span>);
<span class="macro">assert!</span>(result.is_err());</code></pre></div>
<p>Setup username to user1</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::{Url, ParseError};
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"ftp://:secre1@example.com/"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_username(<span class="string">"user1"</span>);
<span class="macro">assert!</span>(result.is_ok());
<span class="macro">assert_eq!</span>(url.username(), <span class="string">"user1"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"ftp://user1:secre1@example.com/"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.set_scheme" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2391-2440">source</a><h4 class="code-header">pub fn <a href="#method.set_scheme" class="fn">set_scheme</a>(&amp;mut self, scheme: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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 URLs 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 specifications section on legal scheme state
overrides</a>.</p>
<h5 id="examples-35"><a class="doc-anchor" href="#examples-35">§</a>Examples</h5>
<p>Change the URLs scheme from <code>https</code> to <code>http</code>:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"http"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"http://example.net/"</span>);
<span class="macro">assert!</span>(result.is_ok());</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"bar"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"bar://example.net"</span>);
<span class="macro">assert!</span>(result.is_ok());</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"https://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"foõ"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"https://example.net/"</span>);
<span class="macro">assert!</span>(result.is_err());</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"mailto:rms@example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"https"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"mailto:rms@example.net"</span>);
<span class="macro">assert!</span>(result.is_err());</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"foo://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"https"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"foo://example.net"</span>);
<span class="macro">assert!</span>(result.is_err());</code></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"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span><span class="kw-2">mut </span>url = Url::parse(<span class="string">"http://example.net"</span>)<span class="question-mark">?</span>;
<span class="kw">let </span>result = url.set_scheme(<span class="string">"foo"</span>);
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"http://example.net/"</span>);
<span class="macro">assert!</span>(result.is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_file_path" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2471-2487">source</a><h4 class="code-header">pub fn <a href="#method.from_file_path" class="fn">from_file_path</a>&lt;P: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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>
<h5 id="examples-36"><a class="doc-anchor" href="#examples-36">§</a>Examples</h5>
<p>On Unix-like platforms:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>url::Url;
<span class="kw">let </span>url = Url::from_file_path(<span class="string">"/tmp/foo.txt"</span>)<span class="question-mark">?</span>;
<span class="macro">assert_eq!</span>(url.as_str(), <span class="string">"file:///tmp/foo.txt"</span>);
<span class="kw">let </span>url = Url::from_file_path(<span class="string">"../foo.txt"</span>);
<span class="macro">assert!</span>(url.is_err());
<span class="kw">let </span>url = Url::from_file_path(<span class="string">"https://google.com/"</span>);
<span class="macro">assert!</span>(url.is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.from_directory_path" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2508-2514">source</a><h4 class="code-header">pub fn <a href="#method.from_directory_path" class="fn">from_directory_path</a>&lt;P: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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></details><details class="toggle method-toggle" open><summary><section id="method.to_file_path" class="method"><a class="src rightside" href="../src/url/lib.rs.html#2625-2638">source</a><h4 class="code-header">pub fn <a href="#method.to_file_path" class="fn">to_file_path</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>, <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.unit.html">()</a>&gt;</h4></section></summary><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"><code><span class="kw">let </span>path = url.to_file_path();</code></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></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsRef%3Cstr%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2747-2752">source</a><a href="#impl-AsRef%3Cstr%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Return the serialization of this URL.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_ref" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2749-2751">source</a><a href="#method.as_ref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.AsRef.html#tymethod.as_ref" class="fn">as_ref</a>(&amp;self) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>Converts this type into a shared reference of the (usually inferred) input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#186">source</a><a href="#impl-Clone-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#186">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/clone.rs.html#169">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2690-2706">source</a><a href="#impl-Debug-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Debug the serialization of this URL.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2692-2705">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Display-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2675-2680">source</a><a href="#impl-Display-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Display the serialization of this URL.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt-1" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2677-2679">source</a><a href="#method.fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.80.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-From%3CUrl%3E-for-String" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2683-2687">source</a><a href="#impl-From%3CUrl%3E-for-String" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>&gt; for <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h3></section></summary><div class="docblock"><p>String conversion.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2684-2686">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(value: <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts to this type from the input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-FromStr-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2657-2664">source</a><a href="#impl-FromStr-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr">FromStr</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>Parse a string as an URL, without a base URL or encoding override.</p>
</div><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Err" class="associatedtype trait-impl"><a href="#associatedtype.Err" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#associatedtype.Err" class="associatedtype">Err</a> = <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a></h4></section></summary><div class='docblock'>The associated error which can be returned from parsing.</div></details><details class="toggle method-toggle" open><summary><section id="method.from_str" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2661-2663">source</a><a href="#method.from_str" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#tymethod.from_str" class="fn">from_str</a>(input: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Url.html" title="struct url::Url">Url</a>, <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a>&gt;</h4></section></summary><div class='docblock'>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/1.80.0/core/str/traits/trait.FromStr.html#tymethod.from_str">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Hash-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2736-2744">source</a><a href="#impl-Hash-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs hash like their serialization.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.hash" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2738-2743">source</a><a href="#method.hash" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html#tymethod.hash" class="fn">hash</a>&lt;H&gt;(&amp;self, state: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,</div></h4></section></summary><div class='docblock'>Feeds this value into the given <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html#tymethod.hash">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.hash_slice" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.3.0">1.3.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/hash/mod.rs.html#238-240">source</a></span><a href="#method.hash_slice" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html#method.hash_slice" class="fn">hash_slice</a>&lt;H&gt;(data: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.slice.html">[Self]</a>, state: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;mut H</a>)<div class="where">where
H: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher">Hasher</a>,
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Feeds a slice of this type into the given <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hasher.html" title="trait core::hash::Hasher"><code>Hasher</code></a>. <a href="https://doc.rust-lang.org/1.80.0/core/hash/trait.Hash.html#method.hash_slice">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Index%3CRange%3CPosition%3E%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/slicing.rs.html#33-38">source</a><a href="#impl-Index%3CRange%3CPosition%3E%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output" class="associatedtype trait-impl"><a href="#associatedtype.Output" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="toggle method-toggle" open><summary><section id="method.index" class="method trait-impl"><a class="src rightside" href="../src/url/slicing.rs.html#35-37">source</a><a href="#method.index" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index" class="fn">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.Range.html" title="struct core::ops::range::Range">Range</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeFrom%3CPosition%3E%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/slicing.rs.html#19-24">source</a><a href="#impl-Index%3CRangeFrom%3CPosition%3E%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-2" class="associatedtype trait-impl"><a href="#associatedtype.Output-2" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="toggle method-toggle" open><summary><section id="method.index-2" class="method trait-impl"><a class="src rightside" href="../src/url/slicing.rs.html#21-23">source</a><a href="#method.index-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index" class="fn">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.RangeFrom.html" title="struct core::ops::range::RangeFrom">RangeFrom</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeFull%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/slicing.rs.html#12-17">source</a><a href="#impl-Index%3CRangeFull%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.RangeFull.html" title="struct core::ops::range::RangeFull">RangeFull</a>&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-1" class="associatedtype trait-impl"><a href="#associatedtype.Output-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="toggle method-toggle" open><summary><section id="method.index-1" class="method trait-impl"><a class="src rightside" href="../src/url/slicing.rs.html#14-16">source</a><a href="#method.index-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index" class="fn">index</a>(&amp;self, _: <a class="struct" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Index%3CRangeTo%3CPosition%3E%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/slicing.rs.html#26-31">source</a><a href="#impl-Index%3CRangeTo%3CPosition%3E%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html" title="trait core::ops::index::Index">Index</a>&lt;<a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Output-3" class="associatedtype trait-impl"><a href="#associatedtype.Output-3" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#associatedtype.Output" class="associatedtype">Output</a> = <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>The returned type after indexing.</div></details><details class="toggle method-toggle" open><summary><section id="method.index-3" class="method trait-impl"><a class="src rightside" href="../src/url/slicing.rs.html#28-30">source</a><a href="#method.index-3" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index" class="fn">index</a>(&amp;self, range: <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/ops/range/struct.RangeTo.html" title="struct core::ops::range::RangeTo">RangeTo</a>&lt;<a class="enum" href="enum.Position.html" title="enum url::Position">Position</a>&gt;) -&gt; &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a></h4></section></summary><div class='docblock'>Performs the indexing (<code>container[index]</code>) operation. <a href="https://doc.rust-lang.org/1.80.0/core/ops/index/trait.Index.html#tymethod.index">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Ord-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2720-2725">source</a><a href="#impl-Ord-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.cmp" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2722-2724">source</a><a href="#method.cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#tymethod.cmp" class="fn">cmp</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a></h4></section></summary><div class='docblock'>This method returns an <a href="https://doc.rust-lang.org/1.80.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering"><code>Ordering</code></a> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.max" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#856-858">source</a></span><a href="#method.max" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.max" class="fn">max</a>(self, other: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the maximum of two values. <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.max">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.min" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.21.0">1.21.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#877-879">source</a></span><a href="#method.min" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.min" class="fn">min</a>(self, other: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h4></section></summary><div class='docblock'>Compares and returns the minimum of two values. <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.min">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clamp" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.50.0">1.50.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#903-906">source</a></span><a href="#method.clamp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.clamp" class="fn">clamp</a>(self, min: Self, max: Self) -&gt; Self<div class="where">where
Self: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a>,</div></h4></section></summary><div class='docblock'>Restrict a value to a certain interval. <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Ord.html#method.clamp">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2712-2717">source</a><a href="#impl-PartialEq-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2714-2716">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#263">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialOrd-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2728-2733">source</a><a href="#impl-PartialOrd-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="docblock"><p>URLs compare like their serialization.</p>
</div><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.partial_cmp" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2730-2732">source</a><a href="#method.partial_cmp" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp" class="fn">partial_cmp</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Self</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.80.0/core/cmp/enum.Ordering.html" title="enum core::cmp::Ordering">Ordering</a>&gt;</h4></section></summary><div class='docblock'>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.lt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#1180">source</a></span><a href="#method.lt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#method.lt" class="fn">lt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>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/1.80.0/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.le" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#1198">source</a></span><a href="#method.le" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#method.le" class="fn">le</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>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/1.80.0/core/cmp/trait.PartialOrd.html#method.le">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.gt" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#1215">source</a></span><a href="#method.gt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#method.gt" class="fn">gt</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>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/1.80.0/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.ge" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/1.80.0/src/core/cmp.rs.html#1233">source</a></span><a href="#method.ge" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.PartialOrd.html#method.ge" class="fn">ge</a>(&amp;self, other: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;Rhs</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>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/1.80.0/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-TryFrom%3C%26str%3E-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2666-2672">source</a><a href="#impl-TryFrom%3C%26str%3E-for-Url" class="anchor">§</a><h3 class="code-header">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>&gt; for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="enum.ParseError.html" title="enum url::ParseError">ParseError</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="../src/url/lib.rs.html#2669-2671">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(s: &amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, Self::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><section id="impl-Eq-for-Url" class="impl"><a class="src rightside" href="../src/url/lib.rs.html#2709">source</a><a href="#impl-Eq-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><div class="docblock"><p>URLs compare like their serialization.</p>
</div></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Url" class="impl"><a href="#impl-Freeze-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-RefUnwindSafe-for-Url" class="impl"><a href="#impl-RefUnwindSafe-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Send-for-Url" class="impl"><a href="#impl-Send-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Sync-for-Url" class="impl"><a href="#impl-Sync-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-Unpin-for-Url" class="impl"><a href="#impl-Unpin-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section><section id="impl-UnwindSafe-for-Url" class="impl"><a href="#impl-UnwindSafe-for-Url" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Url.html" title="struct url::Url">Url</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.80.0/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.80.0/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#768">source</a><a href="#method.from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&amp;mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/1.80.0/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToString-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/string.rs.html#2552">source</a><a href="#impl-ToString-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html" title="trait alloc::string::ToString">ToString</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.to_string" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/alloc/string.rs.html#2558">source</a><a href="#method.to_string" class="anchor">§</a><h4 class="code-header">default fn <a href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html#tymethod.to_string" class="fn">to_string</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.80.0/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class='docblock'>Converts the given value to a <code>String</code>. <a href="https://doc.rust-lang.org/1.80.0/alloc/string/trait.ToString.html#tymethod.to_string">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from-1" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-2" class="associatedtype trait-impl"><a href="#associatedtype.Error-2" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.80.0/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/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/1.80.0/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.80.0/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>