juniper/url/form_urlencoded/struct.Serializer.html

157 lines
9.3 KiB
HTML
Raw Normal View History

2016-09-11 13:41:24 -05: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 `Serializer` struct in crate `url`.">
<meta name="keywords" content="rust, rustlang, rust-lang, Serializer">
<title>url::form_urlencoded::Serializer - 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'>url</a>::<wbr><a href='index.html'>form_urlencoded</a></p><script>window.sidebarCurrent = {name: 'Serializer', 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'>url</a>::<wbr><a href='index.html'>form_urlencoded</a>::<wbr><a class='struct' href=''>Serializer</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 id='src-1338' class='srclink' href='../../src/url/form_urlencoded.rs.html#210-214' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Serializer&lt;T:&nbsp;<a class='trait' href='../../url/form_urlencoded/trait.Target.html' title='url::form_urlencoded::Target'>Target</a>&gt; {
// some fields omitted
}</pre><div class='docblock'><p>The <a href="https://url.spec.whatwg.org/#concept-urlencoded-serializer"><code>application/x-www-form-urlencoded</code> serializer</a>.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl&lt;T:&nbsp;<a class='trait' href='../../url/form_urlencoded/trait.Target.html' title='url::form_urlencoded::Target'>Target</a>&gt; <a class='struct' href='../../url/form_urlencoded/struct.Serializer.html' title='url::form_urlencoded::Serializer'>Serializer</a>&lt;T&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a id='src-1369' class='srclink' href='../../src/url/form_urlencoded.rs.html#250-346' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.new' class='method'><code>fn <a href='#method.new' class='fnname'>new</a>(target: T) -&gt; Self</code></h4>
<div class='docblock'><p>Create a new <code>application/x-www-form-urlencoded</code> serializer for the given target.</p>
<p>If the target is non-empty,
its content is assumed to already be in <code>application/x-www-form-urlencoded</code> syntax.</p>
</div><h4 id='method.for_suffix' class='method'><code>fn <a href='#method.for_suffix' class='fnname'>for_suffix</a>(target: T, start_position: <a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.usize.html'>usize</a>) -&gt; Self</code></h4>
<div class='docblock'><p>Create a new <code>application/x-www-form-urlencoded</code> serializer
for a suffix of the given target.</p>
<p>If that suffix is non-empty,
its content is assumed to already be in <code>application/x-www-form-urlencoded</code> syntax.</p>
</div><h4 id='method.clear' class='method'><code>fn <a href='#method.clear' class='fnname'>clear</a>(&amp;mut self) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Remove any existing name/value pair.</p>
<p>Panics if called after <code>.finish()</code>.</p>
</div><h4 id='method.append_pair' class='method'><code>fn <a href='#method.append_pair' class='fnname'>append_pair</a>(&amp;mut self, name: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>, value: &amp;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>) -&gt; &amp;mut Self</code></h4>
<div class='docblock'><p>Serialize and append a name/value pair.</p>
<p>Panics if called after <code>.finish()</code>.</p>
</div><h4 id='method.extend_pairs' class='method'><code>fn <a href='#method.extend_pairs' class='fnname'>extend_pairs</a>&lt;I,&nbsp;K,&nbsp;V&gt;(&amp;mut self, iter: I) -&gt; &amp;mut Self <span class='where'>where I: <a class='trait' href='https://doc.rust-lang.org/nightly/core/iter/traits/trait.IntoIterator.html' title='core::iter::traits::IntoIterator'>IntoIterator</a>, I::Item: <a class='trait' href='https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html' title='core::borrow::Borrow'>Borrow</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>(</a>K, V<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.tuple.html'>)</a>&gt;, K: <a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;, V: <a class='trait' href='https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html' title='core::convert::AsRef'>AsRef</a>&lt;<a class='primitive' href='https://doc.rust-lang.org/nightly/std/primitive.str.html'>str</a>&gt;</span></code></h4>
<div class='docblock'><p>Serialize and append a number of name/value pairs.</p>
<p>This simply calls <code>append_pair</code> repeatedly.
This can be more convenient, so the user doesnt need to introduce a block
to limit the scope of <code>Serializer</code>s borrow of its string.</p>
<p>Panics if called after <code>.finish()</code>.</p>
</div><h4 id='method.finish' class='method'><code>fn <a href='#method.finish' class='fnname'>finish</a>(&amp;mut self) -&gt; T::Finished</code></h4>
<div class='docblock'><p>If this serializer was constructed with a string, take and return that string.</p>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>url</span>::<span class='ident'>form_urlencoded</span>;
<span class='kw'>let</span> <span class='ident'>encoded</span>: <span class='ident'>String</span> <span class='op'>=</span> <span class='ident'>form_urlencoded</span>::<span class='ident'>Serializer</span>::<span class='ident'>new</span>(<span class='ident'>String</span>::<span class='ident'>new</span>())
.<span class='ident'>append_pair</span>(<span class='string'>&quot;foo&quot;</span>, <span class='string'>&quot;bar &amp; baz&quot;</span>)
.<span class='ident'>append_pair</span>(<span class='string'>&quot;saison&quot;</span>, <span class='string'>&quot;Été+hiver&quot;</span>)
.<span class='ident'>finish</span>();
<span class='macro'>assert_eq</span><span class='macro'>!</span>(<span class='ident'>encoded</span>, <span class='string'>&quot;foo=bar+%26+baz&amp;saison=%C3%89t%C3%A9%2Bhiver&quot;</span>);</pre>
<p>Panics if called more than once.</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>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</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 = "url";
window.playgroundUrl = "";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>