Now a REAL lib
This commit is contained in:
11
doc/serde/ser/impossible/struct.Impossible.html
Normal file
11
doc/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>
|
||||
128
doc/serde/ser/index.html
Normal file
128
doc/serde/ser/index.html
Normal file
@ -0,0 +1,128 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Generic data structure serialization framework."><meta name="keywords" content="rust, rustlang, rust-lang, ser"><title>serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Module ser</a></h2><div class="sidebar-elems"><section><div class="block"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li></ul></div></section></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Module <a href="../index.html">serde</a>::<wbr><a class="mod" href="#">ser</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1-1988">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Generic data structure serialization framework.</p>
|
||||
<p>The two most important traits in this module are <a href="../trait.Serialize.html"><code>Serialize</code></a> and
|
||||
<a href="../trait.Serializer.html"><code>Serializer</code></a>.</p>
|
||||
<ul>
|
||||
<li><strong>A type that implements <code>Serialize</code> is a data structure</strong> that can be
|
||||
serialized to any data format supported by Serde, and conversely</li>
|
||||
<li><strong>A type that implements <code>Serializer</code> is a data format</strong> that can
|
||||
serialize any data structure supported by Serde.</li>
|
||||
</ul>
|
||||
<h2 id="the-serialize-trait"><a href="#the-serialize-trait">The Serialize trait</a></h2>
|
||||
<p>Serde provides <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for many Rust primitive and
|
||||
standard library types. The complete list is below. All of these can be
|
||||
serialized using Serde out of the box.</p>
|
||||
<p>Additionally, Serde provides a procedural macro called <a href="https://crates.io/crates/serde_derive"><code>serde_derive</code></a> to
|
||||
automatically generate <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for structs and enums
|
||||
in your program. See the <a href="https://serde.rs/derive.html">derive section of the manual</a> for how to use this.</p>
|
||||
<p>In rare cases it may be necessary to implement <a href="../trait.Serialize.html"><code>Serialize</code></a> manually for
|
||||
some type in your program. See the <a href="https://serde.rs/impl-serialize.html">Implementing <code>Serialize</code></a> section of the
|
||||
manual for more about this.</p>
|
||||
<p>Third-party crates may provide <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations for types that
|
||||
they expose. For example the <a href="https://crates.io/crates/linked-hash-map"><code>linked-hash-map</code></a> crate provides a
|
||||
<a href="https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html"><code>LinkedHashMap<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 href="#the-serializer-trait">The Serializer trait</a></h2>
|
||||
<p><a href="../trait.Serializer.html"><code>Serializer</code></a> implementations are provided by third-party crates, for
|
||||
example <a href="https://github.com/serde-rs/json"><code>serde_json</code></a>, <a href="https://github.com/dtolnay/serde-yaml"><code>serde_yaml</code></a> and <a href="https://github.com/jamesmunns/postcard"><code>postcard</code></a>.</p>
|
||||
<p>A partial list of well-maintained formats is given on the <a href="https://serde.rs/#data-formats">Serde
|
||||
website</a>.</p>
|
||||
<h2 id="implementations-of-serialize-provided-by-serde"><a href="#implementations-of-serialize-provided-by-serde">Implementations of Serialize provided by Serde</a></h2>
|
||||
<ul>
|
||||
<li><strong>Primitive types</strong>:
|
||||
<ul>
|
||||
<li>bool</li>
|
||||
<li>i8, i16, i32, i64, i128, isize</li>
|
||||
<li>u8, u16, u32, u64, u128, usize</li>
|
||||
<li>f32, f64</li>
|
||||
<li>char</li>
|
||||
<li>str</li>
|
||||
<li>&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="small-section-header"><a href="#reexports">Re-exports</a></h2><div class="item-table"><div class="item-row"><div class="item-left import-item" id="reexport.StdError"><code>pub use std::error::<a class="trait" href="https://doc.rust-lang.org/1.64.0/std/error/trait.Error.html" title="trait std::error::Error">Error</a> as StdError;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Impossible.html" title="serde::ser::Impossible struct">Impossible</a></div><div class="item-right docblock-short"><p>Helper type for implementing a <code>Serializer</code> that does not support
|
||||
serializing one of the compound types.</p>
|
||||
</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Error.html" title="serde::ser::Error trait">Error</a></div><div class="item-right docblock-short"><p>Trait used by <code>Serialize</code> implementations to generically construct
|
||||
errors belonging to the <code>Serializer</code> against which they are
|
||||
currently running.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serialize.html" title="serde::ser::Serialize trait">Serialize</a></div><div class="item-right docblock-short"><p>A <strong>data structure</strong> that can be serialized into any data format supported
|
||||
by Serde.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeMap.html" title="serde::ser::SerializeMap trait">SerializeMap</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_map</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeSeq.html" title="serde::ser::SerializeSeq trait">SerializeSeq</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeStruct.html" title="serde::ser::SerializeStruct trait">SerializeStruct</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeStructVariant.html" title="serde::ser::SerializeStructVariant trait">SerializeStructVariant</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTuple.html" title="serde::ser::SerializeTuple trait">SerializeTuple</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTupleStruct.html" title="serde::ser::SerializeTupleStruct trait">SerializeTupleStruct</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.SerializeTupleVariant.html" title="serde::ser::SerializeTupleVariant trait">SerializeTupleVariant</a></div><div class="item-right docblock-short"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
|
||||
</div></div><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.Serializer.html" title="serde::ser::Serializer trait">Serializer</a></div><div class="item-right docblock-short"><p>A <strong>data format</strong> that can serialize any data structure supported by Serde.</p>
|
||||
</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
1
doc/serde/ser/sidebar-items.js
Normal file
1
doc/serde/ser/sidebar-items.js
Normal file
@ -0,0 +1 @@
|
||||
window.SIDEBAR_ITEMS = {"struct":[["Impossible","Helper type for implementing a `Serializer` that does not support serializing one of the compound types."]],"trait":[["Error","Trait used by `Serialize` implementations to generically construct errors belonging to the `Serializer` against which they are currently running."],["Serialize","A data structure that can be serialized into any data format supported by Serde."],["SerializeMap","Returned from `Serializer::serialize_map`."],["SerializeSeq","Returned from `Serializer::serialize_seq`."],["SerializeStruct","Returned from `Serializer::serialize_struct`."],["SerializeStructVariant","Returned from `Serializer::serialize_struct_variant`."],["SerializeTuple","Returned from `Serializer::serialize_tuple`."],["SerializeTupleStruct","Returned from `Serializer::serialize_tuple_struct`."],["SerializeTupleVariant","Returned from `Serializer::serialize_tuple_variant`."],["Serializer","A data format that can serialize any data structure supported by Serde."]]};
|
||||
69
doc/serde/ser/struct.Impossible.html
Normal file
69
doc/serde/ser/struct.Impossible.html
Normal file
File diff suppressed because one or more lines are too long
29
doc/serde/ser/trait.Error.html
Normal file
29
doc/serde/ser/trait.Error.html
Normal file
@ -0,0 +1,29 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Trait used by `Serialize` implementations to generically construct errors belonging to the `Serializer` against which they are currently running."><meta name="keywords" content="rust, rustlang, rust-lang, Error"><title>Error in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">Error</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.custom">custom</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul><li><a href="#impl-Error-for-Error">Error</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">Error</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#186">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait Error: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="https://doc.rust-lang.org/1.64.0/std/error/trait.Error.html" title="trait std::error::Error">StdError</a> {
|
||||
fn <a href="#tymethod.custom" class="fnname">custom</a><T>(msg: T) -> Self<br> <span class="where">where<br> T: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a></span>;
|
||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait used by <code>Serialize</code> implementations to generically construct
|
||||
errors belonging to the <code>Serializer</code> against which they are
|
||||
currently running.</p>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website shows an error
|
||||
type appropriate for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.custom" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#186">source</a></div><h4 class="code-header">fn <a href="#tymethod.custom" class="fnname">custom</a><T>(msg: T) -> Self <span class="where fmt-newline">where<br> T: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>, </span></h4></div></summary><div class="docblock"><p>Used when a <a href="../trait.Serialize.html"><code>Serialize</code></a> implementation encounters any error
|
||||
while serializing a type.</p>
|
||||
<p>The message should not be capitalized and should not end with a
|
||||
period.</p>
|
||||
<p>For example, a filesystem <a href="https://doc.rust-lang.org/std/path/struct.Path.html"><code>Path</code></a> may refuse to serialize
|
||||
itself if it contains invalid UTF-8 data.</p>
|
||||
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="self">self</span>, <span class="ident">Serialize</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Path</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="self">self</span>.<span class="ident">to_str</span>() {
|
||||
<span class="prelude-val">Some</span>(<span class="ident">s</span>) => <span class="ident">serializer</span>.<span class="ident">serialize_str</span>(<span class="ident">s</span>),
|
||||
<span class="prelude-val">None</span> => <span class="prelude-val">Err</span>(<span class="ident">ser::Error::custom</span>(<span class="string">"path contains invalid UTF-8 characters"</span>)),
|
||||
}
|
||||
}
|
||||
}</code></pre></div>
|
||||
</div></details></div><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-Error-for-Error" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/fmt.rs.html#4-8">source</a></span><a href="#impl-Error-for-Error" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a> for <a class="struct" href="https://doc.rust-lang.org/1.64.0/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a></h3></section></summary><div class="impl-items"><section id="method.custom" class="method trait-impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/fmt.rs.html#5-7">source</a></span><a href="#method.custom" class="anchor"></a><h4 class="code-header">fn <a href="#tymethod.custom" class="fnname">custom</a><T: <a class="trait" href="https://doc.rust-lang.org/1.64.0/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a>>(_msg: T) -> Self</h4></section></div></details><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><section id="impl-Error-for-Error-1" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/de/value.rs.html#84-92">source</a></span><a href="#impl-Error-for-Error-1" class="anchor"></a><h3 class="code-header in-band">impl <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a> for serde::de::value::<a class="struct" href="../de/value/struct.Error.html" title="struct serde::de::value::Error">Error</a></h3></section></div><script type="text/javascript" src="../../implementors/serde/ser/trait.Error.js" data-ignore-extern-crates="core" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
43
doc/serde/ser/trait.Serialize.html
Normal file
43
doc/serde/ser/trait.Serialize.html
Normal file
File diff suppressed because one or more lines are too long
57
doc/serde/ser/trait.SerializeMap.html
Normal file
57
doc/serde/ser/trait.SerializeMap.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_map`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeMap"><title>SerializeMap in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeMap</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_key">serialize_key</a></li><li><a href="#tymethod.serialize_value">serialize_value</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.serialize_entry">serialize_entry</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeMap</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1793-1852">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeMap {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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>>;
|
||||
|
||||
fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a><K: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>K,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>V<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>><br> <span class="where">where<br> K: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br> V: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>,
|
||||
{ ... }
|
||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_map</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeMap</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">HashMap</span><span class="op"><</span><span class="ident">K</span>, <span class="ident">V</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">K</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">V</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">map</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_map</span>(<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="ident">len</span>()))<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> (<span class="ident">k</span>, <span class="ident">v</span>) <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">map</span>.<span class="ident">serialize_entry</span>(<span class="ident">k</span>, <span class="ident">v</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">map</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeMap</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1795">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1798">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_key" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1806-1808">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_key" class="fnname">serialize_key</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a map key.</p>
|
||||
<p>If possible, <code>Serialize</code> implementations are encouraged to use
|
||||
<code>serialize_entry</code> instead as it may be implemented more efficiently in
|
||||
some formats compared to a pair of calls to <code>serialize_key</code> and
|
||||
<code>serialize_value</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_value" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1816-1818">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_value" class="fnname">serialize_value</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a map value.</p>
|
||||
<h5 id="panics"><a href="#panics">Panics</a></h5>
|
||||
<p>Calling <code>serialize_value</code> before <code>serialize_key</code> is incorrect and is
|
||||
allowed to panic or produce bogus results.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1851">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a map.</p>
|
||||
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.serialize_entry" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1837-1848">source</a></div><h4 class="code-header">fn <a href="#method.serialize_entry" class="fnname">serialize_entry</a><K: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>, V: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>K,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>V<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeMap.html#associatedtype.Error" title="type serde::ser::SerializeMap::Error">Error</a>> <span class="where fmt-newline">where<br> K: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>,<br> V: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a map entry consisting of a key and a value.</p>
|
||||
<p>Some <a href="../trait.Serialize.html"><code>Serialize</code></a> types are not able to hold a key and value in memory
|
||||
at the same time so <code>SerializeMap</code> implementations are required to
|
||||
support <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and <a href="#tymethod.serialize_value"><code>serialize_value</code></a> individually. The
|
||||
<code>serialize_entry</code> method allows serializers to optimize for the case
|
||||
where key and value are both available. <a href="../trait.Serialize.html"><code>Serialize</code></a> implementations
|
||||
are encouraged to use <code>serialize_entry</code> if possible.</p>
|
||||
<p>The default implementation delegates to <a href="#tymethod.serialize_key"><code>serialize_key</code></a> and
|
||||
<a href="#tymethod.serialize_value"><code>serialize_value</code></a>. This is appropriate for serializers that do not
|
||||
care about performance or are not able to optimize <code>serialize_entry</code> any
|
||||
better than this.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeMap-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#148-174">source</a></span><a href="#impl-SerializeMap-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeMap.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
33
doc/serde/ser/trait.SerializeSeq.html
Normal file
33
doc/serde/ser/trait.SerializeSeq.html
Normal file
@ -0,0 +1,33 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_seq`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeSeq"><title>SerializeSeq in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeSeq</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_element">serialize_element</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeSeq</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1524-1538">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeSeq {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_seq</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeSeq</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Vec</span><span class="op"><</span><span class="ident">T</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">T</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">seq</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_seq</span>(<span class="prelude-val">Some</span>(<span class="self">self</span>.<span class="ident">len</span>()))<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> <span class="ident">element</span> <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">seq</span>.<span class="ident">serialize_element</span>(<span class="ident">element</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">seq</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeSeq</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1526">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1529">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_element" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1532-1534">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeSeq.html#associatedtype.Error" title="type serde::ser::SerializeSeq::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a sequence element.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1537">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a sequence.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeSeq-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#68-86">source</a></span><a href="#impl-SerializeSeq-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeSeq.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
39
doc/serde/ser/trait.SerializeStruct.html
Normal file
39
doc/serde/ser/trait.SerializeStruct.html
Normal file
@ -0,0 +1,39 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_struct`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeStruct"><title>SerializeStruct in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeStruct</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.skip_field">skip_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeStruct</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1887-1912">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeStruct {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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>>;
|
||||
|
||||
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>> { ... }
|
||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_struct</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeStruct</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">struct</span> <span class="ident">Rgb</span> {
|
||||
<span class="ident">r</span>: <span class="ident">u8</span>,
|
||||
<span class="ident">g</span>: <span class="ident">u8</span>,
|
||||
<span class="ident">b</span>: <span class="ident">u8</span>,
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Rgb</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rgb</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_struct</span>(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"r"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">r</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"g"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">g</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">serialize_field</span>(<span class="string">"b"</span>, <span class="kw-2">&</span><span class="self">self</span>.<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">rgb</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeStruct</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1889">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1892">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1895-1901">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a struct field.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1911">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a struct.</p>
|
||||
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.skip_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1905-1908">source</a></div><h4 class="code-header">fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStruct.html#associatedtype.Error" title="type serde::ser::SerializeStruct::Error">Error</a>></h4></div></summary><div class="docblock"><p>Indicate that a struct field has been skipped.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeStruct-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#176-195">source</a></span><a href="#impl-SerializeStruct-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStruct.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
45
doc/serde/ser/trait.SerializeStructVariant.html
Normal file
45
doc/serde/ser/trait.SerializeStructVariant.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_struct_variant`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeStructVariant"><title>SerializeStructVariant in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeStructVariant</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><ul><li><a href="#method.skip_field">skip_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeStructVariant</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1953-1978">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeStructVariant {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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>>;
|
||||
|
||||
fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>> { ... }
|
||||
}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_struct_variant</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeStructVariant</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">enum</span> <span class="ident">E</span> {
|
||||
<span class="ident">S</span> { <span class="ident">r</span>: <span class="ident">u8</span>, <span class="ident">g</span>: <span class="ident">u8</span>, <span class="ident">b</span>: <span class="ident">u8</span> },
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">E</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
|
||||
<span class="ident">E::S</span> {
|
||||
<span class="kw-2">ref</span> <span class="ident">r</span>,
|
||||
<span class="kw-2">ref</span> <span class="ident">g</span>,
|
||||
<span class="kw-2">ref</span> <span class="ident">b</span>,
|
||||
} => {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">sv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_struct_variant</span>(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"S"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"r"</span>, <span class="ident">r</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"g"</span>, <span class="ident">g</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">serialize_field</span>(<span class="string">"b"</span>, <span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">sv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeStructVariant</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1955">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1958">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1961-1967">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a struct variant field.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1977">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a struct variant.</p>
|
||||
</div></details></div><h2 id="provided-methods" class="small-section-header">Provided Methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.skip_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1971-1974">source</a></div><h4 class="code-header">fn <a href="#method.skip_field" class="fnname">skip_field</a>(&mut self, key: &'static <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeStructVariant.html#associatedtype.Error" title="type serde::ser::SerializeStructVariant::Error">Error</a>></h4></div></summary><div class="docblock"><p>Indicate that a struct variant field has been skipped.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeStructVariant-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#197-216">source</a></span><a href="#impl-SerializeStructVariant-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeStructVariant.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
53
doc/serde/ser/trait.SerializeTuple.html
Normal file
53
doc/serde/ser/trait.SerializeTuple.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_tuple`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTuple"><title>SerializeTuple in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTuple</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_element">serialize_element</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeTuple</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1624-1638">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTuple {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeTuple</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">A</span>, <span class="ident">B</span>, <span class="ident">C</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> (<span class="ident">A</span>, <span class="ident">B</span>, <span class="ident">C</span>)
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">A</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">B</span>: <span class="ident">Serialize</span>,
|
||||
<span class="ident">C</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tup</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple</span>(<span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">serialize_element</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tup</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">Serializer</span>, <span class="ident">SerializeTuple</span>};
|
||||
|
||||
<span class="kw">impl</span><span class="op"><</span><span class="ident">T</span><span class="op">></span> <span class="ident">Serialize</span> <span class="kw">for</span> [<span class="ident">T</span>; <span class="number">16</span>]
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">T</span>: <span class="ident">Serialize</span>,
|
||||
{
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">seq</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple</span>(<span class="number">16</span>)<span class="question-mark">?</span>;
|
||||
<span class="kw">for</span> <span class="ident">element</span> <span class="kw">in</span> <span class="self">self</span> {
|
||||
<span class="ident">seq</span>.<span class="ident">serialize_element</span>(<span class="ident">element</span>)<span class="question-mark">?</span>;
|
||||
}
|
||||
<span class="ident">seq</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTuple</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1626">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1629">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_element" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1632-1634">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_element" class="fnname">serialize_element</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTuple.html#associatedtype.Error" title="type serde::ser::SerializeTuple::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a tuple element.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1637">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a tuple.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTuple-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#88-106">source</a></span><a href="#impl-SerializeTuple-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTuple.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
32
doc/serde/ser/trait.SerializeTupleStruct.html
Normal file
32
doc/serde/ser/trait.SerializeTupleStruct.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="Returned from `Serializer::serialize_tuple_struct`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTupleStruct"><title>SerializeTupleStruct in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTupleStruct</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeTupleStruct</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1669-1683">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTupleStruct {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_struct</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeTupleStruct</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">struct</span> <span class="ident">Rgb</span>(<span class="ident">u8</span>, <span class="ident">u8</span>, <span class="ident">u8</span>);
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">Rgb</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">ts</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_struct</span>(<span class="string">"Rgb"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">0</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">1</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">serialize_field</span>(<span class="kw-2">&</span><span class="self">self</span>.<span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">ts</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTupleStruct</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1671">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1674">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1677-1679">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleStruct.html#associatedtype.Error" title="type serde::ser::SerializeTupleStruct::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a tuple struct field.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1682">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a tuple struct.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTupleStruct-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#108-126">source</a></span><a href="#impl-SerializeTupleStruct-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleStruct.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
45
doc/serde/ser/trait.SerializeTupleVariant.html
Normal file
45
doc/serde/ser/trait.SerializeTupleVariant.html
Normal file
@ -0,0 +1,45 @@
|
||||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Returned from `Serializer::serialize_tuple_variant`."><meta name="keywords" content="rust, rustlang, rust-lang, SerializeTupleVariant"><title>SerializeTupleVariant in serde::ser - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../../normalize.css"><link rel="stylesheet" type="text/css" href="../../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../../dark.css" disabled><link rel="stylesheet" type="text/css" href="../../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../../storage.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../main.js"></script><noscript><link rel="stylesheet" href="../../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../../favicon.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">☰</button><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../../serde/index.html"><div class="logo-container"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">SerializeTupleVariant</a></h2><div class="sidebar-elems"><section><div class="block"><h3 class="sidebar-title"><a href="#required-associated-types">Required Associated Types</a></h3><ul><li><a href="#associatedtype.Error">Error</a></li><li><a href="#associatedtype.Ok">Ok</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#required-methods">Required Methods</a></h3><ul><li><a href="#tymethod.end">end</a></li><li><a href="#tymethod.serialize_field">serialize_field</a></li></ul></div><div class="block"><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div></section><h2 class="location"><a href="index.html">In serde::ser</a></h2></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../../serde/index.html"><img class="rust-logo" src="../../rust-logo.svg" alt="logo"></a><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><button type="button">?</button></div><div id="settings-menu" tabindex="-1"><a href="../../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../../wheel.svg"></a></div></div></form></nav></div><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn"><span class="in-band">Trait <a href="../index.html">serde</a>::<wbr><a href="index.html">ser</a>::<wbr><a class="trait" href="#">SerializeTupleVariant</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span></h1><span class="out-of-band"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1727-1741">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span></div><div class="docblock item-decl"><pre class="rust trait"><code>pub trait SerializeTupleVariant {
|
||||
type <a href="#associatedtype.Ok" class="associatedtype">Ok</a>;
|
||||
type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>;
|
||||
|
||||
fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(<br> &mut self,<br> value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T<br> ) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>><br> <span class="where">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a></span>;
|
||||
<span class="item-spacer"></span> fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Returned from <code>Serializer::serialize_tuple_variant</code>.</p>
|
||||
<h2 id="example-use"><a href="#example-use">Example use</a></h2>
|
||||
<div class='information'><div class='tooltip edition' data-edition="2018">ⓘ</div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">use</span> <span class="ident">serde::ser</span>::{<span class="ident">Serialize</span>, <span class="ident">SerializeTupleVariant</span>, <span class="ident">Serializer</span>};
|
||||
|
||||
<span class="kw">enum</span> <span class="ident">E</span> {
|
||||
<span class="ident">T</span>(<span class="ident">u8</span>, <span class="ident">u8</span>),
|
||||
<span class="ident">U</span>(<span class="ident">String</span>, <span class="ident">u32</span>, <span class="ident">u32</span>),
|
||||
}
|
||||
|
||||
<span class="kw">impl</span> <span class="ident">Serialize</span> <span class="kw">for</span> <span class="ident">E</span> {
|
||||
<span class="kw">fn</span> <span class="ident">serialize</span><span class="op"><</span><span class="ident">S</span><span class="op">></span>(<span class="kw-2">&</span><span class="self">self</span>, <span class="ident">serializer</span>: <span class="ident">S</span>) -> <span class="prelude-ty">Result</span><span class="op"><</span><span class="ident">S::Ok</span>, <span class="ident">S::Error</span><span class="op">></span>
|
||||
<span class="kw">where</span>
|
||||
<span class="ident">S</span>: <span class="ident">Serializer</span>,
|
||||
{
|
||||
<span class="kw">match</span> <span class="kw-2">*</span><span class="self">self</span> {
|
||||
<span class="ident">E::T</span>(<span class="kw-2">ref</span> <span class="ident">a</span>, <span class="kw-2">ref</span> <span class="ident">b</span>) => {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_variant</span>(<span class="string">"E"</span>, <span class="number">0</span>, <span class="string">"T"</span>, <span class="number">2</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">a</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
<span class="ident">E::U</span>(<span class="kw-2">ref</span> <span class="ident">a</span>, <span class="kw-2">ref</span> <span class="ident">b</span>, <span class="kw-2">ref</span> <span class="ident">c</span>) => {
|
||||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">tv</span> <span class="op">=</span> <span class="ident">serializer</span>.<span class="ident">serialize_tuple_variant</span>(<span class="string">"E"</span>, <span class="number">1</span>, <span class="string">"U"</span>, <span class="number">3</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">a</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">b</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">serialize_field</span>(<span class="ident">c</span>)<span class="question-mark">?</span>;
|
||||
<span class="ident">tv</span>.<span class="ident">end</span>()
|
||||
}
|
||||
}
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="example-implementation"><a href="#example-implementation">Example implementation</a></h2>
|
||||
<p>The <a href="https://serde.rs/data-format.html">example data format</a> presented on the website demonstrates an
|
||||
implementation of <code>SerializeTupleVariant</code> for a basic JSON data format.</p>
|
||||
</div></details><h2 id="required-associated-types" class="small-section-header">Required Associated Types<a href="#required-associated-types" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="associatedtype.Ok" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1729">source</a></div><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a></h4></div></summary><div class="docblock"><p>Must match the <code>Ok</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="associatedtype.Error" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1732">source</a></div><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a>: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a></h4></div></summary><div class="docblock"><p>Must match the <code>Error</code> type of our <code>Serializer</code>.</p>
|
||||
</div></details></div><h2 id="required-methods" class="small-section-header">Required Methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="tymethod.serialize_field" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1735-1737">source</a></div><h4 class="code-header">fn <a href="#tymethod.serialize_field" class="fnname">serialize_field</a><T: ?<a class="trait" href="https://doc.rust-lang.org/1.64.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>>(&mut self, value: <a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.reference.html">&</a>T) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.64.0/std/primitive.unit.html">()</a>, Self::<a class="associatedtype" href="trait.SerializeTupleVariant.html#associatedtype.Error" title="type serde::ser::SerializeTupleVariant::Error">Error</a>> <span class="where fmt-newline">where<br> T: <a class="trait" href="../trait.Serialize.html" title="trait serde::Serialize">Serialize</a>, </span></h4></div></summary><div class="docblock"><p>Serialize a tuple variant field.</p>
|
||||
</div></details><details class="rustdoc-toggle" open><summary><div id="tymethod.end" class="method has-srclink"><div class="rightside"><a class="srclink" href="../../src/serde/ser/mod.rs.html#1740">source</a></div><h4 class="code-header">fn <a href="#tymethod.end" class="fnname">end</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.64.0/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></div></summary><div class="docblock"><p>Finish serializing a tuple variant.</p>
|
||||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><details class="rustdoc-toggle implementors-toggle"><summary><section id="impl-SerializeTupleVariant-for-Impossible%3COk%2C%20Error%3E" class="impl has-srclink"><span class="rightside"><a class="srclink" href="../../src/serde/ser/impossible.rs.html#128-146">source</a></span><a href="#impl-SerializeTupleVariant-for-Impossible%3COk%2C%20Error%3E" class="anchor"></a><h3 class="code-header in-band">impl<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> <span class="where fmt-newline">where<br> Error: <a class="trait" href="trait.Error.html" title="trait serde::ser::Error">Error</a>, </span></h3></section></summary><div class="impl-items"><section id="associatedtype.Ok-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Ok-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Ok" class="associatedtype">Ok</a> = Ok</h4></section><section id="associatedtype.Error-1" class="associatedtype trait-impl has-srclink"><a href="#associatedtype.Error-1" class="anchor"></a><h4 class="code-header">type <a href="#associatedtype.Error" class="associatedtype">Error</a> = Error</h4></section></div></details></div><script type="text/javascript" src="../../implementors/serde/ser/trait.SerializeTupleVariant.js" data-ignore-extern-crates="" async></script></section></div></main><div id="rustdoc-vars" data-root-path="../../" data-current-crate="serde" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.64.0 (a55dd71d5 2022-09-19)" ></div></body></html>
|
||||
806
doc/serde/ser/trait.Serializer.html
Normal file
806
doc/serde/ser/trait.Serializer.html
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user