mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-18 00:38:14 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
11
serde/ser/impossible/struct.Impossible.html
Normal file
11
serde/ser/impossible/struct.Impossible.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../serde/ser/struct.Impossible.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../serde/ser/struct.Impossible.html">../../../serde/ser/struct.Impossible.html</a>...</p>
|
||||
<script>location.replace("../../../serde/ser/struct.Impossible.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
117
serde/ser/index.html
Normal file
117
serde/ser/index.html
Normal 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::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a></span><h1>Module <span>ser</span><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/ser/mod.rs.html#1-1954">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"><code>Serialize</code></a> and
|
||||
<a href="../trait.Serializer.html"><code>Serializer</code></a>.</p>
|
||||
<ul>
|
||||
<li><strong>A type that implements <code>Serialize</code> is a data structure</strong> that can be
|
||||
serialized to any data format supported by Serde, and conversely</li>
|
||||
<li><strong>A type that implements <code>Serializer</code> is a data format</strong> that can
|
||||
serialize any data structure supported by Serde.</li>
|
||||
</ul>
|
||||
<h2 id="the-serialize-trait"><a class="doc-anchor" href="#the-serialize-trait">§</a>The Serialize trait</h2>
|
||||
<p>Serde provides <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for many Rust primitive and
|
||||
standard library types. The complete list is below. All of these can be
|
||||
serialized using Serde out of the box.</p>
|
||||
<p>Additionally, Serde provides a procedural macro called <a href="https://crates.io/crates/serde_derive"><code>serde_derive</code></a> to
|
||||
automatically generate <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for structs and enums
|
||||
in your program. See the <a href="https://serde.rs/derive.html">derive section of the manual</a> for how to use this.</p>
|
||||
<p>In rare cases it may be necessary to implement <a href="../trait.Serialize.html"><code>Serialize</code></a> manually for
|
||||
some type in your program. See the <a href="https://serde.rs/impl-serialize.html">Implementing <code>Serialize</code></a> section of the
|
||||
manual for more about this.</p>
|
||||
<p>Third-party crates may provide <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for types that
|
||||
they expose. For example the <a href="https://crates.io/crates/linked-hash-map"><code>linked-hash-map</code></a> crate provides a
|
||||
<a href="https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html"><code>LinkedHashMap<K, V></code></a> type that is serializable by Serde because the crate
|
||||
provides an implementation of <a href="../trait.Serialize.html"><code>Serialize</code></a> for it.</p>
|
||||
<h2 id="the-serializer-trait"><a class="doc-anchor" href="#the-serializer-trait">§</a>The Serializer trait</h2>
|
||||
<p><a href="../trait.Serializer.html"><code>Serializer</code></a> implementations are provided by third-party crates, for
|
||||
example <a href="https://github.com/serde-rs/json"><code>serde_json</code></a>, <a href="https://github.com/dtolnay/serde-yaml"><code>serde_yaml</code></a> and <a href="https://github.com/jamesmunns/postcard"><code>postcard</code></a>.</p>
|
||||
<p>A partial list of well-maintained formats is given on the <a href="https://serde.rs/#data-formats">Serde
|
||||
website</a>.</p>
|
||||
<h2 id="implementations-of-serialize-provided-by-serde"><a 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>&T and &mut T</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Compound types</strong>:
|
||||
<ul>
|
||||
<li>[T]</li>
|
||||
<li>[T; 0] through [T; 32]</li>
|
||||
<li>tuples up to size 16</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Common standard library types</strong>:
|
||||
<ul>
|
||||
<li>String</li>
|
||||
<li>Option<T></li>
|
||||
<li>Result<T, E></li>
|
||||
<li>PhantomData<T></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Wrapper types</strong>:
|
||||
<ul>
|
||||
<li>Box<T></li>
|
||||
<li>Cow<’a, T></li>
|
||||
<li>Cell<T></li>
|
||||
<li>RefCell<T></li>
|
||||
<li>Mutex<T></li>
|
||||
<li>RwLock<T></li>
|
||||
<li>Rc<T> <em>(if</em> features = [“rc”] <em>is enabled)</em></li>
|
||||
<li>Arc<T> <em>(if</em> features = [“rc”] <em>is enabled)</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Collection types</strong>:
|
||||
<ul>
|
||||
<li>BTreeMap<K, V></li>
|
||||
<li>BTreeSet<T></li>
|
||||
<li>BinaryHeap<T></li>
|
||||
<li>HashMap<K, V, H></li>
|
||||
<li>HashSet<T, H></li>
|
||||
<li>LinkedList<T></li>
|
||||
<li>VecDeque<T></li>
|
||||
<li>Vec<T></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>FFI types</strong>:
|
||||
<ul>
|
||||
<li>CStr</li>
|
||||
<li>CString</li>
|
||||
<li>OsStr</li>
|
||||
<li>OsString</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Miscellaneous standard library types</strong>:
|
||||
<ul>
|
||||
<li>Duration</li>
|
||||
<li>SystemTime</li>
|
||||
<li>Path</li>
|
||||
<li>PathBuf</li>
|
||||
<li>Range<T></li>
|
||||
<li>RangeInclusive<T></li>
|
||||
<li>Bound<T></li>
|
||||
<li>num::NonZero*</li>
|
||||
<li><code>!</code> <em>(unstable)</em></li>
|
||||
</ul>
|
||||
</li>
|
||||
<li><strong>Net types</strong>:
|
||||
<ul>
|
||||
<li>IpAddr</li>
|
||||
<li>Ipv4Addr</li>
|
||||
<li>Ipv6Addr</li>
|
||||
<li>SocketAddr</li>
|
||||
<li>SocketAddrV4</li>
|
||||
<li>SocketAddrV6</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.StdError"><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/error/trait.Error.html" title="trait core::error::Error">Error</a> as StdError;</code></div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a></div><div class="desc docblock-short">Helper type for implementing a <code>Serializer</code> that does not support
|
||||
serializing one of the compound types.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></div><div class="desc docblock-short">Trait used by <code>Serialize</code> implementations to generically construct
|
||||
errors belonging to the <code>Serializer</code> against which they are
|
||||
currently running.</div></li><li><div class="item-name"><a class="trait" href="trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a></div><div class="desc docblock-short">A <strong>data structure</strong> that can be serialized into any data format supported
|
||||
by Serde.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeMap.html" title="trait serde::ser::SerializeMap">Serialize<wbr>Map</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_map</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeSeq.html" title="trait serde::ser::SerializeSeq">Serialize<wbr>Seq</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_seq</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeStruct.html" title="trait serde::ser::SerializeStruct">Serialize<wbr>Struct</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_struct</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeStructVariant.html" title="trait serde::ser::SerializeStructVariant">Serialize<wbr>Struct<wbr>Variant</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_struct_variant</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeTuple.html" title="trait serde::ser::SerializeTuple">Serialize<wbr>Tuple</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_tuple</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeTupleStruct.html" title="trait serde::ser::SerializeTupleStruct">Serialize<wbr>Tuple<wbr>Struct</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_tuple_struct</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeTupleVariant.html" title="trait serde::ser::SerializeTupleVariant">Serialize<wbr>Tuple<wbr>Variant</a></div><div class="desc docblock-short">Returned from <code>Serializer::serialize_tuple_variant</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.Serializer.html" title="trait serde::ser::Serializer">Serializer</a></div><div class="desc docblock-short">A <strong>data format</strong> that can serialize any data structure supported by Serde.</div></li></ul></section></div></main></body></html>
|
||||
1
serde/ser/sidebar-items.js
Normal file
1
serde/ser/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"struct":["Impossible"],"trait":["Error","Serialize","SerializeMap","SerializeSeq","SerializeStruct","SerializeStructVariant","SerializeTuple","SerializeTupleStruct","SerializeTupleVariant","Serializer"]};
|
||||
75
serde/ser/struct.Impossible.html
Normal file
75
serde/ser/struct.Impossible.html
Normal file
File diff suppressed because one or more lines are too long
32
serde/ser/trait.Error.html
Normal file
32
serde/ser/trait.Error.html
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Trait used by `Serialize` implementations to generically construct errors belonging to the `Serializer` against which they are currently running."><title>Error in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">Error</span><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/ser/mod.rs.html#186">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Error: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/error/trait.Error.html" title="trait core::error::Error">StdError</a> {
|
||||
// Required method
|
||||
fn <a href="#tymethod.custom" class="fn">custom</a><T>(msg: T) -> Self
|
||||
<span class="where">where T: <a class="trait" href="https://doc.rust-lang.org/1.84.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/ser/mod.rs.html#186">Source</a><h4 class="code-header">fn <a href="#tymethod.custom" class="fn">custom</a><T>(msg: T) -> Self<div class="where">where
|
||||
T: <a class="trait" href="https://doc.rust-lang.org/1.84.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"><code>Serialize</code></a> implementation encounters any error
|
||||
while serializing a type.</p>
|
||||
<p>The message should not be capitalized and should not end with a
|
||||
period.</p>
|
||||
<p>For example, a filesystem <a href="https://doc.rust-lang.org/std/path/struct.Path.html"><code>Path</code></a> may refuse to serialize
|
||||
itself if it contains invalid UTF-8 data.</p>
|
||||
|
||||
<div class="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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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) => serializer.serialize_str(s),
|
||||
<span class="prelude-val">None </span>=> <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.84.1/reference/items/traits.html#object-safety">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/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::ser::Error">Error</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.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/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><T: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>>(_msg: T) -> 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/de/value.rs.html#83-91">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::ser::Error">Error</a> for serde::de::value::<a class="struct" href="../de/value/struct.Error.html" title="struct serde::de::value::Error">Error</a></h3></section></div><script src="../../trait.impl/serde/ser/trait.Error.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html>
|
||||
399
serde/ser/trait.Serialize.html
Normal file
399
serde/ser/trait.Serialize.html
Normal file
File diff suppressed because one or more lines are too long
75
serde/ser/trait.SerializeMap.html
Normal file
75
serde/ser/trait.SerializeMap.html
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
<!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::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeMap</span><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/ser/mod.rs.html#1767-1822">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_key" class="fn">serialize_key</a><T>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.serialize_value" class="fn">serialize_value</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.serialize_entry" class="fn">serialize_entry</a><K, V>(
|
||||
&mut self,
|
||||
key: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&K</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&V</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>>
|
||||
<span class="where">where K: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,
|
||||
V: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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><K, V> Serialize <span class="kw">for </span>HashMap<K, V>
|
||||
<span class="kw">where
|
||||
</span>K: Serialize,
|
||||
V: Serialize,
|
||||
{
|
||||
<span class="kw">fn </span>serialize<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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/ser/mod.rs.html#1769">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/ser/mod.rs.html#1772">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::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/ser/mod.rs.html#1780-1782">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_key" class="fn">serialize_key</a><T>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1790-1792">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_value" class="fn">serialize_value</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1821">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Ok" title="type serde::ser::SerializeMap::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>></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/ser/mod.rs.html#1811-1818">Source</a><h4 class="code-header">fn <a href="#method.serialize_entry" class="fn">serialize_entry</a><K, V>(
|
||||
&mut self,
|
||||
key: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&K</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&V</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><div class="where">where
|
||||
K: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,
|
||||
V: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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"><code>Serialize</code></a> types are not able to hold a key and value in memory
|
||||
at the same time so <code>SerializeMap</code> implementations are required to
|
||||
support <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and <a href="#tymethod.serialize_value"><code>serialize_value</code></a> individually. The
|
||||
<code>serialize_entry</code> method allows serializers to optimize for the case
|
||||
where key and value are both available. <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations
|
||||
are encouraged to use <code>serialize_entry</code> if possible.</p>
|
||||
<p>The default implementation delegates to <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and
|
||||
<a href="#tymethod.serialize_value"><code>serialize_value</code></a>. This is appropriate for serializers that do not
|
||||
care about performance or are not able to optimize <code>serialize_entry</code> any
|
||||
better than this.</p>
|
||||
</div></details></div><h2 id="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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeMap.html" title="trait serde::ser::SerializeMap">SerializeMap</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeMap.js" async></script></section></div></main></body></html>
|
||||
37
serde/ser/trait.SerializeSeq.html
Normal file
37
serde/ser/trait.SerializeSeq.html
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_seq`."><title>SerializeSeq in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeSeq</span><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/ser/mod.rs.html#1498-1512">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>>;
|
||||
}</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><T> Serialize <span class="kw">for </span>Vec<T>
|
||||
<span class="kw">where
|
||||
</span>T: Serialize,
|
||||
{
|
||||
<span class="kw">fn </span>serialize<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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/ser/mod.rs.html#1500">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/ser/mod.rs.html#1503">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::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/ser/mod.rs.html#1506-1508">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1511">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Ok" title="type serde::ser::SerializeSeq::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeSeq.html" title="trait serde::ser::SerializeSeq">SerializeSeq</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeSeq.js" async></script></section></div></main></body></html>
|
||||
53
serde/ser/trait.SerializeStruct.html
Normal file
53
serde/ser/trait.SerializeStruct.html
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_struct`."><title>SerializeStruct in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeStruct</span><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/ser/mod.rs.html#1857-1880">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(
|
||||
&mut self,
|
||||
key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.skip_field" class="fn">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>> { ... }
|
||||
}</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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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">&</span><span class="self">self</span>.r)<span class="question-mark">?</span>;
|
||||
rgb.serialize_field(<span class="string">"g"</span>, <span class="kw-2">&</span><span class="self">self</span>.g)<span class="question-mark">?</span>;
|
||||
rgb.serialize_field(<span class="string">"b"</span>, <span class="kw-2">&</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/ser/mod.rs.html#1859">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/ser/mod.rs.html#1862">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::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/ser/mod.rs.html#1865-1867">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(
|
||||
&mut self,
|
||||
key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1879">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Ok" title="type serde::ser::SerializeStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>></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/ser/mod.rs.html#1873-1876">Source</a><h4 class="code-header">fn <a href="#method.skip_field" class="fn">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeStruct.html" title="trait serde::ser::SerializeStruct">SerializeStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeStruct.js" async></script></section></div></main></body></html>
|
||||
59
serde/ser/trait.SerializeStructVariant.html
Normal file
59
serde/ser/trait.SerializeStructVariant.html
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
<!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::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeStructVariant</span><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/ser/mod.rs.html#1921-1944">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(
|
||||
&mut self,
|
||||
key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>>;
|
||||
|
||||
// Provided method
|
||||
fn <a href="#method.skip_field" class="fn">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>> { ... }
|
||||
}</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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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,
|
||||
} => {
|
||||
<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/ser/mod.rs.html#1923">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/ser/mod.rs.html#1926">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::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/ser/mod.rs.html#1929-1931">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(
|
||||
&mut self,
|
||||
key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>,
|
||||
value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>,
|
||||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1943">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Ok" title="type serde::ser::SerializeStructVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>></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/ser/mod.rs.html#1937-1940">Source</a><h4 class="code-header">fn <a href="#method.skip_field" class="fn">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeStructVariant.html" title="trait serde::ser::SerializeStructVariant">SerializeStructVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeStructVariant.js" async></script></section></div></main></body></html>
|
||||
57
serde/ser/trait.SerializeTuple.html
Normal file
57
serde/ser/trait.SerializeTuple.html
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_tuple`."><title>SerializeTuple in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeTuple</span><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/ser/mod.rs.html#1598-1612">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>>;
|
||||
}</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><A, B, C> 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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
tup.serialize_element(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
tup.serialize_element(<span class="kw-2">&</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><T> 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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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/ser/mod.rs.html#1600">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/ser/mod.rs.html#1603">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::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/ser/mod.rs.html#1606-1608">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fn">serialize_element</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1611">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Ok" title="type serde::ser::SerializeTuple::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeTuple.html" title="trait serde::ser::SerializeTuple">SerializeTuple</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeTuple.js" async></script></section></div></main></body></html>
|
||||
36
serde/ser/trait.SerializeTupleStruct.html
Normal file
36
serde/ser/trait.SerializeTupleStruct.html
Normal 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_tuple_struct`."><title>SerializeTupleStruct in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeTupleStruct</span><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/ser/mod.rs.html#1643-1657">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>>;
|
||||
}</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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
ts.serialize_field(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
ts.serialize_field(<span class="kw-2">&</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/ser/mod.rs.html#1645">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/ser/mod.rs.html#1648">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::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/ser/mod.rs.html#1651-1653">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1656">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Ok" title="type serde::ser::SerializeTupleStruct::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeTupleStruct.html" title="trait serde::ser::SerializeTupleStruct">SerializeTupleStruct</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeTupleStruct.js" async></script></section></div></main></body></html>
|
||||
49
serde/ser/trait.SerializeTupleVariant.html
Normal file
49
serde/ser/trait.SerializeTupleVariant.html
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_tuple_variant`."><title>SerializeTupleVariant in serde::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.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" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.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]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.216</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>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a></span><h1>Trait <span class="trait">SerializeTupleVariant</span><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/ser/mod.rs.html#1701-1715">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::ser::Error">Error</a>;
|
||||
|
||||
// Required methods
|
||||
fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>>
|
||||
<span class="where">where T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>>;
|
||||
}</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<S>(<span class="kw-2">&</span><span class="self">self</span>, serializer: S) -> <span class="prelude-ty">Result</span><S::Ok, S::Error>
|
||||
<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) => {
|
||||
<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) => {
|
||||
<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/ser/mod.rs.html#1703">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/ser/mod.rs.html#1706">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::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/ser/mod.rs.html#1709-1711">Source</a><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fn">serialize_field</a><T>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.Serialize.html" title="trait serde::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/ser/mod.rs.html#1714">Source</a><h4 class="code-header">fn <a href="#tymethod.end" class="fn">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Ok" title="type serde::ser::SerializeTupleVariant::Ok">Ok</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>></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.84.1/reference/items/traits.html#object-safety">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/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<Ok, Error> <a class="trait" href="trait.SerializeTupleVariant.html" title="trait serde::ser::SerializeTupleVariant">SerializeTupleVariant</a> for <a class="struct" href="struct.Impossible.html" title="struct serde::ser::Impossible">Impossible</a><Ok, Error><div class="where">where
|
||||
Error: <a class="trait" href="trait.Error.html" title="trait serde::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/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/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/ser/trait.SerializeTupleVariant.js" async></script></section></div></main></body></html>
|
||||
952
serde/ser/trait.Serializer.html
Normal file
952
serde/ser/trait.Serializer.html
Normal file
File diff suppressed because one or more lines are too long
Loading…
Add table
Add a link
Reference in a new issue