mentat/percent_encoding/index.html

257 lines
13 KiB
HTML
Raw Permalink Normal View History

2018-08-22 17:04:13 +00:00
<!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 `percent_encoding` crate.">
<meta name="keywords" content="rust, rustlang, rust-lang, percent_encoding">
<title>percent_encoding - Rust</title>
<link rel="stylesheet" type="text/css" href="../normalize.css">
<link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle">
<link rel="stylesheet" type="text/css" href="../dark.css">
<link rel="stylesheet" type="text/css" href="../main.css" id="themeStyle">
<script src="../storage.js"></script>
</head>
<body class="rustdoc mod">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
<p class='location'>Crate percent_encoding</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#functions">Functions</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'percent_encoding', ty: 'mod', relpath: '../'};</script></div>
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="../brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="../theme.js"></script>
<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">
<h1 class='fqn'><span class='in-band'>Crate <a class="mod" href=''>percent_encoding</a></span><span class='out-of-band'><span id='render-detail'>
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
[<span class='inner'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/percent_encoding/lib.rs.html#9-440' title='goto source code'>[src]</a></span></h1>
<div class='docblock'><p>URLs use special chacters to indicate the parts of the request. For example, a forward slash
indicates a path. In order for that charcter to exist outside of a path separator, that
charcter would need to be encoded.</p>
<p>Percent encoding replaces reserved charcters with the <code>%</code> escape charcter followed by hexidecimal
ASCII representaton. For non-ASCII charcters that are percent encoded, a UTF-8 byte sequence
becomes percent encoded. A simple example can be seen when the space literal is replaced with
<code>%20</code>.</p>
<p>Percent encoding is further complicated by the fact that different parts of an URL have
different encoding requirements. In order to support the variety of encoding requirements,
<code>url::percent_encoding</code> includes different <em>encode sets</em>.
See <a href="https://url.spec.whatwg.org/#percent-encoded-bytes">URL Standard</a> for details.</p>
<p>This module provides some <code>*_ENCODE_SET</code> constants.
If a different set is required, it can be created with
the <a href="../macro.define_encode_set!.html"><code>define_encode_set!</code></a> macro.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">url</span>::<span class="ident">percent_encoding</span>::{<span class="ident">utf8_percent_encode</span>, <span class="ident">DEFAULT_ENCODE_SET</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">utf8_percent_encode</span>(<span class="string">&quot;foo bar?&quot;</span>, <span class="ident">DEFAULT_ENCODE_SET</span>).<span class="ident">to_string</span>(), <span class="string">&quot;foo%20bar%3F&quot;</span>);</pre>
</div><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
<table>
<tr class=' module-item'>
<td><a class="macro" href="macro.define_encode_set.html"
title='macro percent_encoding::define_encode_set'>define_encode_set</a></td>
<td class='docblock-short'>
<p>Define a new struct
that implements the <a href="percent_encoding/trait.EncodeSet.html"><code>EncodeSet</code></a> trait,
for use in <a href="percent_encoding/fn.percent_encode.html"><code>percent_decode()</code></a>
and related functions.</p>
</td>
</tr></table><h2 id='structs' class='section-header'><a href="#structs">Structs</a></h2>
<table>
<tr class=' module-item'>
<td><a class="struct" href="struct.DEFAULT_ENCODE_SET.html"
title='struct percent_encoding::DEFAULT_ENCODE_SET'>DEFAULT_ENCODE_SET</a></td>
<td class='docblock-short'>
<p>This encode set is used for path components.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.PATH_SEGMENT_ENCODE_SET.html"
title='struct percent_encoding::PATH_SEGMENT_ENCODE_SET'>PATH_SEGMENT_ENCODE_SET</a></td>
<td class='docblock-short'>
<p>This encode set is used for on '/'-separated path segment</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.PercentDecode.html"
title='struct percent_encoding::PercentDecode'>PercentDecode</a></td>
<td class='docblock-short'>
<p>The return type of <code>percent_decode()</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.PercentEncode.html"
title='struct percent_encoding::PercentEncode'>PercentEncode</a></td>
<td class='docblock-short'>
<p>The return type of <code>percent_encode()</code> and <code>utf8_percent_encode()</code>.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.QUERY_ENCODE_SET.html"
title='struct percent_encoding::QUERY_ENCODE_SET'>QUERY_ENCODE_SET</a></td>
<td class='docblock-short'>
<p>This encode set is used in the URL parser for query strings.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.SIMPLE_ENCODE_SET.html"
title='struct percent_encoding::SIMPLE_ENCODE_SET'>SIMPLE_ENCODE_SET</a></td>
<td class='docblock-short'>
<p>This encode set is used for the path of cannot-be-a-base URLs.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="struct" href="struct.USERINFO_ENCODE_SET.html"
title='struct percent_encoding::USERINFO_ENCODE_SET'>USERINFO_ENCODE_SET</a></td>
<td class='docblock-short'>
<p>This encode set is used for username and password.</p>
</td>
</tr></table><h2 id='traits' class='section-header'><a href="#traits">Traits</a></h2>
<table>
<tr class=' module-item'>
<td><a class="trait" href="trait.EncodeSet.html"
title='trait percent_encoding::EncodeSet'>EncodeSet</a></td>
<td class='docblock-short'>
<p>Represents a set of characters / bytes that should be percent-encoded.</p>
</td>
</tr></table><h2 id='functions' class='section-header'><a href="#functions">Functions</a></h2>
<table>
<tr class=' module-item'>
<td><a class="fn" href="fn.percent_decode.html"
title='fn percent_encoding::percent_decode'>percent_decode</a></td>
<td class='docblock-short'>
<p>Percent-decode the given bytes.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.percent_encode.html"
title='fn percent_encoding::percent_encode'>percent_encode</a></td>
<td class='docblock-short'>
<p>Percent-encode the given bytes with the given encode set.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.percent_encode_byte.html"
title='fn percent_encoding::percent_encode_byte'>percent_encode_byte</a></td>
<td class='docblock-short'>
<p>Return the percent-encoding of the given bytes.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class="fn" href="fn.utf8_percent_encode.html"
title='fn percent_encoding::utf8_percent_encode'>utf8_percent_encode</a></td>
<td class='docblock-short'>
<p>Percent-encode the UTF-8 encoding of the given string.</p>
</td>
</tr></table></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><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse 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 = "percent_encoding";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>