Files
google-apis-rs/serde_with/index.html
2024-03-05 21:06:01 +01:00

158 lines
33 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

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="crates.io badge Build Status codecov CII Best Practices Rustexplorer"><title>serde_with - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2"><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-ac92e1bbe349e143.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_with" data-themes="" data-resource-suffix="" data-rustdoc-version="1.76.0 (07dca489a 2024-02-04)" data-channel="1.76.0" data-search-js="search-2b6ce74ff89ae146.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-f2adc0d6ca4d09fb.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-305769736d49e732.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-feafe1bb7466e4bd.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_with/index.html">serde_with</a><span class="version">2.3.3</span></h2></div><div class="sidebar-elems"><ul class="block">
<li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#modules">Modules</a></li><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#traits">Traits</a></li><li><a href="#attributes">Attribute Macros</a></li><li><a href="#derives">Derive Macros</a></li></ul></section></div></nav><div class="sidebar-resizer"></div>
<main><div class="width-limiter"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../serde_with/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">serde_with</a><button id="copy-path" title="Copy item path to clipboard"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/serde_with/lib.rs.html#1-2339">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><a href="https://crates.io/crates/serde_with/"><img src="https://img.shields.io/crates/v/serde_with.svg" alt="crates.io badge" /></a>
<a href="https://github.com/jonasbb/serde_with"><img src="https://github.com/jonasbb/serde_with/workflows/Rust%20CI/badge.svg" alt="Build Status" /></a>
<a href="https://codecov.io/gh/jonasbb/serde_with"><img src="https://codecov.io/gh/jonasbb/serde_with/branch/master/graph/badge.svg" alt="codecov" /></a>
<a href="https://bestpractices.coreinfrastructure.org/projects/4322"><img src="https://bestpractices.coreinfrastructure.org/projects/4322/badge" alt="CII Best Practices" /></a>
<a href="https://www.rustexplorer.com/b/py7ida"><img src="https://img.shields.io/badge/Try%20on-rustexplorer-lightgrey?logo=rust&amp;logoColor=orange" alt="Rustexplorer" /></a></p>
<hr />
<p>This crate provides custom de/serialization helpers to use in combination with <a href="https://serde.rs/field-attrs.html#with">serdes with-annotation</a> and with the improved <a href="https://docs.rs/serde_with/2.3.3/serde_with/guide/serde_as/index.html"><code>serde_as</code></a>-annotation.
Some common use cases are:</p>
<ul>
<li>De/Serializing a type using the <code>Display</code> and <code>FromStr</code> traits, e.g., for <code>u8</code>, <code>url::Url</code>, or <code>mime::Mime</code>.
Check <a href="https://docs.rs/serde_with/2.3.3/serde_with/struct.DisplayFromStr.html"><code>DisplayFromStr</code></a> for details.</li>
<li>Support for arrays larger than 32 elements or using const generics.
With <code>serde_as</code> large arrays are supported, even if they are nested in other types.
<code>[bool; 64]</code>, <code>Option&lt;[u8; M]&gt;</code>, and <code>Box&lt;[[u8; 64]; N]&gt;</code> are all supported, as <a href="#large-and-const-generic-arrays">this examples shows</a>.</li>
<li>Skip serializing all empty <code>Option</code> types with <a href="https://docs.rs/serde_with/2.3.3/serde_with/attr.skip_serializing_none.html"><code>#[skip_serializing_none]</code></a>.</li>
<li>Apply a prefix to each field name of a struct, without changing the de/serialize implementations of the struct using <a href="https://docs.rs/serde_with/2.3.3/serde_with/macro.with_prefix.html"><code>with_prefix!</code></a>.</li>
<li>Deserialize a comma separated list like <code>#hash,#tags,#are,#great</code> into a <code>Vec&lt;String&gt;</code>.
Check the documentation for <a href="https://docs.rs/serde_with/2.3.3/serde_with/struct.StringWithSeparator.html"><code>serde_with::StringWithSeparator::&lt;CommaSeparator, T&gt;</code></a>.</li>
</ul>
<h3 id="getting-help"><a href="#getting-help">Getting Help</a></h3>
<p><strong>Check out the <a href="https://docs.rs/serde_with/2.3.3/serde_with/guide/index.html">user guide</a> to find out more tips and tricks about this crate.</strong></p>
<p>For further help using this crate you can <a href="https://github.com/jonasbb/serde_with/discussions/new">open a new discussion</a> or ask on <a href="https://users.rust-lang.org/">users.rust-lang.org</a>.
For bugs, please open a <a href="https://github.com/jonasbb/serde_with/issues/new">new issue</a> on GitHub.</p>
<h2 id="use-serde_with-in-your-project"><a href="#use-serde_with-in-your-project">Use <code>serde_with</code> in your Project</a></h2><div class="example-wrap"><pre class="language-bash"><code># Add the current version to your Cargo.toml
cargo add serde_with
</code></pre></div>
<p>The crate contains different features for integration with other common crates.
Check the <a href="https://docs.rs/serde_with/2.3.3/serde_with/guide/feature_flags/index.html">feature flags</a> section for information about all available features.</p>
<h2 id="examples"><a href="#examples">Examples</a></h2>
<p>Annotate your struct or enum to enable the custom de/serializer.
The <code>#[serde_as]</code> attribute must be placed <em>before</em> the <code>#[derive]</code>.</p>
<p>The <code>as</code> is analogous to the <code>with</code> attribute of serde.
You mirror the type structure of the field you want to de/serialize.
You can specify converters for the inner types of a field, e.g., <code>Vec&lt;DisplayFromStr&gt;</code>.
The default de/serialization behavior can be restored by using <code>_</code> as a placeholder, e.g., <code>BTreeMap&lt;_, DisplayFromStr&gt;</code>.</p>
<h3 id="displayfromstr"><a href="#displayfromstr"><code>DisplayFromStr</code></a></h3>
<p><a href="https://www.rustexplorer.com/b/py7ida"><img src="https://img.shields.io/badge/Try%20on-rustexplorer-lightgrey?logo=rust&amp;logoColor=orange" alt="Rustexplorer" /></a></p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[serde_as]
#[derive(Deserialize, Serialize)]
</span><span class="kw">struct </span>Foo {
<span class="comment">// Serialize with Display, deserialize with FromStr
</span><span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"DisplayFromStr"</span>)]
</span>bar: u8,
}
<span class="comment">// This will serialize
</span>Foo {bar: <span class="number">12</span>}
<span class="comment">// into this JSON
</span>{<span class="string">"bar"</span>: <span class="string">"12"</span>}</code></pre></div>
<h3 id="large-and-const-generic-arrays"><a href="#large-and-const-generic-arrays">Large and const-generic arrays</a></h3>
<p>serde does not support arrays with more than 32 elements or using const-generics.
The <code>serde_as</code> attribute allows circumventing this restriction, even for nested types and nested arrays.</p>
<p>On top of it, <code>[u8; N]</code> (aka, bytes) can use the specialized <code>&quot;Bytes&quot;</code> for efficiency much like the <code>serde_bytes</code> crate.</p>
<p><a href="https://www.rustexplorer.com/b/um0xyi"><img src="https://img.shields.io/badge/Try%20on-rustexplorer-lightgrey?logo=rust&amp;logoColor=orange" alt="Rustexplorer" /></a></p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[serde_as]
#[derive(Deserialize, Serialize)]
</span><span class="kw">struct </span>Arrays&lt;<span class="kw">const </span>N: usize, <span class="kw">const </span>M: usize&gt; {
<span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"[_; N]"</span>)]
</span>constgeneric: [bool; N],
<span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"Box&lt;[[_; 64]; N]&gt;"</span>)]
</span>nested: Box&lt;[[u8; <span class="number">64</span>]; N]&gt;,
<span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"Option&lt;[_; M]&gt;"</span>)]
</span>optional: <span class="prelude-ty">Option</span>&lt;[u8; M]&gt;,
<span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"Bytes"</span>)]
</span>bytes: [u8; M],
}
<span class="comment">// This allows us to serialize a struct like this
</span><span class="kw">let </span>arrays: Arrays&lt;<span class="number">100</span>, <span class="number">128</span>&gt; = Arrays {
constgeneric: [<span class="bool-val">true</span>; <span class="number">100</span>],
nested: Box::new([[<span class="number">111</span>; <span class="number">64</span>]; <span class="number">100</span>]),
optional: <span class="prelude-val">Some</span>([<span class="number">222</span>; <span class="number">128</span>]),
bytes: [<span class="number">0x42</span>; <span class="number">128</span>],
};
<span class="macro">assert!</span>(serde_json::to_string(<span class="kw-2">&amp;</span>arrays).is_ok());</code></pre></div>
<h3 id="skip_serializing_none"><a href="#skip_serializing_none"><code>skip_serializing_none</code></a></h3>
<p>This situation often occurs with JSON, but other formats also support optional fields.
If many fields are optional, putting the annotations on the structs can become tedious.
The <code>#[skip_serializing_none]</code> attribute must be placed <em>before</em> the <code>#[derive]</code>.</p>
<p><a href="https://www.rustexplorer.com/b/xr1tm0"><img src="https://img.shields.io/badge/Try%20on-rustexplorer-lightgrey?logo=rust&amp;logoColor=orange" alt="Rustexplorer" /></a></p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[skip_serializing_none]
#[derive(Deserialize, Serialize)]
</span><span class="kw">struct </span>Foo {
a: <span class="prelude-ty">Option</span>&lt;usize&gt;,
b: <span class="prelude-ty">Option</span>&lt;usize&gt;,
c: <span class="prelude-ty">Option</span>&lt;usize&gt;,
d: <span class="prelude-ty">Option</span>&lt;usize&gt;,
e: <span class="prelude-ty">Option</span>&lt;usize&gt;,
f: <span class="prelude-ty">Option</span>&lt;usize&gt;,
g: <span class="prelude-ty">Option</span>&lt;usize&gt;,
}
<span class="comment">// This will serialize
</span>Foo {a: <span class="prelude-val">None</span>, b: <span class="prelude-val">None</span>, c: <span class="prelude-val">None</span>, d: <span class="prelude-val">Some</span>(<span class="number">4</span>), e: <span class="prelude-val">None</span>, f: <span class="prelude-val">None</span>, g: <span class="prelude-val">Some</span>(<span class="number">7</span>)}
<span class="comment">// into this JSON
</span>{<span class="string">"d"</span>: <span class="number">4</span>, <span class="string">"g"</span>: <span class="number">7</span>}</code></pre></div>
<h3 id="advanced-serde_as-usage"><a href="#advanced-serde_as-usage">Advanced <code>serde_as</code> usage</a></h3>
<p>This example is mainly supposed to highlight the flexibility of the <code>serde_as</code>-annotation compared to <a href="https://serde.rs/field-attrs.html#with">serdes with-annotation</a>.
More details about <code>serde_as</code> can be found in the <a href="https://docs.rs/serde_with/2.3.3/serde_with/guide/index.html">user guide</a>.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::time::Duration;
<span class="attr">#[serde_as]
#[derive(Deserialize, Serialize)]
</span><span class="kw">enum </span>Foo {
Durations(
<span class="comment">// Serialize them into a list of number as seconds
</span><span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"Vec&lt;DurationSeconds&gt;"</span>)]
</span>Vec&lt;Duration&gt;,
),
Bytes {
<span class="comment">// We can treat a Vec like a map with duplicates.
// JSON only allows string keys, so convert i32 to strings
// The bytes will be hex encoded
</span><span class="attr">#[serde_as(<span class="kw">as </span>= <span class="string">"Map&lt;DisplayFromStr, Hex&gt;"</span>)]
</span>bytes: Vec&lt;(i32, Vec&lt;u8&gt;)&gt;,
}
}
<span class="comment">// This will serialize
</span>Foo::Durations(
<span class="macro">vec!</span>[Duration::new(<span class="number">5</span>, <span class="number">0</span>), Duration::new(<span class="number">3600</span>, <span class="number">0</span>), Duration::new(<span class="number">0</span>, <span class="number">0</span>)]
)
<span class="comment">// into this JSON
</span>{
<span class="string">"Durations"</span>: [<span class="number">5</span>, <span class="number">3600</span>, <span class="number">0</span>]
}
<span class="comment">// and serializes
</span>Foo::Bytes {
bytes: <span class="macro">vec!</span>[
(<span class="number">1</span>, <span class="macro">vec!</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>]),
(-<span class="number">100</span>, <span class="macro">vec!</span>[<span class="number">100</span>, <span class="number">200</span>, <span class="number">255</span>]),
(<span class="number">1</span>, <span class="macro">vec!</span>[<span class="number">0</span>, <span class="number">111</span>, <span class="number">222</span>]),
],
}
<span class="comment">// into this JSON
</span>{
<span class="string">"Bytes"</span>: {
<span class="string">"bytes"</span>: {
<span class="string">"1"</span>: <span class="string">"000102"</span>,
<span class="string">"-100"</span>: <span class="string">"64c8ff"</span>,
<span class="string">"1"</span>: <span class="string">"006fde"
</span>}
}
}</code></pre></div>
</div></details><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="de/index.html" title="mod serde_with::de">de</a></div><div class="desc docblock-short">Module for <a href="trait.DeserializeAs.html" title="trait serde_with::DeserializeAs"><code>DeserializeAs</code></a> implementations</div></li><li><div class="item-name"><a class="mod" href="formats/index.html" title="mod serde_with::formats">formats</a></div><div class="desc docblock-short">Specify the format and how lenient the deserialization is</div></li><li><div class="item-name"><a class="mod" href="rust/index.html" title="mod serde_with::rust">rust</a></div><div class="desc docblock-short">De/Serialization for Rusts builtin and std types</div></li><li><div class="item-name"><a class="mod" href="ser/index.html" title="mod serde_with::ser">ser</a></div><div class="desc docblock-short">Module for <a href="trait.SerializeAs.html" title="trait serde_with::SerializeAs"><code>SerializeAs</code></a> implementations</div></li></ul><h2 id="macros" class="section-header"><a href="#macros">Macros</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.flattened_maybe.html" title="macro serde_with::flattened_maybe">flattened_maybe</a></div><div class="desc docblock-short">Support deserializing from flattened and non-flattened representation</div></li><li><div class="item-name"><a class="macro" href="macro.serde_conv.html" title="macro serde_with::serde_conv">serde_conv</a></div><div class="desc docblock-short">Create new conversion adapters from functions</div></li><li><div class="item-name"><a class="macro" href="macro.with_prefix.html" title="macro serde_with::with_prefix">with_prefix</a></div><div class="desc docblock-short">Serialize with an added prefix on every field name and deserialize by
trimming away the prefix.</div></li></ul><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.As.html" title="struct serde_with::As">As</a></div><div class="desc docblock-short">Adapter to convert from <code>serde_as</code> to the serde traits.</div></li><li><div class="item-name"><a class="struct" href="struct.BoolFromInt.html" title="struct serde_with::BoolFromInt">BoolFromInt</a></div><div class="desc docblock-short">Deserialize a boolean from a number</div></li><li><div class="item-name"><a class="struct" href="struct.BorrowCow.html" title="struct serde_with::BorrowCow">BorrowCow</a></div><div class="desc docblock-short">Borrow <code>Cow</code> data during deserialization when possible.</div></li><li><div class="item-name"><a class="struct" href="struct.Bytes.html" title="struct serde_with::Bytes">Bytes</a></div><div class="desc docblock-short">Optimized handling of owned and borrowed byte representations.</div></li><li><div class="item-name"><a class="struct" href="struct.BytesOrString.html" title="struct serde_with::BytesOrString">BytesOrString</a></div><div class="desc docblock-short">Deserialize from bytes or string</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultOnError.html" title="struct serde_with::DefaultOnError">DefaultOnError</a></div><div class="desc docblock-short">Deserialize value and return <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html" title="trait core::default::Default"><code>Default</code></a> on error</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultOnNull.html" title="struct serde_with::DefaultOnNull">DefaultOnNull</a></div><div class="desc docblock-short">Deserialize <a href="https://doc.rust-lang.org/1.76.0/core/default/trait.Default.html" title="trait core::default::Default"><code>Default</code></a> from <code>null</code> values</div></li><li><div class="item-name"><a class="struct" href="struct.DisplayFromStr.html" title="struct serde_with::DisplayFromStr">DisplayFromStr</a></div><div class="desc docblock-short">De/Serialize using <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>Display</code></a> and <a href="https://doc.rust-lang.org/1.76.0/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr"><code>FromStr</code></a> implementation</div></li><li><div class="item-name"><a class="struct" href="struct.DurationMicroSeconds.html" title="struct serde_with::DurationMicroSeconds">DurationMicroSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSeconds.html" title="struct serde_with::DurationSeconds"><code>DurationSeconds</code></a> with micro-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationMicroSecondsWithFrac.html" title="struct serde_with::DurationMicroSecondsWithFrac">DurationMicroSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSecondsWithFrac.html" title="struct serde_with::DurationSecondsWithFrac"><code>DurationSecondsWithFrac</code></a> with micro-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationMilliSeconds.html" title="struct serde_with::DurationMilliSeconds">DurationMilliSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSeconds.html" title="struct serde_with::DurationSeconds"><code>DurationSeconds</code></a> with milli-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationMilliSecondsWithFrac.html" title="struct serde_with::DurationMilliSecondsWithFrac">DurationMilliSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSecondsWithFrac.html" title="struct serde_with::DurationSecondsWithFrac"><code>DurationSecondsWithFrac</code></a> with milli-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationNanoSeconds.html" title="struct serde_with::DurationNanoSeconds">DurationNanoSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSeconds.html" title="struct serde_with::DurationSeconds"><code>DurationSeconds</code></a> with nano-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationNanoSecondsWithFrac.html" title="struct serde_with::DurationNanoSecondsWithFrac">DurationNanoSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.DurationSecondsWithFrac.html" title="struct serde_with::DurationSecondsWithFrac"><code>DurationSecondsWithFrac</code></a> with nano-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationSeconds.html" title="struct serde_with::DurationSeconds">DurationSeconds</a></div><div class="desc docblock-short">De/Serialize Durations as number of seconds.</div></li><li><div class="item-name"><a class="struct" href="struct.DurationSecondsWithFrac.html" title="struct serde_with::DurationSecondsWithFrac">DurationSecondsWithFrac</a></div><div class="desc docblock-short">De/Serialize Durations as number of seconds.</div></li><li><div class="item-name"><a class="struct" href="struct.EnumMap.html" title="struct serde_with::EnumMap">EnumMap</a></div><div class="desc docblock-short">Represent a list of enum values as a map.</div></li><li><div class="item-name"><a class="struct" href="struct.FromInto.html" title="struct serde_with::FromInto">FromInto</a></div><div class="desc docblock-short">Serialize value by converting to/from a proxy type with serde support.</div></li><li><div class="item-name"><a class="struct" href="struct.KeyValueMap.html" title="struct serde_with::KeyValueMap">KeyValueMap</a></div><div class="desc docblock-short">Convert <code>Vec</code> elements into key-value map entries</div></li><li><div class="item-name"><a class="struct" href="struct.Map.html" title="struct serde_with::Map">Map</a></div><div class="desc docblock-short">This serializes a list of tuples into a map</div></li><li><div class="item-name"><a class="struct" href="struct.MapFirstKeyWins.html" title="struct serde_with::MapFirstKeyWins">MapFirstKeyWins</a></div><div class="desc docblock-short">Ensure that the last value is taken, if duplicate values exist</div></li><li><div class="item-name"><a class="struct" href="struct.MapPreventDuplicates.html" title="struct serde_with::MapPreventDuplicates">MapPreventDuplicates</a></div><div class="desc docblock-short">Ensure no duplicate keys exist in a map.</div></li><li><div class="item-name"><a class="struct" href="struct.NoneAsEmptyString.html" title="struct serde_with::NoneAsEmptyString">NoneAsEmptyString</a></div><div class="desc docblock-short">De/Serialize a <a href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html" title="enum core::option::Option"><code>Option&lt;String&gt;</code></a> type while transforming the empty string to <a href="https://doc.rust-lang.org/1.76.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a></div></li><li><div class="item-name"><a class="struct" href="struct.OneOrMany.html" title="struct serde_with::OneOrMany">OneOrMany</a></div><div class="desc docblock-short">Deserialize one or many elements</div></li><li><div class="item-name"><a class="struct" href="struct.PickFirst.html" title="struct serde_with::PickFirst">PickFirst</a></div><div class="desc docblock-short">Try multiple deserialization options until one succeeds.</div></li><li><div class="item-name"><a class="struct" href="struct.Same.html" title="struct serde_with::Same">Same</a></div><div class="desc docblock-short">Adapter to convert from <code>serde_as</code> to the serde traits.</div></li><li><div class="item-name"><a class="struct" href="struct.Seq.html" title="struct serde_with::Seq">Seq</a></div><div class="desc docblock-short">De/Serialize a Map into a list of tuples</div></li><li><div class="item-name"><a class="struct" href="struct.SetLastValueWins.html" title="struct serde_with::SetLastValueWins">SetLastValueWins</a></div><div class="desc docblock-short">Ensure that the last value is taken, if duplicate values exist</div></li><li><div class="item-name"><a class="struct" href="struct.SetPreventDuplicates.html" title="struct serde_with::SetPreventDuplicates">SetPreventDuplicates</a></div><div class="desc docblock-short">Ensure no duplicate values exist in a set.</div></li><li><div class="item-name"><a class="struct" href="struct.StringWithSeparator.html" title="struct serde_with::StringWithSeparator">StringWithSeparator</a></div><div class="desc docblock-short">De/Serialize a delimited collection using <a href="https://doc.rust-lang.org/1.76.0/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>Display</code></a> and <a href="https://doc.rust-lang.org/1.76.0/core/str/traits/trait.FromStr.html" title="trait core::str::traits::FromStr"><code>FromStr</code></a> implementation</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampMicroSeconds.html" title="struct serde_with::TimestampMicroSeconds">TimestampMicroSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSeconds.html" title="struct serde_with::TimestampSeconds"><code>TimestampSeconds</code></a> with micro-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampMicroSecondsWithFrac.html" title="struct serde_with::TimestampMicroSecondsWithFrac">TimestampMicroSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSecondsWithFrac.html" title="struct serde_with::TimestampSecondsWithFrac"><code>TimestampSecondsWithFrac</code></a> with micro-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampMilliSeconds.html" title="struct serde_with::TimestampMilliSeconds">TimestampMilliSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSeconds.html" title="struct serde_with::TimestampSeconds"><code>TimestampSeconds</code></a> with milli-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampMilliSecondsWithFrac.html" title="struct serde_with::TimestampMilliSecondsWithFrac">TimestampMilliSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSecondsWithFrac.html" title="struct serde_with::TimestampSecondsWithFrac"><code>TimestampSecondsWithFrac</code></a> with milli-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampNanoSeconds.html" title="struct serde_with::TimestampNanoSeconds">TimestampNanoSeconds</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSeconds.html" title="struct serde_with::TimestampSeconds"><code>TimestampSeconds</code></a> with nano-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampNanoSecondsWithFrac.html" title="struct serde_with::TimestampNanoSecondsWithFrac">TimestampNanoSecondsWithFrac</a></div><div class="desc docblock-short">Equivalent to <a href="struct.TimestampSecondsWithFrac.html" title="struct serde_with::TimestampSecondsWithFrac"><code>TimestampSecondsWithFrac</code></a> with nano-seconds as base unit.</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampSeconds.html" title="struct serde_with::TimestampSeconds">TimestampSeconds</a></div><div class="desc docblock-short">De/Serialize timestamps as seconds since the UNIX epoch</div></li><li><div class="item-name"><a class="struct" href="struct.TimestampSecondsWithFrac.html" title="struct serde_with::TimestampSecondsWithFrac">TimestampSecondsWithFrac</a></div><div class="desc docblock-short">De/Serialize timestamps as seconds since the UNIX epoch</div></li><li><div class="item-name"><a class="struct" href="struct.TryFromInto.html" title="struct serde_with::TryFromInto">TryFromInto</a></div><div class="desc docblock-short">Serialize value by converting to/from a proxy type with serde support.</div></li><li><div class="item-name"><a class="struct" href="struct.VecSkipError.html" title="struct serde_with::VecSkipError">VecSkipError</a></div><div class="desc docblock-short">Deserialize a sequence into <code>Vec&lt;T&gt;</code>, skipping elements which fail to deserialize.</div></li></ul><h2 id="traits" class="section-header"><a href="#traits">Traits</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.DeserializeAs.html" title="trait serde_with::DeserializeAs">DeserializeAs</a></div><div class="desc docblock-short">A <strong>data structure</strong> that can be deserialized from any data format supported by Serde, analogue to <a href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize"><code>Deserialize</code></a>.</div></li><li><div class="item-name"><a class="trait" href="trait.SerializeAs.html" title="trait serde_with::SerializeAs">SerializeAs</a></div><div class="desc docblock-short">A <strong>data structure</strong> that can be serialized into any data format supported by Serde, analogue to <a href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize"><code>Serialize</code></a>.</div></li></ul><h2 id="attributes" class="section-header"><a href="#attributes">Attribute Macros</a></h2><ul class="item-table"><li><div class="item-name"><a class="attr" href="attr.apply.html" title="attr serde_with::apply">apply</a></div><div class="desc docblock-short">Apply attributes to all fields with matching types</div></li><li><div class="item-name"><a class="attr" href="attr.serde_as.html" title="attr serde_with::serde_as">serde_as</a></div><div class="desc docblock-short">Convenience macro to use the <a href="https://docs.rs/serde_with/2.3.3/serde_with/guide/index.html"><code>serde_as</code></a> system.</div></li><li><div class="item-name"><a class="attr" href="attr.skip_serializing_none.html" title="attr serde_with::skip_serializing_none">skip_serializing_none</a></div><div class="desc docblock-short">Add <code>skip_serializing_if</code> annotations to [<code>Option</code>] fields.</div></li></ul><h2 id="derives" class="section-header"><a href="#derives">Derive Macros</a></h2><ul class="item-table"><li><div class="item-name"><a class="derive" href="derive.DeserializeFromStr.html" title="derive serde_with::DeserializeFromStr">DeserializeFromStr</a></div><div class="desc docblock-short">Deserialize value by using its <a href="std::str::FromStr"><code>FromStr</code></a> implementation</div></li><li><div class="item-name"><a class="derive" href="derive.SerializeDisplay.html" title="derive serde_with::SerializeDisplay">SerializeDisplay</a></div><div class="desc docblock-short">Serialize value by using its <a href="std::fmt::Display"><code>Display</code></a> implementation</div></li></ul></section></div></main></body></html>