Now a REAL lib

This commit is contained in:
Justine
2023-01-09 19:23:20 +01:00
parent ef46613c71
commit fe9e6f04f5
19014 changed files with 715877 additions and 264 deletions

1
doc/serde/all.html Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../serde/de/struct.IgnoredAny.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="../../../serde/de/struct.IgnoredAny.html">../../../serde/de/struct.IgnoredAny.html</a>...</p>
<script>location.replace("../../../serde/de/struct.IgnoredAny.html" + location.search + location.hash);</script>
</body>
</html>

148
doc/serde/de/index.html Normal file
View File

@ -0,0 +1,148 @@
<!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 deserialization framework."><meta name="keywords" content="rust, rustlang, rust-lang, de"><title>serde::de - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module de</a></h2><div class="sidebar-elems"><section><div class="block"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#traits">Traits</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">serde</a>::<wbr><a class="mod" href="#">de</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/de/mod.rs.html#1-2299">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Generic data structure deserialization framework.</p>
<p>The two most important traits in this module are <a href="../trait.Deserialize.html"><code>Deserialize</code></a> and
<a href="../trait.Deserializer.html"><code>Deserializer</code></a>.</p>
<ul>
<li><strong>A type that implements <code>Deserialize</code> is a data structure</strong> that can be
deserialized from any data format supported by Serde, and conversely</li>
<li><strong>A type that implements <code>Deserializer</code> is a data format</strong> that can
deserialize any data structure supported by Serde.</li>
</ul>
<h2 id="the-deserialize-trait"><a href="#the-deserialize-trait">The Deserialize trait</a></h2>
<p>Serde provides <a href="../trait.Deserialize.html"><code>Deserialize</code></a> implementations for many Rust primitive and
standard library types. The complete list is below. All of these can be
deserialized 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.Deserialize.html"><code>Deserialize</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.Deserialize.html"><code>Deserialize</code></a> manually for
some type in your program. See the <a href="https://serde.rs/impl-deserialize.html">Implementing <code>Deserialize</code></a> section of
the manual for more about this.</p>
<p>Third-party crates may provide <a href="../trait.Deserialize.html"><code>Deserialize</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&lt;K, V&gt;</code></a> type that is deserializable by Serde because the
crate provides an implementation of <a href="../trait.Deserialize.html"><code>Deserialize</code></a> for it.</p>
<h2 id="the-deserializer-trait"><a href="#the-deserializer-trait">The Deserializer trait</a></h2>
<p><a href="../trait.Deserializer.html"><code>Deserializer</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/jamesmunns/postcard"><code>postcard</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>
<h2 id="implementations-of-deserialize-provided-by-serde"><a href="#implementations-of-deserialize-provided-by-serde">Implementations of Deserialize provided by Serde</a></h2>
<p>This is a slightly different set of types than what is supported for
serialization. Some types can be serialized by Serde but not deserialized.
One example is <code>OsStr</code>.</p>
<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>
</ul>
</li>
<li><strong>Compound types</strong>:
<ul>
<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&lt;T&gt;</li>
<li>Result&lt;T, E&gt;</li>
<li>PhantomData&lt;T&gt;</li>
</ul>
</li>
<li><strong>Wrapper types</strong>:
<ul>
<li>Box&lt;T&gt;</li>
<li>Box&lt;[T]&gt;</li>
<li>Box&lt;str&gt;</li>
<li>Cow&lt;a, T&gt;</li>
<li>Cell&lt;T&gt;</li>
<li>RefCell&lt;T&gt;</li>
<li>Mutex&lt;T&gt;</li>
<li>RwLock&lt;T&gt;</li>
<li>Rc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
<li>Arc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
</ul>
</li>
<li><strong>Collection types</strong>:
<ul>
<li>BTreeMap&lt;K, V&gt;</li>
<li>BTreeSet&lt;T&gt;</li>
<li>BinaryHeap&lt;T&gt;</li>
<li>HashMap&lt;K, V, H&gt;</li>
<li>HashSet&lt;T, H&gt;</li>
<li>LinkedList&lt;T&gt;</li>
<li>VecDeque&lt;T&gt;</li>
<li>Vec&lt;T&gt;</li>
</ul>
</li>
<li><strong>Zero-copy types</strong>:
<ul>
<li>&amp;str</li>
<li>&amp;[u8]</li>
</ul>
</li>
<li><strong>FFI types</strong>:
<ul>
<li>CString</li>
<li>Box&lt;CStr&gt;</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&lt;T&gt;</li>
<li>RangeInclusive&lt;T&gt;</li>
<li>Bound&lt;T&gt;</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></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2><div class="item-table"><div class="item-row"><div class="item-left import-item" id="reexport.StdError"><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/1.64.0/std/error/trait.Error.html" title="trait std::error::Error">Error</a> as StdError;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="value/index.html" title="serde::de::value mod">value</a></div><div class="item-right docblock-short"><p>Building blocks for deserializing basic values using the <code>IntoDeserializer</code>
trait.</p>
</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.IgnoredAny.html" title="serde::de::IgnoredAny struct">IgnoredAny</a></div><div class="item-right docblock-short"><p>An efficient way of discarding data from a deserializer.</p>
</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.Unexpected.html" title="serde::de::Unexpected enum">Unexpected</a></div><div class="item-right docblock-short"><p><code>Unexpected</code> represents an unexpected invocation of any one of the <code>Visitor</code>
trait methods.</p>
</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Deserialize.html" title="serde::de::Deserialize trait">Deserialize</a></div><div class="item-right docblock-short"><p>A <strong>data structure</strong> that can be deserialized from any data format supported
by Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.DeserializeOwned.html" title="serde::de::DeserializeOwned trait">DeserializeOwned</a></div><div class="item-right docblock-short"><p>A data structure that can be deserialized without borrowing any data from
the deserializer.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.DeserializeSeed.html" title="serde::de::DeserializeSeed trait">DeserializeSeed</a></div><div class="item-right docblock-short"><p><code>DeserializeSeed</code> is the stateful form of the <code>Deserialize</code> trait. If you
ever find yourself looking for a way to pass data into a <code>Deserialize</code> impl,
this trait is the way to do it.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Deserializer.html" title="serde::de::Deserializer trait">Deserializer</a></div><div class="item-right docblock-short"><p>A <strong>data format</strong> that can deserialize any data structure supported by
Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.EnumAccess.html" title="serde::de::EnumAccess trait">EnumAccess</a></div><div class="item-right docblock-short"><p>Provides a <code>Visitor</code> access to the data of an enum in the input.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Error.html" title="serde::de::Error trait">Error</a></div><div class="item-right docblock-short"><p>The <code>Error</code> trait allows <code>Deserialize</code> implementations to create descriptive
error messages belonging to the <code>Deserializer</code> against which they are
currently running.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Expected.html" title="serde::de::Expected trait">Expected</a></div><div class="item-right docblock-short"><p><code>Expected</code> represents an explanation of what data a <code>Visitor</code> was expecting
to receive.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.IntoDeserializer.html" title="serde::de::IntoDeserializer trait">IntoDeserializer</a></div><div class="item-right docblock-short"><p>Converts an existing value into a <code>Deserializer</code> from which other values can
be deserialized.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.MapAccess.html" title="serde::de::MapAccess trait">MapAccess</a></div><div class="item-right docblock-short"><p>Provides a <code>Visitor</code> access to each entry of a map in the input.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SeqAccess.html" title="serde::de::SeqAccess trait">SeqAccess</a></div><div class="item-right docblock-short"><p>Provides a <code>Visitor</code> access to each element of a sequence in the input.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.VariantAccess.html" title="serde::de::VariantAccess trait">VariantAccess</a></div><div class="item-right docblock-short"><p><code>VariantAccess</code> is a visitor that is created by the <code>Deserializer</code> and
passed to the <code>Deserialize</code> to deserialize the content of a particular enum
variant.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Visitor.html" title="serde::de::Visitor trait">Visitor</a></div><div class="item-right docblock-short"><p>This trait represents a visitor that walks through a deserializer.</p>
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":[["Unexpected","`Unexpected` represents an unexpected invocation of any one of the `Visitor` trait methods."]],"mod":[["value","Building blocks for deserializing basic values using the `IntoDeserializer` trait."]],"struct":[["IgnoredAny","An efficient way of discarding data from a deserializer."]],"trait":[["Deserialize","A data structure that can be deserialized from any data format supported by Serde."],["DeserializeOwned","A data structure that can be deserialized without borrowing any data from the deserializer."],["DeserializeSeed","`DeserializeSeed` is the stateful form of the `Deserialize` trait. If you ever find yourself looking for a way to pass data into a `Deserialize` impl, this trait is the way to do it."],["Deserializer","A data format that can deserialize any data structure supported by Serde."],["EnumAccess","Provides a `Visitor` access to the data of an enum in the input."],["Error","The `Error` trait allows `Deserialize` implementations to create descriptive error messages belonging to the `Deserializer` against which they are currently running."],["Expected","`Expected` represents an explanation of what data a `Visitor` was expecting to receive."],["IntoDeserializer","Converts an existing value into a `Deserializer` from which other values can be deserialized."],["MapAccess","Provides a `Visitor` access to each entry of a map in the input."],["SeqAccess","Provides a `Visitor` access to each element of a sequence in the input."],["VariantAccess","`VariantAccess` is a visitor that is created by the `Deserializer` and passed to the `Deserialize` to deserialize the content of a particular enum variant."],["Visitor","This trait represents a visitor that walks through a deserializer."]]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,20 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A data structure that can be deserialized without borrowing any data from the deserializer."><meta name="keywords" content="rust, rustlang, rust-lang, DeserializeOwned"><title>DeserializeOwned in serde::de - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">DeserializeOwned</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::de</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">de</a>::<wbr><a class="trait" href="#">DeserializeOwned</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/de/mod.rs.html#603">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait DeserializeOwned: for&lt;'de&gt; <a class="trait" href="../trait.Deserialize.html" title="trait serde::Deserialize">Deserialize</a>&lt;'de&gt; { }</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A data structure that can be deserialized without borrowing any data from
the deserializer.</p>
<p>This is primarily useful for trait bounds on functions. For example a
<code>from_str</code> function may be able to deserialize a data structure that borrows
from the input string, but a <code>from_reader</code> function may only deserialize
owned 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"><code><span class="kw">fn</span> <span class="ident">from_str</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span>, <span class="ident">T</span><span class="op">&gt;</span>(<span class="ident">s</span>: <span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="ident">str</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Deserialize</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">from_reader</span><span class="op">&lt;</span><span class="ident">R</span>, <span class="ident">T</span><span class="op">&gt;</span>(<span class="ident">rdr</span>: <span class="ident">R</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">R</span>: <span class="ident">Read</span>,
<span class="ident">T</span>: <span class="ident">DeserializeOwned</span>;</code></pre></div>
<h2 id="lifetime"><a href="#lifetime">Lifetime</a></h2>
<p>The relationship between <code>Deserialize</code> and <code>DeserializeOwned</code> in trait
bounds is explained in more detail on the page <a href="https://serde.rs/lifetimes.html">Understanding deserializer
lifetimes</a>.</p>
</div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-DeserializeOwned-for-T" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#604">source</a></span><a href="#impl-DeserializeOwned-for-T" class="anchor"></a><h3 class="code-header in-band">impl&lt;T&gt; <a class="trait" href="trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: for&lt;'de&gt; <a class="trait" href="../trait.Deserialize.html" title="trait serde::Deserialize">Deserialize</a>&lt;'de&gt;,&nbsp;</span></h3></section></div><script type="text/javascript" src="../../implementors/serde/de/trait.DeserializeOwned.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,134 @@
<!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="`DeserializeSeed` is the stateful form of the `Deserialize` trait. If you ever find yourself looking for a way to pass data into a `Deserialize` impl, this trait is the way to do it."><meta name="keywords" content="rust, rustlang, rust-lang, DeserializeSeed"><title>DeserializeSeed in serde::de - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">DeserializeSeed</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Value">Value</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.deserialize">deserialize</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-DeserializeSeed%3C%27de%3E-for-PhantomData%3CT%3E">PhantomData&lt;T&gt;</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::de</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">de</a>::<wbr><a class="trait" href="#">DeserializeSeed</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/de/mod.rs.html#769-778">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait DeserializeSeed&lt;'de&gt;: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> {
type <a href="#associatedtype.Value" class="associatedtype">Value</a>;
fn <a href="#tymethod.deserialize" class="fnname">deserialize</a>&lt;D&gt;(self, deserializer: D) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.DeserializeSeed.html#associatedtype.Value" title="type serde::de::DeserializeSeed::Value">Value</a>, D::<a class="associatedtype" href="../trait.Deserializer.html#associatedtype.Error" title="type serde::Deserializer::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;D: <a class="trait" href="../trait.Deserializer.html" title="trait serde::Deserializer">Deserializer</a>&lt;'de&gt;</span>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>DeserializeSeed</code> is the stateful form of the <code>Deserialize</code> trait. If you
ever find yourself looking for a way to pass data into a <code>Deserialize</code> impl,
this trait is the way to do it.</p>
<p>As one example of stateful deserialization consider deserializing a JSON
array into an existing buffer. Using the <code>Deserialize</code> trait we could
deserialize a JSON array into a <code>Vec&lt;T&gt;</code> but it would be a freshly allocated
<code>Vec&lt;T&gt;</code>; there is no way for <code>Deserialize</code> to reuse a previously allocated
buffer. Using <code>DeserializeSeed</code> instead makes this possible as in the
example code below.</p>
<p>The canonical API for stateless deserialization looks like this:</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">fn</span> <span class="ident">func</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span>, <span class="ident">T</span>: <span class="ident">Deserialize</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span><span class="op">&gt;</span>() -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T</span>, <span class="ident">Error</span><span class="op">&gt;</span></code></pre></div>
<p>Adjusting an API like this to support stateful deserialization is a matter
of accepting a seed as input:</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">fn</span> <span class="ident">func_seed</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span>, <span class="ident">T</span>: <span class="ident">DeserializeSeed</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span><span class="op">&gt;</span>(<span class="ident">seed</span>: <span class="ident">T</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">T::Value</span>, <span class="ident">Error</span><span class="op">&gt;</span></code></pre></div>
<p>In practice the majority of deserialization is stateless. An API expecting a
seed can be appeased by passing <code>std::marker::PhantomData</code> as a seed in the
case of stateless deserialization.</p>
<h2 id="lifetime"><a href="#lifetime">Lifetime</a></h2>
<p>The <code>'de</code> lifetime of this trait is the lifetime of data that may be
borrowed by <code>Self::Value</code> when deserialized. See the page <a href="https://serde.rs/lifetimes.html">Understanding
deserializer lifetimes</a> for a more detailed explanation of these lifetimes.</p>
<h2 id="example"><a href="#example">Example</a></h2>
<p>Suppose we have JSON that looks like <code>[[1, 2], [3, 4, 5], [6]]</code> and we need
to deserialize it into a flat representation like <code>vec![1, 2, 3, 4, 5, 6]</code>.
Allocating a brand new <code>Vec&lt;T&gt;</code> for each subarray would be slow. Instead we
would like to allocate a single <code>Vec&lt;T&gt;</code> and then deserialize each subarray
into it. This requires stateful deserialization using the <code>DeserializeSeed</code>
trait.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">std::fmt</span>;
<span class="kw">use</span> <span class="ident">std::marker::PhantomData</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>::{<span class="ident">Deserialize</span>, <span class="ident">DeserializeSeed</span>, <span class="ident">Deserializer</span>, <span class="ident">SeqAccess</span>, <span class="ident">Visitor</span>};
<span class="comment">// A DeserializeSeed implementation that uses stateful deserialization to</span>
<span class="comment">// append array elements onto the end of an existing vector. The preexisting</span>
<span class="comment">// state (&quot;seed&quot;) in this case is the Vec&lt;T&gt;. The `deserialize` method of</span>
<span class="comment">// `ExtendVec` will be traversing the inner arrays of the JSON input and</span>
<span class="comment">// appending each integer into the existing Vec.</span>
<span class="kw">struct</span> <span class="ident">ExtendVec</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span>, <span class="ident">T</span>: <span class="lifetime">&#39;a</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>);
<span class="kw">impl</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span>, <span class="lifetime">&#39;a</span>, <span class="ident">T</span><span class="op">&gt;</span> <span class="ident">DeserializeSeed</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ExtendVec</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span>, <span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Deserialize</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">// The return type of the `deserialize` method. This implementation</span>
<span class="comment">// appends onto an existing vector but does not create any new data</span>
<span class="comment">// structure, so the return type is ().</span>
<span class="kw">type</span> <span class="ident">Value</span> <span class="op">=</span> ();
<span class="kw">fn</span> <span class="ident">deserialize</span><span class="op">&lt;</span><span class="ident">D</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="ident">deserializer</span>: <span class="ident">D</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Value</span>, <span class="ident">D::Error</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">D</span>: <span class="ident">Deserializer</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">// Visitor implementation that will walk an inner array of the JSON</span>
<span class="comment">// input.</span>
<span class="kw">struct</span> <span class="ident">ExtendVecVisitor</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span>, <span class="ident">T</span>: <span class="lifetime">&#39;a</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="lifetime">&#39;a</span> <span class="kw-2">mut</span> <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>);
<span class="kw">impl</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span>, <span class="lifetime">&#39;a</span>, <span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Visitor</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">ExtendVecVisitor</span><span class="op">&lt;</span><span class="lifetime">&#39;a</span>, <span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Deserialize</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="kw">type</span> <span class="ident">Value</span> <span class="op">=</span> ();
<span class="kw">fn</span> <span class="ident">expecting</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">formatter</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span>) -&gt; <span class="ident">fmt::Result</span> {
<span class="macro">write!</span>(<span class="ident">formatter</span>, <span class="string">&quot;an array of integers&quot;</span>)
}
<span class="kw">fn</span> <span class="ident">visit_seq</span><span class="op">&lt;</span><span class="ident">A</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">seq</span>: <span class="ident">A</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span>(), <span class="ident">A::Error</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">A</span>: <span class="ident">SeqAccess</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">// Decrease the number of reallocations if there are many elements</span>
<span class="kw">if</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">size_hint</span>) <span class="op">=</span> <span class="ident">seq</span>.<span class="ident">size_hint</span>() {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">reserve</span>(<span class="ident">size_hint</span>);
}
<span class="comment">// Visit each element in the inner array and push it onto</span>
<span class="comment">// the existing vector.</span>
<span class="kw">while</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(<span class="ident">elem</span>) <span class="op">=</span> <span class="ident">seq</span>.<span class="ident">next_element</span>()<span class="question-mark">?</span> {
<span class="self">self</span>.<span class="number">0</span>.<span class="ident">push</span>(<span class="ident">elem</span>);
}
<span class="prelude-val">Ok</span>(())
}
}
<span class="ident">deserializer</span>.<span class="ident">deserialize_seq</span>(<span class="ident">ExtendVecVisitor</span>(<span class="self">self</span>.<span class="number">0</span>))
}
}
<span class="comment">// Visitor implementation that will walk the outer array of the JSON input.</span>
<span class="kw">struct</span> <span class="ident">FlattenedVecVisitor</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>(<span class="ident">PhantomData</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>);
<span class="kw">impl</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span>, <span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Visitor</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">FlattenedVecVisitor</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">T</span>: <span class="ident">Deserialize</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">// This Visitor constructs a single Vec&lt;T&gt; to hold the flattened</span>
<span class="comment">// contents of the inner arrays.</span>
<span class="kw">type</span> <span class="ident">Value</span> <span class="op">=</span> <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>;
<span class="kw">fn</span> <span class="ident">expecting</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">formatter</span>: <span class="kw-2">&amp;mut</span> <span class="ident">fmt::Formatter</span>) -&gt; <span class="ident">fmt::Result</span> {
<span class="macro">write!</span>(<span class="ident">formatter</span>, <span class="string">&quot;an array of arrays&quot;</span>)
}
<span class="kw">fn</span> <span class="ident">visit_seq</span><span class="op">&lt;</span><span class="ident">A</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="kw-2">mut</span> <span class="ident">seq</span>: <span class="ident">A</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</span>, <span class="ident">A::Error</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">A</span>: <span class="ident">SeqAccess</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">// Create a single Vec to hold the flattened contents.</span>
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">vec</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
<span class="comment">// Each iteration through this loop is one inner array.</span>
<span class="kw">while</span> <span class="kw">let</span> <span class="prelude-val">Some</span>(()) <span class="op">=</span> <span class="ident">seq</span>.<span class="ident">next_element_seed</span>(<span class="ident">ExtendVec</span>(<span class="kw-2">&amp;mut</span> <span class="ident">vec</span>))<span class="question-mark">?</span> {
<span class="comment">// Nothing to do; inner array has been appended into `vec`.</span>
}
<span class="comment">// Return the finished vec.</span>
<span class="prelude-val">Ok</span>(<span class="ident">vec</span>)
}
}
<span class="kw">let</span> <span class="ident">visitor</span> <span class="op">=</span> <span class="ident">FlattenedVecVisitor</span>(<span class="ident">PhantomData</span>);
<span class="kw">let</span> <span class="ident">flattened</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u64</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">deserializer</span>.<span class="ident">deserialize_seq</span>(<span class="ident">visitor</span>)<span class="question-mark">?</span>;</code></pre></div>
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Value" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#771">source</a></div><h4 class="code-header">type <a href="#associatedtype.Value" class="associatedtype">Value</a></h4></div></summary><div class="docblock"><p>The type produced by using this seed.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.deserialize" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#775-777">source</a></div><h4 class="code-header">fn <a href="#tymethod.deserialize" class="fnname">deserialize</a>&lt;D&gt;(self, deserializer: D) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.DeserializeSeed.html#associatedtype.Value" title="type serde::de::DeserializeSeed::Value">Value</a>, D::<a class="associatedtype" href="../trait.Deserializer.html#associatedtype.Error" title="type serde::Deserializer::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;D: <a class="trait" href="../trait.Deserializer.html" title="trait serde::Deserializer">Deserializer</a>&lt;'de&gt;,&nbsp;</span></h4></div></summary><div class="docblock"><p>Equivalent to the more common <code>Deserialize::deserialize</code> method, except
with some initial piece of data (the seed) passed in.</p>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-DeserializeSeed%3C%27de%3E-for-PhantomData%3CT%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#780-793">source</a></span><a href="#impl-DeserializeSeed%3C%27de%3E-for-PhantomData%3CT%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;'de, T&gt; <a class="trait" href="trait.DeserializeSeed.html" title="trait serde::de::DeserializeSeed">DeserializeSeed</a>&lt;'de&gt; for <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;T&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Deserialize.html" title="trait serde::Deserialize">Deserialize</a>&lt;'de&gt;,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Value-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Value-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Value" class="associatedtype">Value</a> = T</h4></section><section id="method.deserialize" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#787-792">source</a></span><a href="#method.deserialize" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.deserialize" class="fnname">deserialize</a>&lt;D&gt;(self, deserializer: D) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, D::<a class="associatedtype" href="../trait.Deserializer.html#associatedtype.Error" title="type serde::Deserializer::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;D: <a class="trait" href="../trait.Deserializer.html" title="trait serde::Deserializer">Deserializer</a>&lt;'de&gt;,&nbsp;</span></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"></div><script type="text/javascript" src="../../implementors/serde/de/trait.DeserializeSeed.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,26 @@
<!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="`Expected` represents an explanation of what data a `Visitor` was expecting to receive."><meta name="keywords" content="rust, rustlang, rust-lang, Expected"><title>Expected in serde::de - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Expected</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.fmt">fmt</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-Expected-for-%26%27a%20str">&amp;&#39;a str</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#trait-implementations">Trait Implementations</a></h3><ul><li><a href="#impl-Display-for-dyn%20Expected%20+%20%27a">Display</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::de</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">de</a>::<wbr><a class="trait" href="#">Expected</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/de/mod.rs.html#471-475">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait Expected {
fn <a href="#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.64.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>Expected</code> represents an explanation of what data a <code>Visitor</code> was expecting
to receive.</p>
<p>This is used as an argument to the <code>invalid_type</code>, <code>invalid_value</code>, and
<code>invalid_length</code> methods of the <code>Error</code> trait to build error messages. The
message should be a noun or noun phrase that completes the sentence “This
Visitor expects to receive …”, for example the message could be “an
integer between 0 and 64”. The message should not be capitalized and should
not end with a period.</p>
<p>Within the context of a <code>Visitor</code> implementation, the <code>Visitor</code> itself
(<code>&amp;self</code>) is an implementation of this trait.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">fn</span> <span class="ident">visit_bool</span><span class="op">&lt;</span><span class="ident">E</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="ident">v</span>: <span class="ident">bool</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Value</span>, <span class="ident">E</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">E</span>: <span class="ident">de::Error</span>,
{
<span class="prelude-val">Err</span>(<span class="ident">de::Error::invalid_type</span>(<span class="ident">Unexpected::Bool</span>(<span class="ident">v</span>), <span class="kw-2">&amp;</span><span class="self">self</span>))
}</code></pre></div>
<p>Outside of a <code>Visitor</code>, <code>&amp;&quot;...&quot;</code> can be used.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">return</span> <span class="prelude-val">Err</span>(<span class="ident">de::Error::invalid_type</span>(<span class="ident">Unexpected::Bool</span>(<span class="ident">v</span>), <span class="kw-2">&amp;</span><span class="string">&quot;a negative integer&quot;</span>));</code></pre></div>
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.fmt" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#474">source</a></div><h4 class="code-header">fn <a href="#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.64.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></div></summary><div class="docblock"><p>Format an explanation of what data was being expected. Same signature as
the <code>Display</code> and <code>Debug</code> traits.</p>
</div></details></div><h2 id="trait-implementations" class="small-section-header">Trait Implementations<a href="#trait-implementations" class="anchor"></a></h2><div id="trait-implementations-list"><details class="rustdoc-toggle implementors-toggle" open><summary><section id="impl-Display-for-dyn%20Expected%20+%20%27a" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#492-496">source</a></span><a href="#impl-Display-for-dyn%20Expected%20+%20%27a" class="anchor"></a><h3 class="code-header in-band">impl&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for dyn <a class="trait" href="trait.Expected.html" title="trait serde::de::Expected">Expected</a> + 'a</h3></section></summary><div class="impl-items"><details class="rustdoc-toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#493-495">source</a></span><a href="#method.fmt" class="anchor"></a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.64.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'><p>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></p>
</div></details></div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Expected-for-%26%27a%20str" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#486-490">source</a></span><a href="#impl-Expected-for-%26%27a%20str" class="anchor"></a><h3 class="code-header in-band">impl&lt;'a&gt; <a class="trait" href="trait.Expected.html" title="trait serde::de::Expected">Expected</a> for &amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a></h3></section></summary><div class="impl-items"><section id="method.fmt-1" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#487-489">source</a></span><a href="#method.fmt-1" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.fmt" class="fnname">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.64.0/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-Expected-for-T" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/mod.rs.html#477-484">source</a></span><a href="#impl-Expected-for-T" class="anchor"></a><h3 class="code-header in-band">impl&lt;'de, T&gt; <a class="trait" href="trait.Expected.html" title="trait serde::de::Expected">Expected</a> for T <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="trait.Visitor.html" title="trait serde::de::Visitor">Visitor</a>&lt;'de&gt;,&nbsp;</span></h3></section></div><script type="text/javascript" src="../../implementors/serde/de/trait.Expected.js" data-ignore-extern-crates="std" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,68 @@
<!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="Building blocks for deserializing basic values using the `IntoDeserializer` trait."><meta name="keywords" content="rust, rustlang, rust-lang, value"><title>serde::de::value - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../../SourceCodePro-Semibold.ttf.woff2"><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="../../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../../storage.js"></script><script defer src="../../../main.js"></script><noscript><link rel="stylesheet" href="../../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module value</a></h2><div class="sidebar-elems"><section><div class="block"><ul><li><a href="#structs">Structs</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../../serde/index.html"><img class="rust-logo" src="../../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Module <a href="../../index.html">serde</a>::<wbr><a href="../index.html">de</a>::<wbr><a class="mod" href="#">value</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../../src/serde/de/value.rs.html#1-1714">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Building blocks for deserializing basic values using the <code>IntoDeserializer</code>
trait.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">std::str::FromStr</span>;
<span class="kw">use</span> <span class="ident">serde::Deserialize</span>;
<span class="kw">use</span> <span class="ident">serde::de</span>::{<span class="ident">value</span>, <span class="ident">IntoDeserializer</span>};
<span class="attribute">#[<span class="ident">derive</span>(<span class="ident">Deserialize</span>)]</span>
<span class="kw">enum</span> <span class="ident">Setting</span> {
<span class="ident">On</span>,
<span class="ident">Off</span>,
}
<span class="kw">impl</span> <span class="ident">FromStr</span> <span class="kw">for</span> <span class="ident">Setting</span> {
<span class="kw">type</span> <span class="prelude-val">Err</span> <span class="op">=</span> <span class="ident">value::Error</span>;
<span class="kw">fn</span> <span class="ident">from_str</span>(<span class="ident">s</span>: <span class="kw-2">&amp;</span><span class="ident">str</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="self">Self</span>, <span class="ident"><span class="self">Self</span>::Err</span><span class="op">&gt;</span> {
<span class="ident"><span class="self">Self</span>::deserialize</span>(<span class="ident">s</span>.<span class="ident">into_deserializer</span>())
}
}</code></pre></div>
</div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BoolDeserializer.html" title="serde::de::value::BoolDeserializer struct">BoolDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>bool</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BorrowedBytesDeserializer.html" title="serde::de::value::BorrowedBytesDeserializer struct">BorrowedBytesDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>&amp;[u8]</code> with a lifetime tied to another
deserializer. Always calls <a href="../trait.Visitor.html#method.visit_borrowed_bytes" title="Visitor::visit_borrowed_bytes"><code>Visitor::visit_borrowed_bytes</code></a>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BorrowedStrDeserializer.html" title="serde::de::value::BorrowedStrDeserializer struct">BorrowedStrDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>&amp;str</code> with a lifetime tied to another
deserializer.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.BytesDeserializer.html" title="serde::de::value::BytesDeserializer struct">BytesDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>&amp;[u8]</code>. Always calls <a href="../trait.Visitor.html#method.visit_bytes" title="Visitor::visit_bytes"><code>Visitor::visit_bytes</code></a>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CharDeserializer.html" title="serde::de::value::CharDeserializer struct">CharDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>char</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.CowStrDeserializer.html" title="serde::de::value::CowStrDeserializer struct">CowStrDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>Cow&lt;str&gt;</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.EnumAccessDeserializer.html" title="serde::de::value::EnumAccessDeserializer struct">EnumAccessDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding an <code>EnumAccess</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Error.html" title="serde::de::value::Error struct">Error</a></div><div class="item-right docblock-short"><p>A minimal representation of all possible errors that can occur using the
<code>IntoDeserializer</code> trait.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.F32Deserializer.html" title="serde::de::value::F32Deserializer struct">F32Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>f32</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.F64Deserializer.html" title="serde::de::value::F64Deserializer struct">F64Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>f64</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.I8Deserializer.html" title="serde::de::value::I8Deserializer struct">I8Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>i8</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.I16Deserializer.html" title="serde::de::value::I16Deserializer struct">I16Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>i16</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.I32Deserializer.html" title="serde::de::value::I32Deserializer struct">I32Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>i32</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.I64Deserializer.html" title="serde::de::value::I64Deserializer struct">I64Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>i64</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.I128Deserializer.html" title="serde::de::value::I128Deserializer struct">I128Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>i128</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.IsizeDeserializer.html" title="serde::de::value::IsizeDeserializer struct">IsizeDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
an <code>isize</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapAccessDeserializer.html" title="serde::de::value::MapAccessDeserializer struct">MapAccessDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>MapAccess</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.MapDeserializer.html" title="serde::de::value::MapDeserializer struct">MapDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer that iterates over a map.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SeqAccessDeserializer.html" title="serde::de::value::SeqAccessDeserializer struct">SeqAccessDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>SeqAccess</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.SeqDeserializer.html" title="serde::de::value::SeqDeserializer struct">SeqDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer that iterates over a sequence.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.StrDeserializer.html" title="serde::de::value::StrDeserializer struct">StrDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>&amp;str</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.StringDeserializer.html" title="serde::de::value::StringDeserializer struct">StringDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>String</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.U8Deserializer.html" title="serde::de::value::U8Deserializer struct">U8Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>u8</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.U16Deserializer.html" title="serde::de::value::U16Deserializer struct">U16Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>u16</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.U32Deserializer.html" title="serde::de::value::U32Deserializer struct">U32Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>u32</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.U64Deserializer.html" title="serde::de::value::U64Deserializer struct">U64Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>u64</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.U128Deserializer.html" title="serde::de::value::U128Deserializer struct">U128Deserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>u128</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UnitDeserializer.html" title="serde::de::value::UnitDeserializer struct">UnitDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding a <code>()</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UsizeDeserializer.html" title="serde::de::value::UsizeDeserializer struct">UsizeDeserializer</a></div><div class="item-right docblock-short"><p>A deserializer holding
a <code>usize</code>.</p>
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":[["BoolDeserializer","A deserializer holding a `bool`."],["BorrowedBytesDeserializer","A deserializer holding a `&[u8]` with a lifetime tied to another deserializer. Always calls [`Visitor::visit_borrowed_bytes`]."],["BorrowedStrDeserializer","A deserializer holding a `&str` with a lifetime tied to another deserializer."],["BytesDeserializer","A deserializer holding a `&[u8]`. Always calls [`Visitor::visit_bytes`]."],["CharDeserializer","A deserializer holding a `char`."],["CowStrDeserializer","A deserializer holding a `Cow<str>`."],["EnumAccessDeserializer","A deserializer holding an `EnumAccess`."],["Error","A minimal representation of all possible errors that can occur using the `IntoDeserializer` trait."],["F32Deserializer","A deserializer holding an `f32`."],["F64Deserializer","A deserializer holding an `f64`."],["I128Deserializer","A deserializer holding an `i128`."],["I16Deserializer","A deserializer holding an `i16`."],["I32Deserializer","A deserializer holding an `i32`."],["I64Deserializer","A deserializer holding an `i64`."],["I8Deserializer","A deserializer holding an `i8`."],["IsizeDeserializer","A deserializer holding an `isize`."],["MapAccessDeserializer","A deserializer holding a `MapAccess`."],["MapDeserializer","A deserializer that iterates over a map."],["SeqAccessDeserializer","A deserializer holding a `SeqAccess`."],["SeqDeserializer","A deserializer that iterates over a sequence."],["StrDeserializer","A deserializer holding a `&str`."],["StringDeserializer","A deserializer holding a `String`."],["U128Deserializer","A deserializer holding a `u128`."],["U16Deserializer","A deserializer holding a `u16`."],["U32Deserializer","A deserializer holding a `u32`."],["U64Deserializer","A deserializer holding a `u64`."],["U8Deserializer","A deserializer holding a `u8`."],["UnitDeserializer","A deserializer holding a `()`."],["UsizeDeserializer","A deserializer holding a `usize`."]]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

71
doc/serde/index.html Normal file
View File

@ -0,0 +1,71 @@
<!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="Serde"><meta name="keywords" content="rust, rustlang, rust-lang, serde"><title>serde - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><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="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Crate serde</a></h2><div class="sidebar-elems"><div class="block"><ul><li class="version">Version 1.0.152</li><li><a id="all-types" href="all.html">All Items</a></li></ul></div><section><div class="block"><ul><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#traits">Traits</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../serde/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">serde</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/serde/lib.rs.html#1-334">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="serde"><a href="#serde">Serde</a></h2>
<p>Serde is a framework for <em><strong>ser</strong></em>ializing and <em><strong>de</strong></em>serializing Rust data
structures efficiently and generically.</p>
<p>The Serde ecosystem consists of data structures that know how to serialize
and deserialize themselves along with data formats that know how to
serialize and deserialize other things. Serde provides the layer by which
these two groups interact with each other, allowing any supported data
structure to be serialized and deserialized using any supported data format.</p>
<p>See the Serde website <a href="https://serde.rs/">https://serde.rs/</a> for additional documentation and
usage examples.</p>
<h3 id="design"><a href="#design">Design</a></h3>
<p>Where many other languages rely on runtime reflection for serializing data,
Serde is instead built on Rusts powerful trait system. A data structure
that knows how to serialize and deserialize itself is one that implements
Serdes <code>Serialize</code> and <code>Deserialize</code> traits (or uses Serdes derive
attribute to automatically generate implementations at compile time). This
avoids any overhead of reflection or runtime type information. In fact in
many situations the interaction between data structure and data format can
be completely optimized away by the Rust compiler, leaving Serde
serialization to perform the same speed as a handwritten serializer for the
specific selection of data structure and data format.</p>
<h3 id="data-formats"><a href="#data-formats">Data formats</a></h3>
<p>The following is a partial list of data formats that have been implemented
for Serde by the community.</p>
<ul>
<li><a href="https://github.com/serde-rs/json">JSON</a>, the ubiquitous JavaScript Object Notation used by many HTTP APIs.</li>
<li><a href="https://github.com/jamesmunns/postcard">Postcard</a>, a no_std and embedded-systems friendly compact binary format.</li>
<li><a href="https://github.com/enarx/ciborium">CBOR</a>, a Concise Binary Object Representation designed for small message
size without the need for version negotiation.</li>
<li><a href="https://github.com/dtolnay/serde-yaml">YAML</a>, a self-proclaimed human-friendly configuration language that aint
markup language.</li>
<li><a href="https://github.com/3Hren/msgpack-rust">MessagePack</a>, an efficient binary format that resembles a compact JSON.</li>
<li><a href="https://docs.rs/toml">TOML</a>, a minimal configuration format used by <a href="https://doc.rust-lang.org/cargo/reference/manifest.html">Cargo</a>.</li>
<li><a href="https://github.com/birkenfeld/serde-pickle">Pickle</a>, a format common in the Python world.</li>
<li><a href="https://github.com/ron-rs/ron">RON</a>, a Rusty Object Notation.</li>
<li><a href="https://github.com/mongodb/bson-rust">BSON</a>, the data storage and network transfer format used by MongoDB.</li>
<li><a href="https://docs.rs/apache-avro">Avro</a>, a binary format used within Apache Hadoop, with support for schema
definition.</li>
<li><a href="https://github.com/callum-oakley/json5-rs">JSON5</a>, a superset of JSON including some productions from ES5.</li>
<li><a href="https://docs.rs/serde_qs">URL</a> query strings, in the x-www-form-urlencoded format.</li>
<li><a href="https://github.com/softprops/envy">Envy</a>, a way to deserialize environment variables into Rust structs.
<em>(deserialization only)</em></li>
<li><a href="https://github.com/softprops/envy-store">Envy Store</a>, a way to deserialize <a href="https://docs.aws.amazon.com/systems-manager/latest/userguide/systems-manager-parameter-store.html">AWS Parameter Store</a> parameters into
Rust structs. <em>(deserialization only)</em></li>
<li><a href="https://github.com/rotty/lexpr-rs">S-expressions</a>, the textual representation of code and data used by the
Lisp language family.</li>
<li><a href="https://docs.rs/zvariant">D-Bus</a>s binary wire format.</li>
<li><a href="https://github.com/google/flatbuffers/tree/master/rust/flexbuffers">FlexBuffers</a>, the schemaless cousin of Googles FlatBuffers zero-copy
serialization format.</li>
<li><a href="https://github.com/P3KI/bendy">Bencode</a>, a simple binary format used in the BitTorrent protocol.</li>
<li><a href="https://github.com/oxidecomputer/serde_tokenstream">Token streams</a>, for processing Rust procedural macro input.
<em>(deserialization only)</em></li>
<li><a href="https://docs.rs/serde_dynamo">DynamoDB Items</a>, the format used by <a href="https://docs.rs/rusoto_dynamodb">rusoto_dynamodb</a> to transfer data to
and from DynamoDB.</li>
<li><a href="https://github.com/Canop/deser-hjson">Hjson</a>, a syntax extension to JSON designed around human reading and
editing. <em>(deserialization only)</em></li>
</ul>
</div></details><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="de/index.html" title="serde::de mod">de</a></div><div class="item-right docblock-short"><p>Generic data structure deserialization framework.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="ser/index.html" title="serde::ser mod">ser</a></div><div class="item-right docblock-short"><p>Generic data structure serialization framework.</p>
</div></div></div><h2 id="macros" class="small-section-header"><a href="#macros">Macros</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.forward_to_deserialize_any.html" title="serde::forward_to_deserialize_any macro">forward_to_deserialize_any</a></div><div class="item-right docblock-short"><p>Helper macro when implementing the <code>Deserializer</code> part of a new data format
for Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="macro" href="macro.serde_if_integer128.html" title="serde::serde_if_integer128 macro">serde_if_integer128</a></div><div class="item-right docblock-short"><p>Conditional compilation depending on whether Serde is built with support for
128-bit integers.</p>
</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Deserialize.html" title="serde::Deserialize trait">Deserialize</a></div><div class="item-right docblock-short"><p>A <strong>data structure</strong> that can be deserialized from any data format supported
by Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Deserializer.html" title="serde::Deserializer trait">Deserializer</a></div><div class="item-right docblock-short"><p>A <strong>data format</strong> that can deserialize any data structure supported by
Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serialize.html" title="serde::Serialize trait">Serialize</a></div><div class="item-right docblock-short"><p>A <strong>data structure</strong> that can be serialized into any data format supported
by Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serializer.html" title="serde::Serializer trait">Serializer</a></div><div class="item-right docblock-short"><p>A <strong>data format</strong> that can serialize any data structure supported by Serde.</p>
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.forward_to_deserialize_any.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.forward_to_deserialize_any.html">macro.forward_to_deserialize_any.html</a>...</p>
<script>location.replace("macro.forward_to_deserialize_any.html" + location.search + location.hash);</script>
</body>
</html>

View File

@ -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="Helper macro when implementing the `Deserializer` part of a new data format for Serde."><meta name="keywords" content="rust, rustlang, rust-lang, forward_to_deserialize_any"><title>forward_to_deserialize_any in serde - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><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="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><div class="sidebar-elems"><h2 class="location"><a href="index.html">In serde</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../serde/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Macro <a href="index.html">serde</a>::<wbr><a class="macro" href="#">forward_to_deserialize_any</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/serde/macros.rs.html#112-120">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><div class="example-wrap"><pre class="rust macro"><code><span class="macro">macro_rules!</span> <span class="ident">forward_to_deserialize_any</span> {
(<span class="op">&lt;</span><span class="macro-nonterminal">$</span><span class="macro-nonterminal">visitor</span>:<span class="ident">ident</span>: <span class="ident">Visitor</span><span class="op">&lt;</span><span class="macro-nonterminal">$</span><span class="macro-nonterminal">lifetime</span>:<span class="ident">tt</span><span class="op">&gt;</span><span class="op">&gt;</span> $(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">func</span>:<span class="ident">ident</span>)<span class="kw-2">*</span>) =&gt; { ... };
($(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">func</span>:<span class="ident">ident</span>)<span class="kw-2">*</span>) =&gt; { ... };
}</code></pre></div>
</div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Helper macro when implementing the <code>Deserializer</code> part of a new data format
for Serde.</p>
<p>Some <a href="trait.Deserializer.html"><code>Deserializer</code></a> implementations for self-describing formats do not
care what hint the <a href="de/trait.Visitor.html"><code>Visitor</code></a> gives them, they just want to blindly call
the <a href="de/trait.Visitor.html"><code>Visitor</code></a> method corresponding to the data they can tell is in the
input. This requires repetitive implementations of all the <a href="trait.Deserializer.html"><code>Deserializer</code></a>
trait methods.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="attribute">#[<span class="ident">inline</span>]</span>
<span class="kw">fn</span> <span class="ident">deserialize_bool</span><span class="op">&lt;</span><span class="ident">V</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="ident">visitor</span>: <span class="ident">V</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">V::Value</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">V</span>: <span class="ident">Visitor</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="self">self</span>.<span class="ident">deserialize_any</span>(<span class="ident">visitor</span>)
}</code></pre></div>
<p>The <code>forward_to_deserialize_any!</code> macro implements these simple forwarding
methods so that they forward directly to <a href="trait.Deserializer.html#tymethod.deserialize_any"><code>Deserializer::deserialize_any</code></a>.
You can choose which methods to forward.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">impl</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span> <span class="ident">Deserializer</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span> <span class="kw">for</span> <span class="ident">MyDeserializer</span> {
<span class="kw">fn</span> <span class="ident">deserialize_any</span><span class="op">&lt;</span><span class="ident">V</span><span class="op">&gt;</span>(<span class="self">self</span>, <span class="ident">visitor</span>: <span class="ident">V</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">V::Value</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span>
<span class="kw">where</span>
<span class="ident">V</span>: <span class="ident">Visitor</span><span class="op">&lt;</span><span class="lifetime">&#39;de</span><span class="op">&gt;</span>,
{
<span class="comment">/* ... */</span>
}
<span class="macro">forward_to_deserialize_any!</span> {
<span class="ident">bool</span> <span class="ident">i8</span> <span class="ident">i16</span> <span class="ident">i32</span> <span class="ident">i64</span> <span class="ident">i128</span> <span class="ident">u8</span> <span class="ident">u16</span> <span class="ident">u32</span> <span class="ident">u64</span> <span class="ident">u128</span> <span class="ident">f32</span> <span class="ident">f64</span> <span class="ident">char</span> <span class="ident">str</span> <span class="ident">string</span>
<span class="ident">bytes</span> <span class="ident">byte_buf</span> <span class="ident">option</span> <span class="ident">unit</span> <span class="ident">unit_struct</span> <span class="ident">newtype_struct</span> <span class="ident">seq</span> <span class="ident">tuple</span>
<span class="ident">tuple_struct</span> <span class="ident">map</span> <span class="kw">struct</span> <span class="kw">enum</span> <span class="ident">identifier</span> <span class="ident">ignored_any</span>
}
}</code></pre></div>
<p>The macro assumes the convention that your <code>Deserializer</code> lifetime parameter
is called <code>'de</code> and that the <code>Visitor</code> type parameters on each method are
called <code>V</code>. A different type parameter and a different lifetime can be
specified explicitly if necessary.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="macro">forward_to_deserialize_any!</span> {
<span class="op">&lt;</span><span class="ident">W</span>: <span class="ident">Visitor</span><span class="op">&lt;</span><span class="lifetime">&#39;q</span><span class="op">&gt;</span><span class="op">&gt;</span>
<span class="ident">bool</span> <span class="ident">i8</span> <span class="ident">i16</span> <span class="ident">i32</span> <span class="ident">i64</span> <span class="ident">i128</span> <span class="ident">u8</span> <span class="ident">u16</span> <span class="ident">u32</span> <span class="ident">u64</span> <span class="ident">u128</span> <span class="ident">f32</span> <span class="ident">f64</span> <span class="ident">char</span> <span class="ident">str</span> <span class="ident">string</span>
<span class="ident">bytes</span> <span class="ident">byte_buf</span> <span class="ident">option</span> <span class="ident">unit</span> <span class="ident">unit_struct</span> <span class="ident">newtype_struct</span> <span class="ident">seq</span> <span class="ident">tuple</span>
<span class="ident">tuple_struct</span> <span class="ident">map</span> <span class="kw">struct</span> <span class="kw">enum</span> <span class="ident">identifier</span> <span class="ident">ignored_any</span>
}</code></pre></div>
</div></details></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=macro.serde_if_integer128.html">
<title>Redirection</title>
</head>
<body>
<p>Redirecting to <a href="macro.serde_if_integer128.html">macro.serde_if_integer128.html</a>...</p>
<script>location.replace("macro.serde_if_integer128.html" + location.search + location.hash);</script>
</body>
</html>

View File

@ -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="Conditional compilation depending on whether Serde is built with support for 128-bit integers."><meta name="keywords" content="rust, rustlang, rust-lang, serde_if_integer128"><title>serde_if_integer128 in serde - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><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="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.svg"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><div class="sidebar-elems"><h2 class="location"><a href="index.html">In serde</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../serde/index.html"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Macro <a href="index.html">serde</a>::<wbr><a class="macro" href="#">serde_if_integer128</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../src/serde/integer128.rs.html#71-75">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><div class="example-wrap"><pre class="rust macro"><code><span class="macro">macro_rules!</span> <span class="ident">serde_if_integer128</span> {
($(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">tt</span>:<span class="ident">tt</span>)<span class="kw-2">*</span>) =&gt; { ... };
}</code></pre></div>
</div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Conditional compilation depending on whether Serde is built with support for
128-bit integers.</p>
<p>Data formats that wish to support Rust compiler versions older than 1.26
(or targets that lack 128-bit integers) may place the i128 / u128 methods
of their Serializer and Deserializer behind this macro.</p>
<p>Data formats that require a minimum Rust compiler version of at least 1.26,
or do not target platforms that lack 128-bit integers, do not need to
bother with this macro and may assume support for 128-bit integers.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde</span>::{<span class="ident">serde_if_integer128</span>, <span class="ident">Serializer</span>};
<span class="kw">impl</span> <span class="ident">Serializer</span> <span class="kw">for</span> <span class="ident">MySerializer</span> {
<span class="kw">type</span> <span class="prelude-val">Ok</span> <span class="op">=</span> ();
<span class="kw">type</span> <span class="ident">Error</span> <span class="op">=</span> <span class="ident">Error</span>;
<span class="kw">fn</span> <span class="ident">serialize_i64</span>(<span class="self">self</span>, <span class="ident">v</span>: <span class="ident">i64</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Ok</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span> {
<span class="comment">/* ... */</span>
}
<span class="comment">/* ... */</span>
<span class="macro">serde_if_integer128!</span> {
<span class="kw">fn</span> <span class="ident">serialize_i128</span>(<span class="self">self</span>, <span class="ident">v</span>: <span class="ident">i128</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Ok</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span> {
<span class="comment">/* ... */</span>
}
<span class="kw">fn</span> <span class="ident">serialize_u128</span>(<span class="self">self</span>, <span class="ident">v</span>: <span class="ident">u128</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident"><span class="self">Self</span>::Ok</span>, <span class="ident"><span class="self">Self</span>::Error</span><span class="op">&gt;</span> {
<span class="comment">/* ... */</span>
}
}
}</code></pre></div>
<p>When Serde is built with support for 128-bit integers, this macro expands
transparently into just the input tokens.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="macro">macro_rules!</span> <span class="ident">serde_if_integer128</span> {
($(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">tt</span>:<span class="ident">tt</span>)<span class="kw-2">*</span>) =&gt; {
$(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">tt</span>)<span class="op">*</span>
};
}</code></pre></div>
<p>When built without support for 128-bit integers, this macro expands to
nothing.</p>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="macro">macro_rules!</span> <span class="ident">serde_if_integer128</span> {
($(<span class="macro-nonterminal">$</span><span class="macro-nonterminal">tt</span>:<span class="ident">tt</span>)<span class="kw-2">*</span>) =&gt; {};
}</code></pre></div>
</div></details></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="refresh" content="0;URL=../../../serde/ser/struct.Impossible.html">
<title>Redirection</title>
</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>

128
doc/serde/ser/index.html Normal file
View File

@ -0,0 +1,128 @@
<!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="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module ser</a></h2><div class="sidebar-elems"><section><div class="block"><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></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">serde</a>::<wbr><a class="mod" href="#">ser</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1-1988">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><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>
<h2 id="the-serialize-trait"><a href="#the-serialize-trait">The Serialize trait</a></h2>
<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&lt;K, V&gt;</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>
<h2 id="the-serializer-trait"><a href="#the-serializer-trait">The Serializer trait</a></h2>
<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/jamesmunns/postcard"><code>postcard</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>
<h2 id="implementations-of-serialize-provided-by-serde"><a href="#implementations-of-serialize-provided-by-serde">Implementations of Serialize provided by Serde</a></h2>
<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>&amp;T and &amp;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&lt;T&gt;</li>
<li>Result&lt;T, E&gt;</li>
<li>PhantomData&lt;T&gt;</li>
</ul>
</li>
<li><strong>Wrapper types</strong>:
<ul>
<li>Box&lt;T&gt;</li>
<li>Cow&lt;a, T&gt;</li>
<li>Cell&lt;T&gt;</li>
<li>RefCell&lt;T&gt;</li>
<li>Mutex&lt;T&gt;</li>
<li>RwLock&lt;T&gt;</li>
<li>Rc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
<li>Arc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
</ul>
</li>
<li><strong>Collection types</strong>:
<ul>
<li>BTreeMap&lt;K, V&gt;</li>
<li>BTreeSet&lt;T&gt;</li>
<li>BinaryHeap&lt;T&gt;</li>
<li>HashMap&lt;K, V, H&gt;</li>
<li>HashSet&lt;T, H&gt;</li>
<li>LinkedList&lt;T&gt;</li>
<li>VecDeque&lt;T&gt;</li>
<li>Vec&lt;T&gt;</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&lt;T&gt;</li>
<li>RangeInclusive&lt;T&gt;</li>
<li>Bound&lt;T&gt;</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></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2><div class="item-table"><div class="item-row"><div class="item-left import-item" id="reexport.StdError"><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/1.64.0/std/error/trait.Error.html" title="trait std::error::Error">Error</a> as StdError;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Impossible.html" title="serde::ser::Impossible struct">Impossible</a></div><div class="item-right docblock-short"><p>Helper type for implementing a <code>Serializer</code> that does not support
serializing one of the compound types.</p>
</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Error.html" title="serde::ser::Error trait">Error</a></div><div class="item-right 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>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serialize.html" title="serde::ser::Serialize trait">Serialize</a></div><div class="item-right docblock-short"><p>A <strong>data structure</strong> that can be serialized into any data format supported
by Serde.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeMap.html" title="serde::ser::SerializeMap trait">SerializeMap</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_map</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeSeq.html" title="serde::ser::SerializeSeq trait">SerializeSeq</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeStruct.html" title="serde::ser::SerializeStruct trait">SerializeStruct</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeStructVariant.html" title="serde::ser::SerializeStructVariant trait">SerializeStructVariant</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTuple.html" title="serde::ser::SerializeTuple trait">SerializeTuple</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTupleStruct.html" title="serde::ser::SerializeTupleStruct trait">SerializeTupleStruct</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTupleVariant.html" title="serde::ser::SerializeTupleVariant trait">SerializeTupleVariant</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serializer.html" title="serde::ser::Serializer trait">Serializer</a></div><div class="item-right docblock-short"><p>A <strong>data format</strong> that can serialize any data structure supported by Serde.</p>
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"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

View File

@ -0,0 +1,29 @@
<!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>Error in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Error</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.custom">custom</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-Error-for-Error">Error</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#186">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait Error: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/std/error/trait.Error.html" title="trait std::error::Error">StdError</a> {
fn <a href="#tymethod.custom" class="fnname">custom</a>&lt;T&gt;(msg: T) -&gt; Self<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></span>;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><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>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.custom" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#186">source</a></div><h4 class="code-header">fn <a href="#tymethod.custom" class="fnname">custom</a>&lt;T&gt;(msg: T) -&gt; Self <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>,&nbsp;</span></h4></div></summary><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"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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>) =&gt; <span class="ident">serializer</span>.<span class="ident">serialize_str</span>(<span class="ident">s</span>),
<span class="prelude-val">None</span> =&gt; <span class="prelude-val">Err</span>(<span class="ident">ser::Error::custom</span>(<span class="string">&quot;path contains invalid UTF-8 characters&quot;</span>)),
}
}
}</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Error-for-Error" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/fmt.rs.html#4-8">source</a></span><a href="#impl-Error-for-Error" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a> for <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a></h3></section></summary><div class="impl-items"><section id="method.custom" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/fmt.rs.html#5-7">source</a></span><a href="#method.custom" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.custom" class="fnname">custom</a>&lt;T:&nbsp;<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>&gt;(_msg: T) -&gt; Self</h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-Error-for-Error-1" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/value.rs.html#84-92">source</a></span><a href="#impl-Error-for-Error-1" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a> for serde::de::value::<a class="struct" href="../de/value/struct.Error.html" title="struct serde::de::value::Error">Error</a></h3></section></div><script type="text/javascript" src="../../implementors/serde/ser/trait.Error.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,57 @@
<!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>SerializeMap in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeMap</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_key">serialize_key</a></li><li><a href="#tymethod.serialize_value">serialize_value</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.serialize_entry">serialize_entry</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1793-1852">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeMap {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt;;
fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a>&lt;K:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>K,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>V<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>,
{ ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_map</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">&gt;</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">HashMap</span><span class="op">&lt;</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">&gt;</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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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>()
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1795">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1798">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_key" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1806-1808">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><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></details><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_value" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1816-1818">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a map value.</p>
<h5 id="panics"><a href="#panics">Panics</a></h5>
<p>Calling <code>serialize_value</code> before <code>serialize_key</code> is incorrect and is
allowed to panic or produce bogus results.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1851">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a map.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.serialize_entry" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1837-1848">source</a></div><h4 class="code-header">fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a>&lt;K:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>K,<br>&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>V<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;K: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;V: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><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></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeMap-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#148-174">source</a></span><a href="#impl-SerializeMap-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeMap.html" title="trait serde::ser::SerializeMap">SerializeMap</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeMap.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,33 @@
<!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>SerializeSeq in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeSeq</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_element">serialize_element</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1524-1538">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeSeq {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>&gt;;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">T</span><span class="op">&gt;</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">T</span><span class="op">&gt;</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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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>()
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1526">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1529">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_element" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1532-1534">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a sequence element.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1537">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a sequence.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeSeq-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#68-86">source</a></span><a href="#impl-SerializeSeq-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeSeq.html" title="trait serde::ser::SerializeSeq">SerializeSeq</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeSeq.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,39 @@
<!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>SerializeStruct in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeStruct</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.skip_field">skip_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1887-1912">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeStruct {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt;;
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt; { ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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">&quot;Rgb&quot;</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">&quot;r&quot;</span>, <span class="kw-2">&amp;</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">&quot;g&quot;</span>, <span class="kw-2">&amp;</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">&quot;b&quot;</span>, <span class="kw-2">&amp;</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>()
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1889">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1892">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1895-1901">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a struct field.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1911">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a struct.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.skip_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1905-1908">source</a></div><h4 class="code-header">fn <a href="#method.skip_field" class="fnname">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Indicate that a struct field has been skipped.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeStruct-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#176-195">source</a></span><a href="#impl-SerializeStruct-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeStruct.html" title="trait serde::ser::SerializeStruct">SerializeStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStruct.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,45 @@
<!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>SerializeStructVariant in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeStructVariant</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.skip_field">skip_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1953-1978">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeStructVariant {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt;;
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt; { ... }
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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::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>,
} =&gt; {
<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">&quot;E&quot;</span>, <span class="number">0</span>, <span class="string">&quot;S&quot;</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">&quot;r&quot;</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">&quot;g&quot;</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">&quot;b&quot;</span>, <span class="ident">b</span>)<span class="question-mark">?</span>;
<span class="ident">sv</span>.<span class="ident">end</span>()
}
}
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1955">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1958">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1961-1967">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br>&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a struct variant field.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1977">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a struct variant.</p>
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.skip_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1971-1974">source</a></div><h4 class="code-header">fn <a href="#method.skip_field" class="fnname">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Indicate that a struct variant field has been skipped.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeStructVariant-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#197-216">source</a></span><a href="#impl-SerializeStructVariant-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeStructVariant.html" title="trait serde::ser::SerializeStructVariant">SerializeStructVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStructVariant.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,53 @@
<!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>SerializeTuple in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTuple</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_element">serialize_element</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1624-1638">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTuple {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>&gt;;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">A</span>, <span class="ident">B</span>, <span class="ident">C</span><span class="op">&gt;</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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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">&amp;</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">&amp;</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">&amp;</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>()
}
}</code></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"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">T</span><span class="op">&gt;</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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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>()
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1626">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1629">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_element" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1632-1634">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a tuple element.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1637">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a tuple.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTuple-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#88-106">source</a></span><a href="#impl-SerializeTuple-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTuple.html" title="trait serde::ser::SerializeTuple">SerializeTuple</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTuple.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,32 @@
<!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>SerializeTupleStruct in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTupleStruct</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1669-1683">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTupleStruct {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>&gt;;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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">&quot;Rgb&quot;</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">&amp;</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">&amp;</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">&amp;</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>()
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1671">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1674">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1677-1679">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a tuple struct field.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1682">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a tuple struct.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTupleStruct-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#108-126">source</a></span><a href="#impl-SerializeTupleStruct-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTupleStruct.html" title="trait serde::ser::SerializeTupleStruct">SerializeTupleStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleStruct.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

View File

@ -0,0 +1,45 @@
<!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>SerializeTupleVariant in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><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="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTupleVariant</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><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><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1727-1741">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTupleVariant {
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>&gt;<br>&nbsp;&nbsp;&nbsp; <span class="where">where<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>&gt;;
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::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">&lt;</span><span class="ident">S</span><span class="op">&gt;</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -&gt; <span class="prelude-ty">Result</span><span class="op">&lt;</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">&gt;</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::T</span>(<span class="kw-2">ref</span> <span class="ident">a</span>, <span class="kw-2">ref</span> <span class="ident">b</span>) =&gt; {
<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">&quot;E&quot;</span>, <span class="number">0</span>, <span class="string">&quot;T&quot;</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::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>) =&gt; {
<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">&quot;E&quot;</span>, <span class="number">1</span>, <span class="string">&quot;U&quot;</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>()
}
}
}
}</code></pre></div>
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
<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></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1729">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1732">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1735-1737">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a>&lt;T:&nbsp;?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&amp;</a>T) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,&nbsp;</span></h4></div></summary><div class="docblock"><p>Serialize a tuple variant field.</p>
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1740">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>&gt;</h4></div></summary><div class="docblock"><p>Finish serializing a tuple variant.</p>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTupleVariant-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#128-146">source</a></span><a href="#impl-SerializeTupleVariant-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTupleVariant.html" title="trait serde::ser::SerializeTupleVariant">SerializeTupleVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a>&lt;Ok, Error&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>,&nbsp;</span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleVariant.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"macro":[["forward_to_deserialize_any","Helper macro when implementing the `Deserializer` part of a new data format for Serde."],["serde_if_integer128","Conditional compilation depending on whether Serde is built with support for 128-bit integers."]],"mod":[["de","Generic data structure deserialization framework."],["ser","Generic data structure serialization framework."]],"trait":[["Deserialize","A data structure that can be deserialized from any data format supported by Serde."],["Deserializer","A data format that can deserialize any data structure supported by Serde."],["Serialize","A data structure that can be serialized into any data format supported by Serde."],["Serializer","A data format that can serialize any data structure supported by Serde."]]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long