Files
GopherGate/target/doc/serde/de/index.html
2026-02-26 12:00:21 -05:00

134 lines
13 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Generic data structure deserialization framework."><title>serde::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module de</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde/index.html">serde</a><span class="version">1.0.228</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module de</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#the-deserialize-trait" title="The Deserialize trait">The Deserialize trait</a></li><li><a href="#the-deserializer-trait" title="The Deserializer trait">The Deserializer trait</a></li><li><a href="#implementations-of-deserialize-provided-by-serde" title="Implementations of Deserialize provided by Serde">Implementations of Deserialize provided by Serde</a></li></ul><h3><a href="#modules">Module Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">serde</a></div><h1>Module <span>de</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_core/lib.rs.html#111">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Generic data structure deserialization framework.</p>
<p>The two most important traits in this module are <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> and
<a href="../trait.Deserializer.html" title="trait serde::Deserializer"><code>Deserializer</code></a>.</p>
<ul>
<li><strong>A type that implements <code>Deserialize</code> is a data structure</strong> that can be
deserialized from any data format supported by Serde, and conversely</li>
<li><strong>A type that implements <code>Deserializer</code> is a data format</strong> that can
deserialize any data structure supported by Serde.</li>
</ul>
<h2 id="the-deserialize-trait"><a class="doc-anchor" href="#the-deserialize-trait">§</a>The Deserialize trait</h2>
<p>Serde provides <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> implementations for many Rust primitive and
standard library types. The complete list is below. All of these can be
deserialized using Serde out of the box.</p>
<p>Additionally, Serde provides a procedural macro called <a href="https://crates.io/crates/serde_derive"><code>serde_derive</code></a> to
automatically generate <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> implementations for structs and enums
in your program. See the <a href="https://serde.rs/derive.html">derive section of the manual</a> for how to use this.</p>
<p>In rare cases it may be necessary to implement <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> manually for
some type in your program. See the <a href="https://serde.rs/impl-deserialize.html">Implementing <code>Deserialize</code></a> section of
the manual for more about this.</p>
<p>Third-party crates may provide <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> implementations for types
that they expose. For example the <a href="https://crates.io/crates/linked-hash-map"><code>linked-hash-map</code></a> crate provides a
<a href="https://docs.rs/linked-hash-map/*/linked_hash_map/struct.LinkedHashMap.html"><code>LinkedHashMap&lt;K, V&gt;</code></a> type that is deserializable by Serde because the
crate provides an implementation of <a href="../trait.Deserialize.html" title="trait serde::Deserialize"><code>Deserialize</code></a> for it.</p>
<h2 id="the-deserializer-trait"><a class="doc-anchor" href="#the-deserializer-trait">§</a>The Deserializer trait</h2>
<p><a href="../trait.Deserializer.html" title="trait serde::Deserializer"><code>Deserializer</code></a> implementations are provided by third-party crates, for
example <a href="https://github.com/serde-rs/json"><code>serde_json</code></a>, <a href="https://github.com/dtolnay/serde-yaml"><code>serde_yaml</code></a> and <a href="https://github.com/jamesmunns/postcard"><code>postcard</code></a>.</p>
<p>A partial list of well-maintained formats is given on the <a href="https://serde.rs/#data-formats">Serde
website</a>.</p>
<h2 id="implementations-of-deserialize-provided-by-serde"><a class="doc-anchor" href="#implementations-of-deserialize-provided-by-serde">§</a>Implementations of Deserialize provided by Serde</h2>
<p>This is a slightly different set of types than what is supported for
serialization. Some types can be serialized by Serde but not deserialized.
One example is <code>OsStr</code>.</p>
<ul>
<li><strong>Primitive types</strong>:
<ul>
<li>bool</li>
<li>i8, i16, i32, i64, i128, isize</li>
<li>u8, u16, u32, u64, u128, usize</li>
<li>f32, f64</li>
<li>char</li>
</ul>
</li>
<li><strong>Compound types</strong>:
<ul>
<li>[T; 0] through [T; 32]</li>
<li>tuples up to size 16</li>
</ul>
</li>
<li><strong>Common standard library types</strong>:
<ul>
<li>String</li>
<li>Option&lt;T&gt;</li>
<li>Result&lt;T, E&gt;</li>
<li>PhantomData&lt;T&gt;</li>
</ul>
</li>
<li><strong>Wrapper types</strong>:
<ul>
<li>Box&lt;T&gt;</li>
<li>Box&lt;[T]&gt;</li>
<li>Box&lt;str&gt;</li>
<li>Cow&lt;a, T&gt;</li>
<li>Cell&lt;T&gt;</li>
<li>RefCell&lt;T&gt;</li>
<li>Mutex&lt;T&gt;</li>
<li>RwLock&lt;T&gt;</li>
<li>Rc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
<li>Arc&lt;T&gt;<em>(if</em> features = [“rc”] <em>is enabled)</em></li>
</ul>
</li>
<li><strong>Collection types</strong>:
<ul>
<li>BTreeMap&lt;K, V&gt;</li>
<li>BTreeSet&lt;T&gt;</li>
<li>BinaryHeap&lt;T&gt;</li>
<li>HashMap&lt;K, V, H&gt;</li>
<li>HashSet&lt;T, H&gt;</li>
<li>LinkedList&lt;T&gt;</li>
<li>VecDeque&lt;T&gt;</li>
<li>Vec&lt;T&gt;</li>
</ul>
</li>
<li><strong>Zero-copy types</strong>:
<ul>
<li>&amp;str</li>
<li>&amp;[u8]</li>
</ul>
</li>
<li><strong>FFI types</strong>:
<ul>
<li>CString</li>
<li>Box&lt;CStr&gt;</li>
<li>OsString</li>
</ul>
</li>
<li><strong>Miscellaneous standard library types</strong>:
<ul>
<li>Duration</li>
<li>SystemTime</li>
<li>Path</li>
<li>PathBuf</li>
<li>Range&lt;T&gt;</li>
<li>RangeInclusive&lt;T&gt;</li>
<li>Bound&lt;T&gt;</li>
<li>num::NonZero*</li>
<li><code>!</code> <em>(unstable)</em></li>
</ul>
</li>
<li><strong>Net types</strong>:
<ul>
<li>IpAddr</li>
<li>Ipv4Addr</li>
<li>Ipv6Addr</li>
<li>SocketAddr</li>
<li>SocketAddrV4</li>
<li>SocketAddrV6</li>
</ul>
</li>
</ul>
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><dl class="item-table"><dt><a class="mod" href="value/index.html" title="mod serde::de::value">value</a></dt><dd>Building blocks for deserializing basic values using the <code>IntoDeserializer</code>
trait.</dd></dl><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.IgnoredAny.html" title="struct serde::de::IgnoredAny">Ignored<wbr>Any</a></dt><dd>An efficient way of discarding data from a deserializer.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.Unexpected.html" title="enum serde::de::Unexpected">Unexpected</a></dt><dd><code>Unexpected</code> represents an unexpected invocation of any one of the <code>Visitor</code>
trait methods.</dd></dl><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><dl class="item-table"><dt><a class="trait" href="trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a></dt><dd>A <strong>data structure</strong> that can be deserialized from any data format supported
by Serde.</dd><dt><a class="trait" href="trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">Deserialize<wbr>Owned</a></dt><dd>A data structure that can be deserialized without borrowing any data from
the deserializer.</dd><dt><a class="trait" href="trait.DeserializeSeed.html" title="trait serde::de::DeserializeSeed">Deserialize<wbr>Seed</a></dt><dd><code>DeserializeSeed</code> is the stateful form of the <code>Deserialize</code> trait. If you
ever find yourself looking for a way to pass data into a <code>Deserialize</code> impl,
this trait is the way to do it.</dd><dt><a class="trait" href="trait.Deserializer.html" title="trait serde::de::Deserializer">Deserializer</a></dt><dd>A <strong>data format</strong> that can deserialize any data structure supported by
Serde.</dd><dt><a class="trait" href="trait.EnumAccess.html" title="trait serde::de::EnumAccess">Enum<wbr>Access</a></dt><dd>Provides a <code>Visitor</code> access to the data of an enum in the input.</dd><dt><a class="trait" href="trait.Error.html" title="trait serde::de::Error">Error</a></dt><dd>The <code>Error</code> trait allows <code>Deserialize</code> implementations to create descriptive
error messages belonging to the <code>Deserializer</code> against which they are
currently running.</dd><dt><a class="trait" href="trait.Expected.html" title="trait serde::de::Expected">Expected</a></dt><dd><code>Expected</code> represents an explanation of what data a <code>Visitor</code> was expecting
to receive.</dd><dt><a class="trait" href="trait.IntoDeserializer.html" title="trait serde::de::IntoDeserializer">Into<wbr>Deserializer</a></dt><dd>Converts an existing value into a <code>Deserializer</code> from which other values can
be deserialized.</dd><dt><a class="trait" href="trait.MapAccess.html" title="trait serde::de::MapAccess">MapAccess</a></dt><dd>Provides a <code>Visitor</code> access to each entry of a map in the input.</dd><dt><a class="trait" href="trait.SeqAccess.html" title="trait serde::de::SeqAccess">SeqAccess</a></dt><dd>Provides a <code>Visitor</code> access to each element of a sequence in the input.</dd><dt><a class="trait" href="trait.StdError.html" title="trait serde::de::StdError">StdError</a></dt><dd><code>Error</code> is a trait representing the basic expectations for error values,
i.e., values of type <code>E</code> in <a href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result"><code>Result&lt;T, E&gt;</code></a>.</dd><dt><a class="trait" href="trait.VariantAccess.html" title="trait serde::de::VariantAccess">Variant<wbr>Access</a></dt><dd><code>VariantAccess</code> is a visitor that is created by the <code>Deserializer</code> and
passed to the <code>Deserialize</code> to deserialize the content of a particular enum
variant.</dd><dt><a class="trait" href="trait.Visitor.html" title="trait serde::de::Visitor">Visitor</a></dt><dd>This trait represents a visitor that walks through a deserializer.</dd></dl></section></div></main></body></html>