500 lines
No EOL
64 KiB
HTML
500 lines
No EOL
64 KiB
HTML
<!DOCTYPE html>
|
||
<html lang="en">
|
||
<head>
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||
<meta name="generator" content="rustdoc">
|
||
<meta name="description" content="API documentation for the Rust `Url` struct in crate `hyper`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, Url">
|
||
|
||
<title>hyper::Url - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||
|
||
|
||
|
||
|
||
</head>
|
||
<body class="rustdoc">
|
||
<!--[if lte IE 8]>
|
||
<div class="warning">
|
||
This old browser is unsupported and will most likely display funky
|
||
things.
|
||
</div>
|
||
<![endif]-->
|
||
|
||
|
||
|
||
<nav class="sidebar">
|
||
|
||
<p class='location'><a href='index.html'>hyper</a></p><script>window.sidebarCurrent = {name: 'Url', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content struct">
|
||
<h1 class='fqn'><span class='in-band'>Struct <a href='index.html'>hyper</a>::<wbr><a class='struct' href=''>Url</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a id='src-1685' class='srclink' href='../url/struct.Url.html?gotosrc=1685' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust struct'>pub struct Url {
|
||
// some fields omitted
|
||
}</pre><div class='docblock'><p>A parsed URL record.</p>
|
||
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='method.parse' class='method'><code>fn <a href='#method.parse' class='fnname'>parse</a>(input: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>ParseError</a>></code></h4>
|
||
<div class='docblock'><p>Parse an absolute URL from a string.</p>
|
||
</div><h4 id='method.join' class='method'><code>fn <a href='#method.join' class='fnname'>join</a>(&self, input: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>ParseError</a>></code></h4>
|
||
<div class='docblock'><p>Parse a string as an URL, with this URL as the base URL.</p>
|
||
</div><h4 id='method.options' class='method'><code>fn <a href='#method.options' class='fnname'>options</a>() -> <a class='struct' href='../url/struct.ParseOptions.html' title='url::ParseOptions'>ParseOptions</a><'a></code></h4>
|
||
<div class='docblock'><p>Return a default <code>ParseOptions</code> that can fully configure the URL parser.</p>
|
||
</div><h4 id='method.as_str' class='method'><code>fn <a href='#method.as_str' class='fnname'>as_str</a>(&self) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<div class='docblock'><p>Return the serialization of this URL.</p>
|
||
|
||
<p>This is fast since that serialization is already stored in the <code>Url</code> struct.</p>
|
||
</div><h4 id='method.into_string' class='method'><code>fn <a href='#method.into_string' class='fnname'>into_string</a>(self) -> <a class='struct' href='https://doc.rust-lang.org/nightly/collections/string/struct.String.html' title='collections::string::String'>String</a></code></h4>
|
||
<div class='docblock'><p>Return the serialization of this URL.</p>
|
||
|
||
<p>This consumes the <code>Url</code> and takes ownership of the <code>String</code> stored in it.</p>
|
||
</div><h4 id='method.origin' class='method'><code>fn <a href='#method.origin' class='fnname'>origin</a>(&self) -> <a class='enum' href='../url/origin/enum.Origin.html' title='url::origin::Origin'>Origin</a></code></h4>
|
||
<div class='docblock'><p>Return the origin of this URL (<a href="https://url.spec.whatwg.org/#origin">https://url.spec.whatwg.org/#origin</a>)</p>
|
||
|
||
<p>Note: this returns an opaque origin for <code>file:</code> URLs, which causes
|
||
<code>url.origin() != url.origin()</code>.</p>
|
||
|
||
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
|
||
<p>URL with <code>ftp</code> scheme:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::{<span class='ident'>Host</span>, <span class='ident'>Origin</span>, <span class='ident'>Url</span>};
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://example.com/foo"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>origin</span>(),
|
||
<span class='ident'>Origin</span>::<span class='ident'>Tuple</span>(<span class='string'>"ftp"</span>.<span class='ident'>into</span>(),
|
||
<span class='ident'>Host</span>::<span class='ident'>Domain</span>(<span class='string'>"example.com"</span>.<span class='ident'>into</span>()),
|
||
<span class='number'>21</span>));</pre>
|
||
|
||
<p>URL with <code>blob</code> scheme:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::{<span class='ident'>Host</span>, <span class='ident'>Origin</span>, <span class='ident'>Url</span>};
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"blob:https://example.com/foo"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>origin</span>(),
|
||
<span class='ident'>Origin</span>::<span class='ident'>Tuple</span>(<span class='string'>"https"</span>.<span class='ident'>into</span>(),
|
||
<span class='ident'>Host</span>::<span class='ident'>Domain</span>(<span class='string'>"example.com"</span>.<span class='ident'>into</span>()),
|
||
<span class='number'>443</span>));</pre>
|
||
|
||
<p>URL with <code>file</code> scheme:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::{<span class='ident'>Host</span>, <span class='ident'>Origin</span>, <span class='ident'>Url</span>};
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"file:///tmp/foo"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>url</span>.<span class='ident'>origin</span>().<span class='ident'>is_tuple</span>());
|
||
|
||
<span class='kw'>let</span> <span class='ident'>other_url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"file:///tmp/foo"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>origin</span>() <span class='op'>!=</span> <span class='ident'>other_url</span>.<span class='ident'>origin</span>());</pre>
|
||
|
||
<p>URL with other scheme:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::{<span class='ident'>Host</span>, <span class='ident'>Origin</span>, <span class='ident'>Url</span>};
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"foo:bar"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert</span><span class='macro'>!</span>(<span class='op'>!</span><span class='ident'>url</span>.<span class='ident'>origin</span>().<span class='ident'>is_tuple</span>());</pre>
|
||
</div><h4 id='method.scheme' class='method'><code>fn <a href='#method.scheme' class='fnname'>scheme</a>(&self) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<div class='docblock'><p>Return the scheme of this URL, lower-cased, as an ASCII string without the ':' delimiter.</p>
|
||
|
||
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::<span class='ident'>Url</span>;
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"file:///tmp/foo"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>scheme</span>(), <span class='string'>"file"</span>);</pre>
|
||
</div><h4 id='method.has_authority' class='method'><code>fn <a href='#method.has_authority' class='fnname'>has_authority</a>(&self) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
<div class='docblock'><p>Return whether the URL has an 'authority',
|
||
which can contain a username, password, host, and port number.</p>
|
||
|
||
<p>URLs that do <em>not</em> are either path-only like <code>unix:/run/foo.socket</code>
|
||
or cannot-be-a-base like <code>data:text/plain,Stuff</code>.</p>
|
||
</div><h4 id='method.cannot_be_a_base' class='method'><code>fn <a href='#method.cannot_be_a_base' class='fnname'>cannot_be_a_base</a>(&self) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
<div class='docblock'><p>Return whether this URL is a cannot-be-a-base URL,
|
||
meaning that parsing a relative URL string with this URL as the base will return an error.</p>
|
||
|
||
<p>This is the case if the scheme and <code>:</code> delimiter are not followed by a <code>/</code> slash,
|
||
as is typically the case of <code>data:</code> and <code>mailto:</code> URLs.</p>
|
||
</div><h4 id='method.username' class='method'><code>fn <a href='#method.username' class='fnname'>username</a>(&self) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<div class='docblock'><p>Return the username for this URL (typically the empty string)
|
||
as a percent-encoded ASCII string.</p>
|
||
|
||
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::<span class='ident'>Url</span>;
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://rms@example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>username</span>(), <span class='string'>"rms"</span>);
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://:secret123@example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>username</span>(), <span class='string'>""</span>);
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"https://example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>username</span>(), <span class='string'>""</span>);</pre>
|
||
</div><h4 id='method.password' class='method'><code>fn <a href='#method.password' class='fnname'>password</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
||
<div class='docblock'><p>Return the password for this URL, if any, as a percent-encoded ASCII string.</p>
|
||
|
||
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>use</span> <span class='ident'>url</span>::<span class='ident'>Url</span>;
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://rms:secret123@example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>password</span>(), <span class='prelude-val'>Some</span>(<span class='string'>"secret123"</span>));
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://:secret123@example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>password</span>(), <span class='prelude-val'>Some</span>(<span class='string'>"secret123"</span>));
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"ftp://rms@example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>password</span>(), <span class='prelude-val'>None</span>);
|
||
|
||
<span class='kw'>let</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"https://example.com"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>password</span>(), <span class='prelude-val'>None</span>);</pre>
|
||
</div><h4 id='method.has_host' class='method'><code>fn <a href='#method.has_host' class='fnname'>has_host</a>(&self) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
<div class='docblock'><p>Equivalent to <code>url.host().is_some()</code>.</p>
|
||
</div><h4 id='method.host_str' class='method'><code>fn <a href='#method.host_str' class='fnname'>host_str</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
||
<div class='docblock'><p>Return the string representation of the host (domain or IP address) for this URL, if any.</p>
|
||
|
||
<p>Non-ASCII domains are punycode-encoded per IDNA.
|
||
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
|
||
don’t have a host.</p>
|
||
|
||
<p>See also the <code>host</code> method.</p>
|
||
</div><h4 id='method.host' class='method'><code>fn <a href='#method.host' class='fnname'>host</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='enum' href='../url/host/enum.Host.html' title='url::host::Host'>Host</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>></code></h4>
|
||
<div class='docblock'><p>Return the parsed representation of the host for this URL.
|
||
Non-ASCII domain labels are punycode-encoded per IDNA.</p>
|
||
|
||
<p>Cannot-be-a-base URLs (typical of <code>data:</code> and <code>mailto:</code>) and some <code>file:</code> URLs
|
||
don’t have a host.</p>
|
||
|
||
<p>See also the <code>host_str</code> method.</p>
|
||
</div><h4 id='method.domain' class='method'><code>fn <a href='#method.domain' class='fnname'>domain</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
||
<div class='docblock'><p>If this URL has a host and it is a domain name (not an IP address), return it.</p>
|
||
</div><h4 id='method.port' class='method'><code>fn <a href='#method.port' class='fnname'>port</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u16.html'>u16</a>></code></h4>
|
||
<div class='docblock'><p>Return the port number for this URL, if any.</p>
|
||
</div><h4 id='method.port_or_known_default' class='method'><code>fn <a href='#method.port_or_known_default' class='fnname'>port_or_known_default</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u16.html'>u16</a>></code></h4>
|
||
<div class='docblock'><p>Return the port number for this URL, or the default port number if it is known.</p>
|
||
|
||
<p>This method only knows the default port number
|
||
of the <code>http</code>, <code>https</code>, <code>ws</code>, <code>wss</code>, <code>ftp</code>, and <code>gopher</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>
|
||
</div><h4 id='method.with_default_port' class='method'><code>fn <a href='#method.with_default_port' class='fnname'>with_default_port</a><F>(&self, f: F) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../url/host/struct.HostAndPort.html' title='url::host::HostAndPort'>HostAndPort</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>, <a class='struct' href='https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html' title='std::io::error::Error'>Error</a>> <span class='where'>where F: <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.FnOnce.html' title='core::ops::FnOnce'>FnOnce</a>(&<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u16.html'>u16</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></span></code></h4>
|
||
<div class='docblock'><p>If the URL has a host, return something that implements <code>ToSocketAddrs</code>.</p>
|
||
|
||
<p>If the URL has no port number and the scheme’s default port number is not known
|
||
(see <code>Url::port_or_known_default</code>),
|
||
the closure is called to obtain a port number.
|
||
Typically, this closure can match on the result <code>Url::scheme</code>
|
||
to have per-scheme default port numbers,
|
||
and panic for schemes it’s not prepared to handle.
|
||
For example:</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
|
||
<span class='kw'>fn</span> <span class='ident'>connect</span>(<span class='ident'>url</span>: <span class='kw-2'>&</span><span class='ident'>Url</span>) <span class='op'>-></span> <span class='ident'>io</span>::<span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>TcpStream</span><span class='op'>></span> {
|
||
<span class='ident'>TcpStream</span>::<span class='ident'>connect</span>(<span class='macro'>try</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>with_default_port</span>(<span class='ident'>default_port</span>)))
|
||
}
|
||
|
||
<span class='kw'>fn</span> <span class='ident'>default_port</span>(<span class='ident'>url</span>: <span class='kw-2'>&</span><span class='ident'>Url</span>) <span class='op'>-></span> <span class='prelude-ty'>Result</span><span class='op'><</span><span class='ident'>u16</span>, ()<span class='op'>></span> {
|
||
<span class='kw'>match</span> <span class='ident'>url</span>.<span class='ident'>scheme</span>() {
|
||
<span class='string'>"git"</span> <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='number'>9418</span>),
|
||
<span class='string'>"git+ssh"</span> <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='number'>22</span>),
|
||
<span class='string'>"git+https"</span> <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='number'>443</span>),
|
||
<span class='string'>"git+http"</span> <span class='op'>=></span> <span class='prelude-val'>Ok</span>(<span class='number'>80</span>),
|
||
_ <span class='op'>=></span> <span class='prelude-val'>Err</span>(()),
|
||
}
|
||
}</pre>
|
||
</div><h4 id='method.path' class='method'><code>fn <a href='#method.path' class='fnname'>path</a>(&self) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<div class='docblock'><p>Return the path for this URL, as a percent-encoded ASCII string.
|
||
For cannot-be-a-base URLs, this is an arbitrary string that doesn’t start with '/'.
|
||
For other URLs, this starts with a '/' slash
|
||
and continues with slash-separated path segments.</p>
|
||
</div><h4 id='method.path_segments' class='method'><code>fn <a href='#method.path_segments' class='fnname'>path_segments</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='struct' href='https://doc.rust-lang.org/nightly/core/str/struct.Split.html' title='core::str::Split'>Split</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.char.html'>char</a>>></code></h4>
|
||
<div class='docblock'><p>Unless this URL is cannot-be-a-base,
|
||
return an iterator of '/' slash-separated path segments,
|
||
each as a percent-encoded ASCII string.</p>
|
||
|
||
<p>Return <code>None</code> for cannot-be-a-base URLs.</p>
|
||
|
||
<p>When <code>Some</code> is returned, the iterator always contains at least one string
|
||
(which may be empty).</p>
|
||
</div><h4 id='method.query' class='method'><code>fn <a href='#method.query' class='fnname'>query</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
||
<div class='docblock'><p>Return this URL’s query string, if any, as a percent-encoded ASCII string.</p>
|
||
</div><h4 id='method.query_pairs' class='method'><code>fn <a href='#method.query_pairs' class='fnname'>query_pairs</a>(&self) -> <a class='struct' href='../url/form_urlencoded/struct.Parse.html' title='url::form_urlencoded::Parse'>Parse</a></code></h4>
|
||
<div class='docblock'><p>Parse the URL’s query string, if any, as <code>application/x-www-form-urlencoded</code>
|
||
and return an iterator of (key, value) pairs.</p>
|
||
</div><h4 id='method.fragment' class='method'><code>fn <a href='#method.fragment' class='fnname'>fragment</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>></code></h4>
|
||
<div class='docblock'><p>Return this URL’s fragment identifier, if any.</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>
|
||
</div><h4 id='method.set_fragment' class='method'><code>fn <a href='#method.set_fragment' class='fnname'>set_fragment</a>(&mut self, fragment: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>)</code></h4>
|
||
<div class='docblock'><p>Change this URL’s fragment identifier.</p>
|
||
</div><h4 id='method.set_query' class='method'><code>fn <a href='#method.set_query' class='fnname'>set_query</a>(&mut self, query: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>)</code></h4>
|
||
<div class='docblock'><p>Change this URL’s query string.</p>
|
||
</div><h4 id='method.query_pairs_mut' class='method'><code>fn <a href='#method.query_pairs_mut' class='fnname'>query_pairs_mut</a>(&mut self) -> <a class='struct' href='../url/form_urlencoded/struct.Serializer.html' title='url::form_urlencoded::Serializer'>Serializer</a><<a class='struct' href='../url/struct.UrlQuery.html' title='url::UrlQuery'>UrlQuery</a>></code></h4>
|
||
<div class='docblock'><p>Manipulate this URL’s 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>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>let</span> <span class='kw-2'>mut</span> <span class='ident'>url</span> <span class='op'>=</span> <span class='ident'>Url</span>::<span class='ident'>parse</span>(<span class='string'>"https://example.net?lang=fr#nav"</span>).<span class='ident'>unwrap</span>();
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>query</span>(), <span class='prelude-val'>Some</span>(<span class='string'>"lang=fr"</span>));
|
||
|
||
<span class='ident'>url</span>.<span class='ident'>query_pairs_mut</span>().<span class='ident'>append_pair</span>(<span class='string'>"foo"</span>, <span class='string'>"bar"</span>);
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>query</span>(), <span class='prelude-val'>Some</span>(<span class='string'>"lang=fr&foo=bar"</span>));
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>as_str</span>(), <span class='string'>"https://example.net/?lang=fr&foo=bar#nav"</span>);
|
||
|
||
<span class='ident'>url</span>.<span class='ident'>query_pairs_mut</span>()
|
||
.<span class='ident'>clear</span>()
|
||
.<span class='ident'>append_pair</span>(<span class='string'>"foo"</span>, <span class='string'>"bar & baz"</span>)
|
||
.<span class='ident'>append_pair</span>(<span class='string'>"saisons"</span>, <span class='string'>"Été+hiver"</span>);
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>query</span>(), <span class='prelude-val'>Some</span>(<span class='string'>"foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver"</span>));
|
||
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>url</span>.<span class='ident'>as_str</span>(),
|
||
<span class='string'>"https://example.net/?foo=bar+%26+baz&saisons=%C3%89t%C3%A9%2Bhiver#nav"</span>);</pre>
|
||
|
||
<p>Note: <code>url.query_pairs_mut().clear();</code> is equivalent to <code>url.set_query(Some(""))</code>,
|
||
not <code>url.set_query(None)</code>.</p>
|
||
|
||
<p>The state of <code>Url</code> is unspecified if this return value is leaked without being dropped.</p>
|
||
</div><h4 id='method.set_path' class='method'><code>fn <a href='#method.set_path' class='fnname'>set_path</a>(&mut self, path: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>)</code></h4>
|
||
<div class='docblock'><p>Change this URL’s path.</p>
|
||
</div><h4 id='method.path_segments_mut' class='method'><code>fn <a href='#method.path_segments_mut' class='fnname'>path_segments_mut</a>(&mut self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../url/path_segments/struct.PathSegmentsMut.html' title='url::path_segments::PathSegmentsMut'>PathSegmentsMut</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Return an object with methods to manipulate this URL’s path segments.</p>
|
||
|
||
<p>Return <code>Err(())</code> if this URl is cannot-be-a-base.</p>
|
||
</div><h4 id='method.set_port' class='method'><code>fn <a href='#method.set_port' class='fnname'>set_port</a>(&mut self, port: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.u16.html'>u16</a>>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s port number.</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>
|
||
</div><h4 id='method.set_host' class='method'><code>fn <a href='#method.set_host' class='fnname'>set_host</a>(&mut self, host: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>ParseError</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s host.</p>
|
||
|
||
<p>If this URL is cannot-be-a-base or there is an error parsing the given <code>host</code>,
|
||
do nothing and return <code>Err</code>.</p>
|
||
|
||
<p>Removing the host (calling this with <code>None</code>)
|
||
will also remove any username, password, and port number.</p>
|
||
</div><h4 id='method.set_ip_host' class='method'><code>fn <a href='#method.set_ip_host' class='fnname'>set_ip_host</a>(&mut self, address: <a class='enum' href='https://doc.rust-lang.org/nightly/std/net/ip/enum.IpAddr.html' title='std::net::ip::IpAddr'>IpAddr</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s 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>
|
||
</div><h4 id='method.set_password' class='method'><code>fn <a href='#method.set_password' class='fnname'>set_password</a>(&mut self, password: <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><&<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s 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>
|
||
</div><h4 id='method.set_username' class='method'><code>fn <a href='#method.set_username' class='fnname'>set_username</a>(&mut self, username: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s 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>
|
||
</div><h4 id='method.set_scheme' class='method'><code>fn <a href='#method.set_scheme' class='fnname'>set_scheme</a>(&mut self, scheme: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Change this URL’s scheme.</p>
|
||
|
||
<p>Do nothing and return <code>Err</code> if:
|
||
* The new scheme is not in <code>[a-zA-Z][a-zA-Z0-9+.-]+</code>
|
||
* 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>, <code>ftp</code>, or <code>gopher</code></p>
|
||
</div><h4 id='method.from_file_path' class='method'><code>fn <a href='#method.from_file_path' class='fnname'>from_file_path</a><P>(path: P) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>> <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a><<a class='struct' href='https://doc.rust-lang.org/nightly/std/path/struct.Path.html' title='std::path::Path'>Path</a>></span></code></h4>
|
||
<div class='docblock'><p>Convert a file name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
|
||
|
||
<p>This returns <code>Err</code> if the given path is not absolute or,
|
||
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>).</p>
|
||
</div><h4 id='method.from_directory_path' class='method'><code>fn <a href='#method.from_directory_path' class='fnname'>from_directory_path</a><P>(path: P) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>> <span class='where'>where P: <a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a><<a class='struct' href='https://doc.rust-lang.org/nightly/std/path/struct.Path.html' title='std::path::Path'>Path</a>></span></code></h4>
|
||
<div class='docblock'><p>Convert a directory name as <code>std::path::Path</code> into an URL in the <code>file</code> scheme.</p>
|
||
|
||
<p>This returns <code>Err</code> if the given path is not absolute or,
|
||
on Windows, if the prefix is not a disk prefix (e.g. <code>C:</code>).</p>
|
||
|
||
<p>Compared to <code>from_file_path</code>, this ensure that URL’s 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>"index.html"</code> parsed with <code>Url::from_directory_path(Path::new("/var/www"))</code>
|
||
as the base URL is <code>file:///var/www/index.html</code></li>
|
||
<li><code>"index.html"</code> parsed with <code>Url::from_file_path(Path::new("/var/www"))</code>
|
||
as the base URL is <code>file:///var/index.html</code>, which might not be what was intended.</li>
|
||
</ul>
|
||
|
||
<p>Note that <code>std::path</code> does not consider trailing slashes significant
|
||
and usually does not include them (e.g. in <code>Path::parent()</code>).</p>
|
||
</div><h4 id='method.to_file_path' class='method'><code>fn <a href='#method.to_file_path' class='fnname'>to_file_path</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html' title='std::path::PathBuf'>PathBuf</a>, <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>></code></h4>
|
||
<div class='docblock'><p>Assuming the URL is in the <code>file</code> scheme or similar,
|
||
convert its path to an absolute <code>std::path::Path</code>.</p>
|
||
|
||
<p><strong>Note:</strong> This does not actually check the URL’s <code>scheme</code>,
|
||
and may give nonsensical results for other schemes.
|
||
It is the user’s responsibility to check the URL’s scheme before calling this.</p>
|
||
|
||
<pre class='rust rust-example-rendered'>
|
||
<span class='kw'>let</span> <span class='ident'>path</span> <span class='op'>=</span> <span class='ident'>url</span>.<span class='ident'>to_file_path</span>();</pre>
|
||
|
||
<p>Returns <code>Err</code> if the host is neither empty nor <code>"localhost"</code>,
|
||
or if <code>Path::new_opt()</code> returns <code>None</code>.
|
||
(That is, if the percent-decoded path contains a NUL byte or,
|
||
for a Windows path, is not UTF-8.)</p>
|
||
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html' title='core::ops::Index'>Index</a><<a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeFull.html' title='core::ops::RangeFull'>RangeFull</a>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='associatedtype.Output' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<h4 id='method.index' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&self, <a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeFull.html' title='core::ops::RangeFull'>RangeFull</a>) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
</div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html' title='core::ops::Index'>Index</a><<a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeFrom.html' title='core::ops::RangeFrom'>RangeFrom</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='associatedtype.Output-1' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<h4 id='method.index-1' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&self, range: <a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeFrom.html' title='core::ops::RangeFrom'>RangeFrom</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
</div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html' title='core::ops::Index'>Index</a><<a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeTo.html' title='core::ops::RangeTo'>RangeTo</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='associatedtype.Output-2' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<h4 id='method.index-2' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&self, range: <a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.RangeTo.html' title='core::ops::RangeTo'>RangeTo</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
</div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html' title='core::ops::Index'>Index</a><<a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.Range.html' title='core::ops::Range'>Range</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='associatedtype.Output-3' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#associatedtype.Output' class='type'>Output</a> = <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<h4 id='method.index-3' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/ops/trait.Index.html#tymethod.index' class='fnname'>index</a>(&self, range: <a class='struct' href='https://doc.rust-lang.org/nightly/core/ops/struct.Range.html' title='core::ops::Range'>Range</a><<a class='enum' href='../url/slicing/enum.Position.html' title='url::slicing::Position'>Position</a>>) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
</div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html' title='core::clone::Clone'>Clone</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='impl-items'><h4 id='method.clone' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></h4>
|
||
<div class='docblock'><p>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></p>
|
||
</div><h4 id='method.clone_from' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: &Self)</code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html' title='std::net::addr::ToSocketAddrs'>ToSocketAddrs</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>Return an error if <code>Url::host</code> or <code>Url::port_or_known_default</code> return <code>None</code>.</p>
|
||
</div><div class='impl-items'><h4 id='associatedtype.Iter' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html#associatedtype.Iter' class='type'>Iter</a> = <a class='struct' href='../url/host/struct.SocketAddrs.html' title='url::host::SocketAddrs'>SocketAddrs</a></code></h4>
|
||
<div class='docblock'><p>Returned iterator over socket addresses which this type may correspond to. <a href="https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html#associatedtype.Iter">Read more</a></p>
|
||
</div><h4 id='method.to_socket_addrs' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html#tymethod.to_socket_addrs' class='fnname'>to_socket_addrs</a>(&self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>::<a class='trait' href='https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html' title='std::net::addr::ToSocketAddrs'>Iter</a>, <a class='struct' href='https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html' title='std::io::error::Error'>Error</a>></code></h4>
|
||
<div class='docblock'><p>Converts this object to an iterator of resolved <code>SocketAddr</code>s. <a href="https://doc.rust-lang.org/nightly/std/net/addr/trait.ToSocketAddrs.html#tymethod.to_socket_addrs">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html' title='core::str::FromStr'>FromStr</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>Parse a string as an URL, without a base URL or encoding override.</p>
|
||
</div><div class='impl-items'><h4 id='associatedtype.Err' class='type'><code>type <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#associatedtype.Err' class='type'>Err</a> = <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>ParseError</a></code></h4>
|
||
<div class='docblock'><p>The associated error which can be returned from parsing.</p>
|
||
</div><h4 id='method.from_str' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str' class='fnname'>from_str</a>(input: &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>ParseError</a>></code></h4>
|
||
<div class='docblock'><p>Parses a string <code>s</code> to return a value of this type. <a href="https://doc.rust-lang.org/nightly/core/str/trait.FromStr.html#tymethod.from_str">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html' title='core::fmt::Display'>Display</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>Display the serialization of this URL.</p>
|
||
</div><div class='impl-items'><h4 id='method.fmt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&self, formatter: &mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>></code></h4>
|
||
<div class='docblock'><p>Formats the value using the given formatter.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html' title='core::fmt::Debug'>Debug</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>Debug the serialization of this URL.</p>
|
||
</div><div class='impl-items'><h4 id='method.fmt-1' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, formatter: &mut <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html' title='core::fmt::Formatter'>Formatter</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>()</a>, <a class='struct' href='https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html' title='core::fmt::Error'>Error</a>></code></h4>
|
||
<div class='docblock'><p>Formats the value using the given formatter.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html' title='core::cmp::Eq'>Eq</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>URLs compare like their serialization.</p>
|
||
</div><div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html' title='core::cmp::PartialEq'>PartialEq</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>URLs compare like their serialization.</p>
|
||
</div><div class='impl-items'><h4 id='method.eq' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&self, other: &<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code></h4>
|
||
<div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p>
|
||
</div><h4 id='method.ne' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, other: &Rhs) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>This method tests for <code>!=</code>.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html' title='core::cmp::Ord'>Ord</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>URLs compare like their serialization.</p>
|
||
</div><div class='impl-items'><h4 id='method.cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&self, other: &<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a></code></h4>
|
||
<div class='docblock'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html' title='core::cmp::PartialOrd'>PartialOrd</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>URLs compare like their serialization.</p>
|
||
</div><div class='impl-items'><h4 id='method.partial_cmp' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&self, other: &<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/option/enum.Option.html' title='core::option::Option'>Option</a><<a class='enum' href='https://doc.rust-lang.org/nightly/core/cmp/enum.Ordering.html' title='core::cmp::Ordering'>Ordering</a>></code></h4>
|
||
<div class='docblock'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p>
|
||
</div><h4 id='method.lt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&self, other: &Rhs) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.lt">Read more</a></p>
|
||
</div><h4 id='method.le' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&self, other: &Rhs) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.le">Read more</a></p>
|
||
</div><h4 id='method.gt' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&self, other: &Rhs) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.gt">Read more</a></p>
|
||
</div><h4 id='method.ge' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&self, other: &Rhs) -> <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.bool.html'>bool</a></code><div class='since' title='Stable since Rust version 1.0.0'>1.0.0</div></h4>
|
||
<div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> operator. <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html#method.ge">Read more</a></p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html' title='core::hash::Hash'>Hash</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>URLs hash like their serialization.</p>
|
||
</div><div class='impl-items'><h4 id='method.hash' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#tymethod.hash' class='fnname'>hash</a><H>(&self, state: &mut H) <span class='where'>where H: <a class='trait' href='https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html' title='core::hash::Hasher'>Hasher</a></span></code></h4>
|
||
<div class='docblock'><p>Feeds this value into the state given, updating the hasher as necessary.</p>
|
||
</div><h4 id='method.hash_slice' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html#method.hash_slice' class='fnname'>hash_slice</a><H>(data: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.slice.html'>&[Self]</a>, state: &mut H) <span class='where'>where H: <a class='trait' href='https://doc.rust-lang.org/nightly/core/hash/trait.Hasher.html' title='core::hash::Hasher'>Hasher</a></span></code><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div></h4>
|
||
<div class='docblock'><p>Feeds a slice of this type into the state provided.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a><<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'></span></h3>
|
||
<div class='docblock'><p>Return the serialization of this URL.</p>
|
||
</div><div class='impl-items'><h4 id='method.as_ref' class='method'><code>fn <a href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref' class='fnname'>as_ref</a>(&self) -> &<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a></code></h4>
|
||
<div class='docblock'><p>Performs the conversion.</p>
|
||
</div></div><h3 class='impl'><span class='in-band'><code>impl <a class='trait' href='../hyper/client/trait.IntoUrl.html' title='hyper::client::IntoUrl'>IntoUrl</a> for <a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a></code></span><span class='out-of-band'><div class='ghost'></div><a id='src-850' class='srclink' href='../src/hyper/client/mod.rs.html#434-438' title='goto source code'>[src]</a></span></h3>
|
||
<div class='impl-items'><h4 id='method.into_url' class='method'><code>fn <a href='../hyper/client/trait.IntoUrl.html#tymethod.into_url' class='fnname'>into_url</a>(self) -> <a class='enum' href='https://doc.rust-lang.org/nightly/core/result/enum.Result.html' title='core::result::Result'>Result</a><<a class='struct' href='../hyper/struct.Url.html' title='hyper::Url'>Url</a>, <a class='enum' href='../url/parser/enum.ParseError.html' title='url::parser::ParseError'>UrlError</a>></code></h4>
|
||
<div class='docblock'><p>Consumes the object, trying to return a Url.</p>
|
||
</div></div></section>
|
||
<section id='search' class="content hidden"></section>
|
||
|
||
<section class="footer"></section>
|
||
|
||
<aside id="help" class="hidden">
|
||
<div>
|
||
<h1 class="hidden">Help</h1>
|
||
|
||
<div class="shortcuts">
|
||
<h2>Keyboard Shortcuts</h2>
|
||
|
||
<dl>
|
||
<dt>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt>+</dt>
|
||
<dd>Collapse/expand all sections</dd>
|
||
</dl>
|
||
</div>
|
||
|
||
<div class="infos">
|
||
<h2>Search Tricks</h2>
|
||
|
||
<p>
|
||
Prefix searches with a type followed by a colon (e.g.
|
||
<code>fn:</code>) to restrict the search to a given type.
|
||
</p>
|
||
|
||
<p>
|
||
Accepted types are: <code>fn</code>, <code>mod</code>,
|
||
<code>struct</code>, <code>enum</code>,
|
||
<code>trait</code>, <code>type</code>, <code>macro</code>,
|
||
and <code>const</code>.
|
||
</p>
|
||
|
||
<p>
|
||
Search functions by type signature (e.g.
|
||
<code>vec -> usize</code> or <code>* -> vec</code>)
|
||
</p>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "hyper";
|
||
window.playgroundUrl = "";
|
||
</script>
|
||
<script src="../jquery.js"></script>
|
||
<script src="../main.js"></script>
|
||
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |