Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

View File

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

View File

@@ -0,0 +1,117 @@
<!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."><title>serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Module ser</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module ser</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#the-serialize-trait" title="The Serialize trait">The Serialize trait</a></li><li><a href="#the-serializer-trait" title="The Serializer trait">The Serializer trait</a></li><li><a href="#implementations-of-serialize-provided-by-serde" title="Implementations of Serialize provided by Serde">Implementations of Serialize provided by Serde</a></li></ul><h3><a href="#reexports">Module Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>core</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a></div><h1>Module <span>ser</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1-2010">Source</a> </span></div><details class="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" title="trait serde_core::Serialize"><code>Serialize</code></a> and
<a href="../trait.Serializer.html" title="trait serde_core::Serializer"><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 class="doc-anchor" href="#the-serialize-trait">§</a>The Serialize trait</h2>
<p>Serde provides <a href="../trait.Serialize.html" title="trait serde_core::Serialize"><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" title="trait serde_core::Serialize"><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" title="trait serde_core::Serialize"><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" title="trait serde_core::Serialize"><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" title="trait serde_core::Serialize"><code>Serialize</code></a> for it.</p>
<h2 id="the-serializer-trait"><a class="doc-anchor" href="#the-serializer-trait">§</a>The Serializer trait</h2>
<p><a href="../trait.Serializer.html" title="trait serde_core::Serializer"><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 class="doc-anchor" href="#implementations-of-serialize-provided-by-serde">§</a>Implementations of Serialize provided by Serde</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="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><dl class="item-table reexports"><dt id="reexport.StdError"><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/error/trait.Error.html" title="trait core::error::Error">Error</a> as StdError;</code></dt></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a></dt><dd>Helper type for implementing a <code>Serializer</code> that does not support
serializing one of the compound types.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></dt><dd>Trait used by <code>Serialize</code> implementations to generically construct
errors belonging to the <code>Serializer</code> against which they are
currently running.</dd><dt><a class="trait" href="trait.Serialize.html" title="trait serde_core::ser::Serialize">Serialize</a></dt><dd>A <strong>data structure</strong> that can be serialized into any data format supported
by Serde.</dd><dt><a class="trait" href="trait.SerializeMap.html" title="trait serde_core::ser::SerializeMap">Serialize<wbr>Map</a></dt><dd>Returned from <code>Serializer::serialize_map</code>.</dd><dt><a class="trait" href="trait.SerializeSeq.html" title="trait serde_core::ser::SerializeSeq">Serialize<wbr>Seq</a></dt><dd>Returned from <code>Serializer::serialize_seq</code>.</dd><dt><a class="trait" href="trait.SerializeStruct.html" title="trait serde_core::ser::SerializeStruct">Serialize<wbr>Struct</a></dt><dd>Returned from <code>Serializer::serialize_struct</code>.</dd><dt><a class="trait" href="trait.SerializeStructVariant.html" title="trait serde_core::ser::SerializeStructVariant">Serialize<wbr>Struct<wbr>Variant</a></dt><dd>Returned from <code>Serializer::serialize_struct_variant</code>.</dd><dt><a class="trait" href="trait.SerializeTuple.html" title="trait serde_core::ser::SerializeTuple">Serialize<wbr>Tuple</a></dt><dd>Returned from <code>Serializer::serialize_tuple</code>.</dd><dt><a class="trait" href="trait.SerializeTupleStruct.html" title="trait serde_core::ser::SerializeTupleStruct">Serialize<wbr>Tuple<wbr>Struct</a></dt><dd>Returned from <code>Serializer::serialize_tuple_struct</code>.</dd><dt><a class="trait" href="trait.SerializeTupleVariant.html" title="trait serde_core::ser::SerializeTupleVariant">Serialize<wbr>Tuple<wbr>Variant</a></dt><dd>Returned from <code>Serializer::serialize_tuple_variant</code>.</dd><dt><a class="trait" href="trait.Serializer.html" title="trait serde_core::ser::Serializer">Serializer</a></dt><dd>A <strong>data format</strong> that can serialize any data structure supported by Serde.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"struct":["Impossible"],"trait":["Error","Serialize","SerializeMap","SerializeSeq","SerializeStruct","SerializeStructVariant","SerializeTuple","SerializeTupleStruct","SerializeTupleVariant","Serializer"]};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,31 @@
<!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."><title>Error in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Error</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Error</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.custom" title="custom">custom</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Error-for-Error" title="Error">Error</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#192">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Error: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> {
// Required method
fn <a href="#tymethod.custom" class="fn">custom</a>&lt;T&gt;(msg: T) -&gt; Self
<span class="where">where T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></span>;
}</code></pre><details class="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 class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.custom" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#192">Source</a><h4 class="code-header">fn <a href="#tymethod.custom" class="fn">custom</a>&lt;T&gt;(msg: T) -&gt; Self<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>,</div></h4></section></summary><div class="docblock"><p>Used when a <a href="../trait.Serialize.html" title="trait serde_core::Serialize"><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/1.93.1/std/path/struct.Path.html" title="struct std::path::Path"><code>Path</code></a> may refuse to serialize
itself if it contains invalid UTF-8 data.</p>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{<span class="self">self</span>, Serialize, Serializer};
<span class="kw">impl </span>Serialize <span class="kw">for </span>Path {
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">match </span><span class="self">self</span>.to_str() {
<span class="prelude-val">Some</span>(s) =&gt; serializer.serialize_str(s),
<span class="prelude-val">None </span>=&gt; <span class="prelude-val">Err</span>(ser::Error::custom(<span class="string">"path contains invalid UTF-8 characters"</span>)),
}
}
}</code></pre></div></div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Error-for-Error" class="impl"><a class="src rightside" href="../../src/serde_core/ser/fmt.rs.html#4-8">Source</a><a href="#impl-Error-for-Error" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a> for <a class="struct" href="https://doc.rust-lang.org/1.93.1/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"><a class="src rightside" href="../../src/serde_core/ser/fmt.rs.html#5-7">Source</a><a href="#method.custom" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.custom" class="fn">custom</a>&lt;T: <a class="trait" href="https://doc.rust-lang.org/1.93.1/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="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Error-for-Error-1" class="impl"><a class="src rightside" href="../../src/serde_core/de/value.rs.html#84-92">Source</a><a href="#impl-Error-for-Error-1" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a> for serde_core::de::value::<a class="struct" href="../de/value/struct.Error.html" title="struct serde_core::de::value::Error">Error</a></h3></section></div><script src="../../trait.impl/serde_core/ser/trait.Error.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,74 @@
<!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`."><title>SerializeMap in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeMap</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Map</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_key" title="serialize_key">serialize_key</a></li><li><a href="#tymethod.serialize_value" title="serialize_value">serialize_value</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.serialize_entry" title="serialize_entry">serialize_entry</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Map</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1811-1866">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_key" class="fn">serialize_key</a>&lt;T&gt;(&amp;mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.serialize_value" class="fn">serialize_value</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;;
// Provided method
fn <a href="#method.serialize_entry" class="fn">serialize_entry</a>&lt;K, V&gt;(
&amp;mut self,
key: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;K</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;V</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;
<span class="where">where K: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,
V: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span> { ... }
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeMap, Serializer};
<span class="kw">impl</span>&lt;K, V&gt; Serialize <span class="kw">for </span>HashMap&lt;K, V&gt;
<span class="kw">where
</span>K: Serialize,
V: Serialize,
{
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>map = serializer.serialize_map(<span class="prelude-val">Some</span>(<span class="self">self</span>.len()))<span class="question-mark">?</span>;
<span class="kw">for </span>(k, v) <span class="kw">in </span><span class="self">self </span>{
map.serialize_entry(k, v)<span class="question-mark">?</span>;
}
map.end()
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1813">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1816">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_key" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1824-1826">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_key" class="fn">serialize_key</a>&lt;T&gt;(&amp;mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></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="toggle method-toggle" open><summary><section id="tymethod.serialize_value" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1834-1836">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_value" class="fn">serialize_value</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a map value.</p>
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</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="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1865">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a map.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.serialize_entry" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1855-1862">Source</a><h4 class="code-header">fn <a href="#method.serialize_entry" class="fn">serialize_entry</a>&lt;K, V&gt;(
&amp;mut self,
key: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;K</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;V</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde_core::ser::SerializeMap::Error">Error</a>&gt;<div class="where">where
K: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,
V: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a map entry consisting of a key and a value.</p>
<p>Some <a href="../trait.Serialize.html" title="trait serde_core::Serialize"><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="trait.SerializeMap.html#tymethod.serialize_key"><code>serialize_key</code></a> and <a href="trait.SerializeMap.html#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" title="trait serde_core::Serialize"><code>Serialize</code></a> implementations
are encouraged to use <code>serialize_entry</code> if possible.</p>
<p>The default implementation delegates to <a href="trait.SerializeMap.html#tymethod.serialize_key"><code>serialize_key</code></a> and
<a href="trait.SerializeMap.html#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="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeMap-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#148-174">Source</a><a href="#impl-SerializeMap-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeMap.html" title="trait serde_core::ser::SerializeMap">SerializeMap</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#152">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#153">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeMap.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,36 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_seq`."><title>SerializeSeq in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeSeq</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Seq</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_element" title="serialize_element">serialize_element</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Seq</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1518-1532">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde_core::ser::SerializeSeq::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde_core::ser::SerializeSeq::Error">Error</a>&gt;;
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeSeq, Serializer};
<span class="kw">impl</span>&lt;T&gt; Serialize <span class="kw">for </span>Vec&lt;T&gt;
<span class="kw">where
</span>T: Serialize,
{
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>seq = serializer.serialize_seq(<span class="prelude-val">Some</span>(<span class="self">self</span>.len()))<span class="question-mark">?</span>;
<span class="kw">for </span>element <span class="kw">in </span><span class="self">self </span>{
seq.serialize_element(element)<span class="question-mark">?</span>;
}
seq.end()
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1520">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1523">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_element" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1526-1528">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde_core::ser::SerializeSeq::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a sequence element.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1531">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde_core::ser::SerializeSeq::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a sequence.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeSeq-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#68-86">Source</a><a href="#impl-SerializeSeq-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeSeq.html" title="trait serde_core::ser::SerializeSeq">SerializeSeq</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#72">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#73">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeSeq.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,52 @@
<!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`."><title>SerializeStruct in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeStruct</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Struct</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_field" title="serialize_field">serialize_field</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.skip_field" title="skip_field">skip_field</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Struct</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1907-1930">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(
&amp;mut self,
key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt;;
// Provided method
fn <a href="#method.skip_field" class="fn">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt; { ... }
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeStruct, Serializer};
<span class="kw">struct </span>Rgb {
r: u8,
g: u8,
b: u8,
}
<span class="kw">impl </span>Serialize <span class="kw">for </span>Rgb {
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>rgb = serializer.serialize_struct(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
rgb.serialize_field(<span class="string">"r"</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.r)<span class="question-mark">?</span>;
rgb.serialize_field(<span class="string">"g"</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.g)<span class="question-mark">?</span>;
rgb.serialize_field(<span class="string">"b"</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.b)<span class="question-mark">?</span>;
rgb.end()
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1909">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1912">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1915-1917">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(
&amp;mut self,
key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a struct field.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1929">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a struct.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.skip_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1923-1926">Source</a><h4 class="code-header">fn <a href="#method.skip_field" class="fn">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeStruct::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Indicate that a struct field has been skipped.</p>
<p>The default implementation does nothing.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeStruct-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#176-195">Source</a><a href="#impl-SerializeStruct-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeStruct.html" title="trait serde_core::ser::SerializeStruct">SerializeStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#180">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#181">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeStruct.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,58 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_struct_variant`."><title>SerializeStructVariant in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeStructVariant</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Struct<wbr>Variant</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_field" title="serialize_field">serialize_field</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.skip_field" title="skip_field">skip_field</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Struct<wbr>Variant</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1977-2000">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(
&amp;mut self,
key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt;;
// Provided method
fn <a href="#method.skip_field" class="fn">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt; { ... }
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeStructVariant, Serializer};
<span class="kw">enum </span>E {
S { r: u8, g: u8, b: u8 },
}
<span class="kw">impl </span>Serialize <span class="kw">for </span>E {
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">match </span><span class="kw-2">*</span><span class="self">self </span>{
E::S {
<span class="kw-2">ref </span>r,
<span class="kw-2">ref </span>g,
<span class="kw-2">ref </span>b,
} =&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>sv = serializer.serialize_struct_variant(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"S"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
sv.serialize_field(<span class="string">"r"</span>, r)<span class="question-mark">?</span>;
sv.serialize_field(<span class="string">"g"</span>, g)<span class="question-mark">?</span>;
sv.serialize_field(<span class="string">"b"</span>, b)<span class="question-mark">?</span>;
sv.end()
}
}
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1979">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1982">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1985-1987">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(
&amp;mut self,
key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>,
value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a struct variant field.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1999">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a struct variant.</p>
</div></details></div><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.skip_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1993-1996">Source</a><h4 class="code-header">fn <a href="#method.skip_field" class="fn">skip_field</a>(&amp;mut self, key: &amp;'static <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeStructVariant::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Indicate that a struct variant field has been skipped.</p>
<p>The default implementation does nothing.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeStructVariant-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#197-216">Source</a><a href="#impl-SerializeStructVariant-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeStructVariant.html" title="trait serde_core::ser::SerializeStructVariant">SerializeStructVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#201">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#202">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeStructVariant.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,55 @@
<!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`."><title>SerializeTuple in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeTuple</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Tuple</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_element" title="serialize_element">serialize_element</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Tuple</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1624-1638">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde_core::ser::SerializeTuple::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde_core::ser::SerializeTuple::Error">Error</a>&gt;;
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeTuple, Serializer};
<span class="kw">impl</span>&lt;A, B, C&gt; Serialize <span class="kw">for </span>(A, B, C)
<span class="kw">where
</span>A: Serialize,
B: Serialize,
C: Serialize,
{
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>tup = serializer.serialize_tuple(<span class="number">3</span>)<span class="question-mark">?</span>;
tup.serialize_element(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
tup.serialize_element(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
tup.serialize_element(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
tup.end()
}
}</code></pre></div>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeTuple, Serializer};
<span class="kw">impl</span>&lt;T&gt; Serialize <span class="kw">for </span>[T; <span class="number">16</span>]
<span class="kw">where
</span>T: Serialize,
{
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>seq = serializer.serialize_tuple(<span class="number">16</span>)<span class="question-mark">?</span>;
<span class="kw">for </span>element <span class="kw">in </span><span class="self">self </span>{
seq.serialize_element(element)<span class="question-mark">?</span>;
}
seq.end()
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1626">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1629">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_element" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1632-1634">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde_core::ser::SerializeTuple::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a tuple element.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1637">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde_core::ser::SerializeTuple::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a tuple.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeTuple-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#88-106">Source</a><a href="#impl-SerializeTuple-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTuple.html" title="trait serde_core::ser::SerializeTuple">SerializeTuple</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#92">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#93">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeTuple.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,35 @@
<!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`."><title>SerializeTupleStruct in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeTupleStruct</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Tuple<wbr>Struct</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_field" title="serialize_field">serialize_field</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Tuple<wbr>Struct</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1675-1689">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleStruct::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleStruct::Error">Error</a>&gt;;
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeTupleStruct, Serializer};
<span class="kw">struct </span>Rgb(u8, u8, u8);
<span class="kw">impl </span>Serialize <span class="kw">for </span>Rgb {
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">let </span><span class="kw-2">mut </span>ts = serializer.serialize_tuple_struct(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
ts.serialize_field(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
ts.serialize_field(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
ts.serialize_field(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
ts.end()
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1677">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1680">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1683-1685">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleStruct::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a tuple struct field.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1688">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleStruct::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a tuple struct.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeTupleStruct-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#108-126">Source</a><a href="#impl-SerializeTupleStruct-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTupleStruct.html" title="trait serde_core::ser::SerializeTupleStruct">SerializeTupleStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#112">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#113">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeTupleStruct.js" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,48 @@
<!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`."><title>SerializeTupleVariant in serde_core::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_core" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">SerializeTupleVariant</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_core/index.html">serde_<wbr>core</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Serialize<wbr>Tuple<wbr>Variant</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example-use" title="Example use">Example use</a></li><li><a href="#example-implementation" title="Example implementation">Example implementation</a></li></ul><h3><a href="#required-associated-types">Required Associated Types</a></h3><ul class="block"><li><a href="#associatedtype.Error" title="Error">Error</a></li><li><a href="#associatedtype.Ok" title="Ok">Ok</a></li></ul><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.end" title="end">end</a></li><li><a href="#tymethod.serialize_field" title="serialize_field">serialize_field</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>core::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde_core</a>::<wbr><a href="index.html">ser</a></div><h1>Trait <span class="trait">Serialize<wbr>Tuple<wbr>Variant</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/ser/mod.rs.html#1739-1753">Source</a> </span></div><pre class="rust item-decl"><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_core::ser::Error">Error</a>;
// Required methods
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleVariant::Error">Error</a>&gt;
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a></span>;
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleVariant::Error">Error</a>&gt;;
}</code></pre><details class="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 class="doc-anchor" href="#example-use">§</a>Example use</h2>
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::ser::{Serialize, SerializeTupleVariant, Serializer};
<span class="kw">enum </span>E {
T(u8, u8),
U(String, u32, u32),
}
<span class="kw">impl </span>Serialize <span class="kw">for </span>E {
<span class="kw">fn </span>serialize&lt;S&gt;(<span class="kw-2">&amp;</span><span class="self">self</span>, serializer: S) -&gt; <span class="prelude-ty">Result</span>&lt;S::Ok, S::Error&gt;
<span class="kw">where
</span>S: Serializer,
{
<span class="kw">match </span><span class="kw-2">*</span><span class="self">self </span>{
E::T(<span class="kw-2">ref </span>a, <span class="kw-2">ref </span>b) =&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>tv = serializer.serialize_tuple_variant(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"T"</span>, <span class="number">2</span>)<span class="question-mark">?</span>;
tv.serialize_field(a)<span class="question-mark">?</span>;
tv.serialize_field(b)<span class="question-mark">?</span>;
tv.end()
}
E::U(<span class="kw-2">ref </span>a, <span class="kw-2">ref </span>b, <span class="kw-2">ref </span>c) =&gt; {
<span class="kw">let </span><span class="kw-2">mut </span>tv = serializer.serialize_tuple_variant(<span class="string">"E"</span>, <span class="number">1</span>, <span class="string">"U"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
tv.serialize_field(a)<span class="question-mark">?</span>;
tv.serialize_field(b)<span class="question-mark">?</span>;
tv.serialize_field(c)<span class="question-mark">?</span>;
tv.end()
}
}
}
}</code></pre></div><h2 id="example-implementation"><a class="doc-anchor" href="#example-implementation">§</a>Example implementation</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="section-header">Required Associated Types<a href="#required-associated-types" class="anchor">§</a></h2><div class="methods"><details class="toggle" open><summary><section id="associatedtype.Ok" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1741">Source</a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></section></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
</div></details><details class="toggle" open><summary><section id="associatedtype.Error" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1744">Source</a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a></h4></section></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="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.serialize_field" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1747-1749">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a>&lt;T&gt;(&amp;mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleVariant::Error">Error</a>&gt;<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde_core::Serialize">Serialize</a>,</div></h4></section></summary><div class="docblock"><p>Serialize a tuple variant field.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.end" class="method"><a class="src rightside" href="../../src/serde_core/ser/mod.rs.html#1752">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/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_core::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde_core::ser::SerializeTupleVariant::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Finish serializing a tuple variant.</p>
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.93.1/reference/items/traits.html#dyn-compatibility">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><details class="toggle implementors-toggle"><summary><section id="impl-SerializeTupleVariant-for-Impossible%3COk,+Error%3E" class="impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#128-146">Source</a><a href="#impl-SerializeTupleVariant-for-Impossible%3COk,+Error%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Ok, Error&gt; <a class="trait" href="trait.SerializeTupleVariant.html" title="trait serde_core::ser::SerializeTupleVariant">SerializeTupleVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde_core::ser::Impossible">Impossible</a>&lt;Ok, Error&gt;<div class="where">where
Error: <a class="trait" href="trait.Error.html" title="trait serde_core::ser::Error">Error</a>,</div></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#132">Source</a><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"><a class="src rightside" href="../../src/serde_core/ser/impossible.rs.html#133">Source</a><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 src="../../trait.impl/serde_core/ser/trait.SerializeTupleVariant.js" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long