Initial docs commit
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../serde/ser/struct.Impossible.html">
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../serde/ser/struct.Impossible.html">../../../serde/ser/struct.Impossible.html</a>...</p>
|
||||
<script>location.replace("../../../serde/ser/struct.Impossible.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,135 @@
|
||||
<!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="Generic data structure serialization framework."><meta name="keywords" content="rust, rustlang, rust-lang, ser"><title>serde::ser - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc 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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Module ser</p><div class="sidebar-elems"><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div><p class="location"><a href="../index.html">serde</a></p><div id="sidebar-vars" data-name="ser" data-ty="mod" data-relpath="../"></div><script defer src="../sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">serde</a>::<wbr><a class="mod" href="">ser</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1-1964" title="goto source code">[src]</a></span></h1><div class="docblock"><p>Generic data structure serialization framework.</p>
|
||||
<p>The two most important traits in this module are <a href="../trait.Serialize.html"><code>Serialize</code></a> and
|
||||
<a href="../trait.Serializer.html"><code>Serializer</code></a>.</p>
|
||||
<ul>
|
||||
<li><strong>A type that implements <code>Serialize</code> is a data structure</strong> that can be
|
||||
serialized to any data format supported by Serde, and conversely</li>
|
||||
<li><strong>A type that implements <code>Serializer</code> is a data format</strong> that can
|
||||
serialize any data structure supported by Serde.</li>
|
||||
</ul>
|
||||
<h1 id="the-serialize-trait" class="section-header"><a href="#the-serialize-trait">The Serialize trait</a></h1>
|
||||
<p>Serde provides <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for many Rust primitive and
|
||||
standard library types. The complete list is below. All of these can be
|
||||
serialized using Serde out of the box.</p>
|
||||
<p>Additionally, Serde provides a procedural macro called <a href="https://crates.io/crates/serde_derive"><code>serde_derive</code></a> to
|
||||
automatically generate <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for structs and enums
|
||||
in your program. See the <a href="https://serde.rs/derive.html">derive section of the manual</a> for how to use this.</p>
|
||||
<p>In rare cases it may be necessary to implement <a href="../trait.Serialize.html"><code>Serialize</code></a> manually for
|
||||
some type in your program. See the <a href="https://serde.rs/impl-serialize.html">Implementing <code>Serialize</code></a> section of the
|
||||
manual for more about this.</p>
|
||||
<p>Third-party crates may provide <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for types that
|
||||
they expose. For example the <a href="https://crates.io/crates/linked-hash-map"><code>linked-hash-map</code></a> crate provides a
|
||||
<a href="https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html"><code>LinkedHashMap<K, V></code></a> type that is serializable by Serde because the crate
|
||||
provides an implementation of <a href="../trait.Serialize.html"><code>Serialize</code></a> for it.</p>
|
||||
<h1 id="the-serializer-trait" class="section-header"><a href="#the-serializer-trait">The Serializer trait</a></h1>
|
||||
<p><a href="../trait.Serializer.html"><code>Serializer</code></a> implementations are provided by third-party crates, for
|
||||
example <a href="https://github.com/serde-rs/json"><code>serde_json</code></a>, <a href="https://github.com/dtolnay/serde-yaml"><code>serde_yaml</code></a> and <a href="https://github.com/servo/bincode"><code>bincode</code></a>.</p>
|
||||
<p>A partial list of well-maintained formats is given on the <a href="https://serde.rs/#data-formats">Serde
|
||||
website</a>.</p>
|
||||
<h1 id="implementations-of-serialize-provided-by-serde" class="section-header"><a href="#implementations-of-serialize-provided-by-serde">Implementations of Serialize provided by Serde</a></h1>
|
||||
<ul>
|
||||
<li><strong>Primitive types</strong>:
|
||||
<ul>
|
||||
<li>bool</li>
|
||||
<li>i8, i16, i32, i64, i128, isize</li>
|
||||
<li>u8, u16, u32, u64, u128, usize</li>
|
||||
<li>f32, f64</li>
|
||||
<li>char</li>
|
||||
<li>str</li>
|
||||
<li>&T and &mut T</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Compound types</strong>:
|
||||
<ul>
|
||||
<li>[T]</li>
|
||||
<li>[T; 0] through [T; 32]</li>
|
||||
<li>tuples up to size 16</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Common standard library types</strong>:
|
||||
<ul>
|
||||
<li>String</li>
|
||||
<li>Option<T></li>
|
||||
<li>Result<T, E></li>
|
||||
<li>PhantomData<T></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Wrapper types</strong>:
|
||||
<ul>
|
||||
<li>Box<T></li>
|
||||
<li>Cow<’a, T></li>
|
||||
<li>Cell<T></li>
|
||||
<li>RefCell<T></li>
|
||||
<li>Mutex<T></li>
|
||||
<li>RwLock<T></li>
|
||||
<li>Rc<T> <em>(if</em> features = [“rc”] <em>is enabled)</em></li>
|
||||
<li>Arc<T> <em>(if</em> features = [“rc”] <em>is enabled)</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Collection types</strong>:
|
||||
<ul>
|
||||
<li>BTreeMap<K, V></li>
|
||||
<li>BTreeSet<T></li>
|
||||
<li>BinaryHeap<T></li>
|
||||
<li>HashMap<K, V, H></li>
|
||||
<li>HashSet<T, H></li>
|
||||
<li>LinkedList<T></li>
|
||||
<li>VecDeque<T></li>
|
||||
<li>Vec<T></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>FFI types</strong>:
|
||||
<ul>
|
||||
<li>CStr</li>
|
||||
<li>CString</li>
|
||||
<li>OsStr</li>
|
||||
<li>OsString</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Miscellaneous standard library types</strong>:
|
||||
<ul>
|
||||
<li>Duration</li>
|
||||
<li>SystemTime</li>
|
||||
<li>Path</li>
|
||||
<li>PathBuf</li>
|
||||
<li>Range<T></li>
|
||||
<li>RangeInclusive<T></li>
|
||||
<li>Bound<T></li>
|
||||
<li>num::NonZero*</li>
|
||||
<li><code>!</code> <em>(unstable)</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Net types</strong>:
|
||||
<ul>
|
||||
<li>IpAddr</li>
|
||||
<li>Ipv4Addr</li>
|
||||
<li>Ipv6Addr</li>
|
||||
<li>SocketAddr</li>
|
||||
<li>SocketAddrV4</li>
|
||||
<li>SocketAddrV6</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div><h2 id="reexports" class="section-header"><a href="#reexports">Re-exports</a></h2>
|
||||
<table><tr><td><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">Error</a> as StdError;</code></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.Impossible.html" title="serde::ser::Impossible struct">Impossible</a></td><td class="docblock-short"><p>Helper type for implementing a <code>Serializer</code> that does not support
|
||||
serializing one of the compound types.</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.Error.html" title="serde::ser::Error trait">Error</a></td><td class="docblock-short"><p>Trait used by <code>Serialize</code> implementations to generically construct
|
||||
errors belonging to the <code>Serializer</code> against which they are
|
||||
currently running.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.Serialize.html" title="serde::ser::Serialize trait">Serialize</a></td><td class="docblock-short"><p>A <strong>data structure</strong> that can be serialized into any data format supported
|
||||
by Serde.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeMap.html" title="serde::ser::SerializeMap trait">SerializeMap</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_map</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeSeq.html" title="serde::ser::SerializeSeq trait">SerializeSeq</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeStruct.html" title="serde::ser::SerializeStruct trait">SerializeStruct</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeStructVariant.html" title="serde::ser::SerializeStructVariant trait">SerializeStructVariant</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeTuple.html" title="serde::ser::SerializeTuple trait">SerializeTuple</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeTupleStruct.html" title="serde::ser::SerializeTupleStruct trait">SerializeTupleStruct</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.SerializeTupleVariant.html" title="serde::ser::SerializeTupleVariant trait">SerializeTupleVariant</a></td><td class="docblock-short"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
|
||||
</td></tr><tr class="module-item"><td><a class="trait" href="trait.Serializer.html" title="serde::ser::Serializer trait">Serializer</a></td><td class="docblock-short"><p>A <strong>data format</strong> that can serialize any data structure supported by Serde.</p>
|
||||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1 @@
|
||||
initSidebarItems({"struct":[["Impossible","Helper type for implementing a `Serializer` that does not support serializing one of the compound types."]],"trait":[["Error","Trait used by `Serialize` implementations to generically construct errors belonging to the `Serializer` against which they are currently running."],["Serialize","A data structure that can be serialized into any data format supported by Serde."],["SerializeMap","Returned from `Serializer::serialize_map`."],["SerializeSeq","Returned from `Serializer::serialize_seq`."],["SerializeStruct","Returned from `Serializer::serialize_struct`."],["SerializeStructVariant","Returned from `Serializer::serialize_struct_variant`."],["SerializeTuple","Returned from `Serializer::serialize_tuple`."],["SerializeTupleStruct","Returned from `Serializer::serialize_tuple_struct`."],["SerializeTupleVariant","Returned from `Serializer::serialize_tuple_variant`."],["Serializer","A data format that can serialize any data structure supported by Serde."]]});
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,34 @@
|
||||
<!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="Trait used by `Serialize` implementations to generically construct errors belonging to the `Serializer` against which they are currently running."><meta name="keywords" content="rust, rustlang, rust-lang, Error"><title>serde::ser::Error - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait Error</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.custom">custom</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-Error-for-Error">Error</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="Error" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">Error</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 class="srclink" href="../../src/serde/ser/mod.rs.html#183" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait Error: <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/std/error/trait.Error.html" title="trait std::error::Error">StdError</a> {
|
||||
fn <a href="#tymethod.custom" class="fnname">custom</a><T>(msg: T) -> Self<br> <span class="where">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></span>;
|
||||
}</pre></div><div class="docblock"><p>Trait used by <code>Serialize</code> implementations to generically construct
|
||||
errors belonging to the <code>Serializer</code> against which they are
|
||||
currently running.</p>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website shows an error
|
||||
type appropriate for a basic JSON data format.</p>
|
||||
</div><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.custom" class="method"><code>fn <a href="#tymethod.custom" class="fnname">custom</a><T>(msg: T) -> Self <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#183" title="goto source code">[src]</a></h3><div class="docblock"><p>Used when a <a href="../trait.Serialize.html"><code>Serialize</code></a> implementation encounters any error
|
||||
while serializing a type.</p>
|
||||
<p>The message should not be capitalized and should not end with a
|
||||
period.</p>
|
||||
<p>For example, a filesystem <a href="https://doc.rust-lang.org/std/path/struct.Path.html"><code>Path</code></a> may refuse to serialize
|
||||
itself if it contains invalid UTF-8 data.</p>
|
||||
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="self">self</span>, <span class="ident">Serialize</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Path</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">to_str</span>() {
|
||||
<span class="prelude-val">Some</span>(<span class="ident">s</span>) <span class="op">=</span><span class="op">></span> <span class="ident">serializer</span>.<span class="ident">serialize_str</span>(<span class="ident">s</span>),
|
||||
<span class="prelude-val">None</span> <span class="op">=</span><span class="op">></span> <span class="prelude-val">Err</span>(<span class="ident">ser</span>::<span class="ident">Error</span>::<span class="ident">custom</span>(<span class="string">"path contains invalid UTF-8 characters"</span>)),
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><h3 id="impl-Error-for-Error" class="impl"><code class="in-band">impl <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a> for <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a></code><a href="#impl-Error-for-Error" class="anchor"></a><a class="srclink" href="../../src/serde/ser/fmt.rs.html#4-8" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.custom" class="method hidden"><code>fn <a href="#method.custom" class="fnname">custom</a><T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>>(_msg: T) -> Self</code><a class="srclink" href="../../src/serde/ser/fmt.rs.html#5-7" title="goto source code">[src]</a></h4></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-Error" class="impl"><code class="in-band">impl <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a> for serde::de::value::<a class="struct" href="../../serde/de/value/struct.Error.html" title="struct serde::de::value::Error">Error</a></code><a href="#impl-Error" class="anchor"></a><a class="srclink" href="../../src/serde/de/value.rs.html#84-92" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="method.custom-1" class="method hidden"><code>fn <a href="#method.custom-1" class="fnname">custom</a><T>(msg: T) -> Self <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>, </span></code><a class="srclink" href="../../src/serde/de/value.rs.html#86-91" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.Error.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
@@ -0,0 +1,61 @@
|
||||
<!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="Returned from `Serializer::serialize_map`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeMap"><title>serde::ser::SerializeMap - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeMap</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_key">serialize_key</a><a href="#tymethod.serialize_value">serialize_value</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.serialize_entry">serialize_entry</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeMap" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeMap</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1769-1828" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeMap {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>>;
|
||||
|
||||
fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a><K: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>V<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> K: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br> V: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>,
|
||||
{ ... }
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_map</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeMap</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">HashMap</span><span class="op"><</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">K</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">V</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">map</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_map</span>(<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="ident">len</span>()))<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> (<span class="ident">k</span>, <span class="ident">v</span>) <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">map</span>.<span class="ident">serialize_entry</span>(<span class="ident">k</span>, <span class="ident">v</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">map</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeMap</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1771" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1774" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_key" class="method"><code>fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1782-1784" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a map key.</p>
|
||||
<p>If possible, <code>Serialize</code> implementations are encouraged to use
|
||||
<code>serialize_entry</code> instead as it may be implemented more efficiently in
|
||||
some formats compared to a pair of calls to <code>serialize_key</code> and
|
||||
<code>serialize_value</code>.</p>
|
||||
</div><h3 id="tymethod.serialize_value" class="method"><code>fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1792-1794" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a map value.</p>
|
||||
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
||||
<p>Calling <code>serialize_value</code> before <code>serialize_key</code> is incorrect and is
|
||||
allowed to panic or produce bogus results.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1827" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a map.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.serialize_entry" class="method"><code>fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a><K: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>K, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>V<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> K: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br> V: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1813-1824" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a map entry consisting of a key and a value.</p>
|
||||
<p>Some <a href="../trait.Serialize.html"><code>Serialize</code></a> types are not able to hold a key and value in memory
|
||||
at the same time so <code>SerializeMap</code> implementations are required to
|
||||
support <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and <a href="#tymethod.serialize_value"><code>serialize_value</code></a> individually. The
|
||||
<code>serialize_entry</code> method allows serializers to optimize for the case
|
||||
where key and value are both available. <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations
|
||||
are encouraged to use <code>serialize_entry</code> if possible.</p>
|
||||
<p>The default implementation delegates to <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and
|
||||
<a href="#tymethod.serialize_value"><code>serialize_value</code></a>. This is appropriate for serializers that do not
|
||||
care about performance or are not able to optimize <code>serialize_entry</code> any
|
||||
better than this.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeMap" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeMap.html" title="trait serde::ser::SerializeMap">SerializeMap</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeMap" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#148-174" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_key" class="method hidden"><code>fn <a href="#method.serialize_key" class="fnname">serialize_key</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#155-161" title="goto source code">[src]</a></h4><h4 id="method.serialize_value" class="method hidden"><code>fn <a href="#method.serialize_value" class="fnname">serialize_value</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#163-169" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#171-173" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeMap.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,37 @@
|
||||
<!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="Returned from `Serializer::serialize_seq`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeSeq"><title>serde::ser::SerializeSeq - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeSeq</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_element">serialize_element</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeSeq" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeSeq</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1500-1514" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeSeq {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>>;
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeSeq</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Vec</span><span class="op"><</span><span class="ident">T</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">T</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">seq</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_seq</span>(<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="ident">len</span>()))<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> <span class="ident">element</span> <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">seq</span>.<span class="ident">serialize_element</span>(<span class="ident">element</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">seq</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeSeq</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1502" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1505" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_element" class="method"><code>fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1508-1510" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a sequence element.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1513" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a sequence.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeSeq" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeSeq.html" title="trait serde::ser::SerializeSeq">SerializeSeq</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeSeq" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#68-86" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_element" class="method hidden"><code>fn <a href="#method.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#75-81" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#83-85" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeSeq.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,43 @@
|
||||
<!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="Returned from `Serializer::serialize_struct`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeStruct"><title>serde::ser::SerializeStruct - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeStruct</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_field">serialize_field</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.skip_field">skip_field</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeStruct" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeStruct</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1863-1888" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeStruct {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>>;
|
||||
|
||||
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <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="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>> { ... }
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeStruct</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">struct</span> <span class="ident">Rgb</span> {
|
||||
<span class="ident">r</span>: <span class="ident">u8</span>,
|
||||
<span class="ident">g</span>: <span class="ident">u8</span>,
|
||||
<span class="ident">b</span>: <span class="ident">u8</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Rgb</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rgb</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_struct</span>(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"r"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">r</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"g"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">g</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"b"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeStruct</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1865" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1868" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_field" class="method"><code>fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1871-1877" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a struct field.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1887" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a struct.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.skip_field" class="method"><code>fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <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="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1881-1884" title="goto source code">[src]</a></h3><div class="docblock"><p>Indicate that a struct field has been skipped.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeStruct" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeStruct.html" title="trait serde::ser::SerializeStruct">SerializeStruct</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeStruct" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#176-195" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_field" class="method hidden"><code>fn <a href="#method.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#183-190" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#192-194" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStruct.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,49 @@
|
||||
<!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="Returned from `Serializer::serialize_struct_variant`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeStructVariant"><title>serde::ser::SerializeStructVariant - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeStructVariant</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_field">serialize_field</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.skip_field">skip_field</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeStructVariant" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeStructVariant</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1929-1954" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeStructVariant {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>>;
|
||||
|
||||
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <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="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>> { ... }
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeStructVariant</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">enum</span> <span class="ident">E</span> {
|
||||
<span class="ident">S</span> { <span class="ident">r</span>: <span class="ident">u8</span>, <span class="ident">g</span>: <span class="ident">u8</span>, <span class="ident">b</span>: <span class="ident">u8</span> },
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">E</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
|
||||
<span class="ident">E</span>::<span class="ident">S</span> {
|
||||
<span class="kw-2">ref</span> <span class="ident">r</span>,
|
||||
<span class="kw-2">ref</span> <span class="ident">g</span>,
|
||||
<span class="kw-2">ref</span> <span class="ident">b</span>,
|
||||
} <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">sv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_struct_variant</span>(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"S"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"r"</span>, <span class="ident">r</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"g"</span>, <span class="ident">g</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"b"</span>, <span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeStructVariant</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1931" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1934" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_field" class="method"><code>fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1937-1943" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a struct variant field.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1953" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a struct variant.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><h3 id="method.skip_field" class="method"><code>fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <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="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1947-1950" title="goto source code">[src]</a></h3><div class="docblock"><p>Indicate that a struct variant field has been skipped.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeStructVariant" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeStructVariant.html" title="trait serde::ser::SerializeStructVariant">SerializeStructVariant</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeStructVariant" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#197-216" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_field" class="method hidden"><code>fn <a href="#method.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#204-211" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#213-215" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStructVariant.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,58 @@
|
||||
<!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="Returned from `Serializer::serialize_tuple`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTuple"><title>serde::ser::SerializeTuple - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeTuple</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_element">serialize_element</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeTuple" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeTuple</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1600-1614" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeTuple {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>>;
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeTuple</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">A</span>, <span class="ident">B</span>, <span class="ident">C</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> (<span class="ident">A</span>, <span class="ident">B</span>, <span class="ident">C</span>)
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">A</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">B</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">C</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tup</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple</span>(<span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeTuple</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> [<span class="ident">T</span>; <span class="number">16</span>]
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">T</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">seq</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple</span>(<span class="number">16</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> <span class="ident">element</span> <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">seq</span>.<span class="ident">serialize_element</span>(<span class="ident">element</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">seq</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTuple</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1602" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1605" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_element" class="method"><code>fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1608-1610" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a tuple element.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1613" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a tuple.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeTuple" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeTuple.html" title="trait serde::ser::SerializeTuple">SerializeTuple</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeTuple" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#88-106" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_element" class="method hidden"><code>fn <a href="#method.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#95-101" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#103-105" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTuple.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,36 @@
|
||||
<!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="Returned from `Serializer::serialize_tuple_struct`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTupleStruct"><title>serde::ser::SerializeTupleStruct - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeTupleStruct</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_field">serialize_field</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeTupleStruct" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeTupleStruct</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1645-1659" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeTupleStruct {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>>;
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeTupleStruct</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">struct</span> <span class="ident">Rgb</span>(<span class="ident">u8</span>, <span class="ident">u8</span>, <span class="ident">u8</span>);
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Rgb</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">ts</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_struct</span>(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTupleStruct</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1647" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1650" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_field" class="method"><code>fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1653-1655" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a tuple struct field.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1658" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a tuple struct.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeTupleStruct" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeTupleStruct.html" title="trait serde::ser::SerializeTupleStruct">SerializeTupleStruct</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeTupleStruct" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#108-126" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_field" class="method hidden"><code>fn <a href="#method.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#115-121" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#123-125" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleStruct.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
@@ -0,0 +1,49 @@
|
||||
<!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="Returned from `Serializer::serialize_tuple_variant`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTupleVariant"><title>serde::ser::SerializeTupleVariant - Rust</title><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled ><script id="default-settings"></script><script src="../../storage.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../../favicon.svg">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-16x16.png">
|
||||
<link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[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">☰</div><a href='../../serde/index.html'><div class='logo-container rust-logo'><img src='../../rust-logo.png' alt='logo'></div></a><p class="location">Trait SerializeTupleVariant</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Error">Error</a><a href="#associatedtype.Ok">Ok</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.end">end</a><a href="#tymethod.serialize_field">serialize_field</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></p><div id="sidebar-vars" data-name="SerializeTupleVariant" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||||
<a id="settings-menu" href="../../settings.html"><img src="../../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="">SerializeTupleVariant</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 class="srclink" href="../../src/serde/ser/mod.rs.html#1703-1717" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait SerializeTupleVariant {
|
||||
type <a href="#associatedtype.Ok" class="type">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self, <br> value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<div class="item-spacer"></div> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>>;
|
||||
}</pre></div><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
|
||||
<h1 id="example-use" class="section-header"><a href="#example-use">Example use</a></h1>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition">
|
||||
<span class="kw">use</span> <span class="ident">serde</span>::<span class="ident">ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeTupleVariant</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">enum</span> <span class="ident">E</span> {
|
||||
<span class="ident">T</span>(<span class="ident">u8</span>, <span class="ident">u8</span>),
|
||||
<span class="ident">U</span>(<span class="ident">String</span>, <span class="ident">u32</span>, <span class="ident">u32</span>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">E</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) <span class="op">-</span><span class="op">></span> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S</span>::<span class="prelude-val">Ok</span>, <span class="ident">S</span>::<span class="ident">Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
|
||||
<span class="ident">E</span>::<span class="ident">T</span>(<span class="kw-2">ref</span> <span class="ident">a</span>, <span class="kw-2">ref</span> <span class="ident">b</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_variant</span>(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"T"</span>, <span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">a</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
<span class="ident">E</span>::<span class="ident">U</span>(<span class="kw-2">ref</span> <span class="ident">a</span>, <span class="kw-2">ref</span> <span class="ident">b</span>, <span class="kw-2">ref</span> <span class="ident">c</span>) <span class="op">=</span><span class="op">></span> {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_variant</span>(<span class="string">"E"</span>, <span class="number">1</span>, <span class="string">"U"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">a</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">c</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}</pre></div>
|
||||
<h1 id="example-implementation" class="section-header"><a href="#example-implementation">Example implementation</a></h1>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTupleVariant</code> for a basic JSON data format.</p>
|
||||
</div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Ok" class="method"><code>type <a href="#associatedtype.Ok" class="type">Ok</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1705" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div><h3 id="associatedtype.Error" class="method"><code>type <a href="#associatedtype.Error" class="type">Error</a>: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1708" title="goto source code">[src]</a></h3><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.serialize_field" class="method"><code>fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1711-1713" title="goto source code">[src]</a></h3><div class="docblock"><p>Serialize a tuple variant field.</p>
|
||||
</div><h3 id="tymethod.end" class="method"><code>fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="type" href="../../serde/ser/trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>></code><a class="srclink" href="../../src/serde/ser/mod.rs.html#1716" title="goto source code">[src]</a></h3><div class="docblock"><p>Finish serializing a tuple variant.</p>
|
||||
</div></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><h3 id="impl-SerializeTupleVariant" class="impl"><code class="in-band">impl<Ok, Error> <a class="trait" href="../../serde/ser/trait.SerializeTupleVariant.html" title="trait serde::ser::SerializeTupleVariant">SerializeTupleVariant</a> for <a class="struct" href="../../serde/ser/struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error> <span class="where fmt-newline">where<br> Error: <a class="trait" href="../../serde/ser/trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></code><a href="#impl-SerializeTupleVariant" class="anchor"></a><a class="srclink" href="../../src/serde/ser/impossible.rs.html#128-146" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Ok-1" class="type"><code>type <a href="#associatedtype.Ok-1" class="type">Ok</a> = Ok</code></h4><h4 id="associatedtype.Error-1" class="type"><code>type <a href="#associatedtype.Error-1" class="type">Error</a> = Error</code></h4><h4 id="method.serialize_field" class="method hidden"><code>fn <a href="#method.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, Error> <span class="where fmt-newline">where<br> T: <a class="trait" href="../../serde/trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#135-141" title="goto source code">[src]</a></h4><h4 id="method.end" class="method hidden"><code>fn <a href="#method.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Ok, Error></code><a class="srclink" href="../../src/serde/ser/impossible.rs.html#143-145" title="goto source code">[src]</a></h4></div></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleVariant.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde"></div>
|
||||
<script src="../../main.js"></script><script defer src="../../search-index.js"></script></body></html>
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user