mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-22 02:03:38 +00:00
deploy: de38ae62916547ad097c066f94a32e9ba7790eeb
This commit is contained in:
commit
9a86359447
28502 changed files with 1261284 additions and 0 deletions
1
serde_json/all.html
Normal file
1
serde_json/all.html
Normal file
File diff suppressed because one or more lines are too long
83
serde_json/de/fn.from_reader.html
Normal file
83
serde_json/de/fn.from_reader.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!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="Deserialize an instance of type `T` from an I/O stream of JSON."><title>from_reader in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>reader</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Function <span class="fn">from_reader</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/de.rs.html#2607-2613">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_reader<R, T>(rdr: R) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
|
||||
T: <a class="trait" href="../../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from an I/O stream of JSON.</p>
|
||||
<p>The content of the I/O stream is deserialized directly from the stream
|
||||
without being buffered in memory by serde_json.</p>
|
||||
<p>When reading from a source against which short reads are not efficient, such
|
||||
as a <a href="https://doc.rust-lang.org/std/fs/struct.File.html"><code>File</code></a>, you will want to apply your own buffering because serde_json
|
||||
will not buffer the input. See <a href="https://doc.rust-lang.org/std/io/struct.BufReader.html"><code>std::io::BufReader</code></a>.</p>
|
||||
<p>It is expected that the input stream ends after the deserialized object.
|
||||
If the stream does not end, such as in the case of a persistent socket connection,
|
||||
this function will not return. It is possible instead to deserialize from a prefix of an input
|
||||
stream without looking for EOF by managing your own <a href="../struct.Deserializer.html" title="struct serde_json::Deserializer"><code>Deserializer</code></a>.</p>
|
||||
<p>Note that counter to intuition, this function is usually slower than
|
||||
reading a file completely into memory and then applying <a href="./fn.from_str.html"><code>from_str</code></a>
|
||||
or <a href="./fn.from_slice.html"><code>from_slice</code></a> on it. See <a href="https://github.com/serde-rs/json/issues/160">issue #160</a>.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<p>Reading the contents of a file.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
<span class="kw">use </span>std::fs::File;
|
||||
<span class="kw">use </span>std::io::BufReader;
|
||||
<span class="kw">use </span>std::path::Path;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>read_user_from_file<P: AsRef<Path>>(path: P) -> <span class="prelude-ty">Result</span><User, Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="comment">// Open the file in read-only mode with buffer.
|
||||
</span><span class="kw">let </span>file = File::open(path)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>reader = BufReader::new(file);
|
||||
|
||||
<span class="comment">// Read the JSON contents of the file as an instance of `User`.
|
||||
</span><span class="kw">let </span>u = serde_json::from_reader(reader)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Return the `User`.
|
||||
</span><span class="prelude-val">Ok</span>(u)
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="kw">let </span>u = read_user_from_file(<span class="string">"test.json"</span>).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<p>Reading from a persistent socket connection.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
<span class="kw">use </span>std::net::{TcpListener, TcpStream};
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>read_user_from_stream(tcp_stream: TcpStream) -> <span class="prelude-ty">Result</span><User, Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>de = serde_json::Deserializer::from_reader(tcp_stream);
|
||||
<span class="kw">let </span>u = User::deserialize(<span class="kw-2">&mut </span>de)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(u)
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="kw">let </span>listener = TcpListener::bind(<span class="string">"127.0.0.1:4000"</span>).unwrap();
|
||||
|
||||
<span class="kw">for </span>stream <span class="kw">in </span>listener.incoming() {
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, read_user_from_stream(stream.unwrap()));
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
31
serde_json/de/fn.from_slice.html
Normal file
31
serde_json/de/fn.from_slice.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Deserialize an instance of type `T` from bytes of JSON text."><title>from_slice in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>slice</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Function <span class="fn">from_slice</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/de.rs.html#2650-2655">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_slice<'a, T>(v: &'a [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
T: <a class="trait" href="../../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from bytes of JSON text.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `&[u8]`
|
||||
</span><span class="kw">let </span>j = <span class="string">b"
|
||||
{
|
||||
\"fingerprint\": \"0xF9BA143B95FF6D82\",
|
||||
\"location\": \"Menlo Park, CA\"
|
||||
}"</span>;
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_slice(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
31
serde_json/de/fn.from_str.html
Normal file
31
serde_json/de/fn.from_str.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Deserialize an instance of type `T` from a string of JSON text."><title>from_str in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>str</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Function <span class="fn">from_str</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/de.rs.html#2692-2697">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_str<'a, T>(s: &'a <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
T: <a class="trait" href="../../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from a string of JSON text.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `&str`
|
||||
</span><span class="kw">let </span>j = <span class="string">"
|
||||
{
|
||||
\"fingerprint\": \"0xF9BA143B95FF6D82\",
|
||||
\"location\": \"Menlo Park, CA\"
|
||||
}"</span>;
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_str(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
4
serde_json/de/index.html
Normal file
4
serde_json/de/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!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="Deserialize JSON data to a Rust data structure."><title>serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module de</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a></span><h1>Module <span>de</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/de.rs.html#1-2697">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize JSON data to a Rust data structure.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Deserializer.html" title="struct serde_json::de::Deserializer">Deserializer</a></div><div class="desc docblock-short">A structure that deserializes JSON into Rust values.</div></li><li><div class="item-name"><a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a></div><div class="desc docblock-short">JSON input source that reads from a std::io input stream.</div></li><li><div class="item-name"><a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">Slice<wbr>Read</a></div><div class="desc docblock-short">JSON input source that reads from a slice of bytes.</div></li><li><div class="item-name"><a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a></div><div class="desc docblock-short">JSON input source that reads from a UTF-8 string.</div></li><li><div class="item-name"><a class="struct" href="struct.StreamDeserializer.html" title="struct serde_json::de::StreamDeserializer">Stream<wbr>Deserializer</a></div><div class="desc docblock-short">Iterator that deserializes a stream into multiple JSON values.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a></div><div class="desc docblock-short">Trait used by the deserializer for iterating over input. This is manually
|
||||
“specialized” for iterating over <code>&[u8]</code>. Once feature(specialization) is
|
||||
stable we can use actual specialization.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.from_reader.html" title="fn serde_json::de::from_reader">from_<wbr>reader</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from an I/O stream of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.from_slice.html" title="fn serde_json::de::from_slice">from_<wbr>slice</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from bytes of JSON text.</div></li><li><div class="item-name"><a class="fn" href="fn.from_str.html" title="fn serde_json::de::from_str">from_<wbr>str</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from a string of JSON text.</div></li></ul></section></div></main></body></html>
|
||||
1
serde_json/de/sidebar-items.js
Normal file
1
serde_json/de/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"fn":["from_reader","from_slice","from_str"],"struct":["Deserializer","IoRead","SliceRead","StrRead","StreamDeserializer"],"trait":["Read"]};
|
||||
167
serde_json/de/struct.Deserializer.html
Normal file
167
serde_json/de/struct.Deserializer.html
Normal file
File diff suppressed because one or more lines are too long
22
serde_json/de/struct.IoRead.html
Normal file
22
serde_json/de/struct.IoRead.html
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
<!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="JSON input source that reads from a std::io input stream."><title>IoRead in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">IoRead</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Read%3C'de%3E-for-IoRead%3CR%3E" title="Read<'de>">Read<'de></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-IoRead%3CR%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-IoRead%3CR%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-IoRead%3CR%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-IoRead%3CR%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-IoRead%3CR%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-IoRead%3CR%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Struct <span class="struct">IoRead</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/read.rs.html#149-158">Source</a> </span></div><pre class="rust item-decl"><code>pub struct IoRead<R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</div>{ <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>JSON input source that reads from a std::io input stream.</p>
|
||||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-IoRead%3CR%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#189-202">Source</a><a href="#impl-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/serde_json/read.rs.html#194-201">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(reader: R) -> Self</h4></section></summary><div class="docblock"><p>Create a JSON input source to read from a std::io input stream.</p>
|
||||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><section id="impl-Read%3C'de%3E-for-IoRead%3CR%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#247-400">Source</a><a href="#impl-Read%3C'de%3E-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<'de, R> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'de> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</div></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-IoRead%3CR%3E" class="impl"><a href="#impl-Freeze-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a>,</div></h3></section><section id="impl-RefUnwindSafe-for-IoRead%3CR%3E" class="impl"><a href="#impl-RefUnwindSafe-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,</div></h3></section><section id="impl-Send-for-IoRead%3CR%3E" class="impl"><a href="#impl-Send-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</div></h3></section><section id="impl-Sync-for-IoRead%3CR%3E" class="impl"><a href="#impl-Sync-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,</div></h3></section><section id="impl-Unpin-for-IoRead%3CR%3E" class="impl"><a href="#impl-Unpin-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-IoRead%3CR%3E" class="impl"><a href="#impl-UnwindSafe-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<R> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
13
serde_json/de/struct.SliceRead.html
Normal file
13
serde_json/de/struct.SliceRead.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!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="JSON input source that reads from a slice of bytes."><title>SliceRead in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Slice<wbr>Read</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Read%3C'a%3E-for-SliceRead%3C'a%3E" title="Read<'a>">Read<'a></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-SliceRead%3C'a%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-SliceRead%3C'a%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-SliceRead%3C'a%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-SliceRead%3C'a%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-SliceRead%3C'a%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-SliceRead%3C'a%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Struct <span class="struct">SliceRead</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/read.rs.html#164-170">Source</a> </span></div><pre class="rust item-decl"><code>pub struct SliceRead<'a> { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>JSON input source that reads from a slice of bytes.</p>
|
||||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-SliceRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#404-533">Source</a><a href="#impl-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/serde_json/read.rs.html#406-413">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(slice: &'a [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]) -> Self</h4></section></summary><div class="docblock"><p>Create a JSON input source to read from a slice of bytes.</p>
|
||||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><section id="impl-Read%3C'a%3E-for-SliceRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#537-658">Source</a><a href="#impl-Read%3C'a%3E-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-Freeze-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-RefUnwindSafe-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-RefUnwindSafe-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-Send-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-Send-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-Sync-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-Sync-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-Unpin-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-Unpin-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-UnwindSafe-for-SliceRead%3C'a%3E" class="impl"><a href="#impl-UnwindSafe-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
13
serde_json/de/struct.StrRead.html
Normal file
13
serde_json/de/struct.StrRead.html
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
<!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="JSON input source that reads from a UTF-8 string."><title>StrRead in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">StrRead</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.new" title="new">new</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Read%3C'a%3E-for-StrRead%3C'a%3E" title="Read<'a>">Read<'a></a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-StrRead%3C'a%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-StrRead%3C'a%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-StrRead%3C'a%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-StrRead%3C'a%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-StrRead%3C'a%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-StrRead%3C'a%3E" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Struct <span class="struct">StrRead</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/read.rs.html#175-179">Source</a> </span></div><pre class="rust item-decl"><code>pub struct StrRead<'a> { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>JSON input source that reads from a UTF-8 string.</p>
|
||||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-StrRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#662-671">Source</a><a href="#impl-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../../src/serde_json/read.rs.html#664-670">Source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a>(s: &'a <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> Self</h4></section></summary><div class="docblock"><p>Create a JSON input source to read from a UTF-8 string.</p>
|
||||
</div></details></div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><section id="impl-Read%3C'a%3E-for-StrRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#675-750">Source</a><a href="#impl-Read%3C'a%3E-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-StrRead%3C'a%3E" class="impl"><a href="#impl-Freeze-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-RefUnwindSafe-for-StrRead%3C'a%3E" class="impl"><a href="#impl-RefUnwindSafe-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-Send-for-StrRead%3C'a%3E" class="impl"><a href="#impl-Send-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-Sync-for-StrRead%3C'a%3E" class="impl"><a href="#impl-Sync-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-Unpin-for-StrRead%3C'a%3E" class="impl"><a href="#impl-Unpin-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-UnwindSafe-for-StrRead%3C'a%3E" class="impl"><a href="#impl-UnwindSafe-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
276
serde_json/de/struct.StreamDeserializer.html
Normal file
276
serde_json/de/struct.StreamDeserializer.html
Normal file
File diff suppressed because one or more lines are too long
8
serde_json/de/trait.Read.html
Normal file
8
serde_json/de/trait.Read.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!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 the deserializer for iterating over input. This is manually “specialized” for iterating over `&[u8]`. Once feature(specialization) is stable we can use actual specialization."><title>Read in serde_json::de - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Read</a></h2><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Read%3C'de%3E-for-%26mut+R" title="&mut R">&mut R</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>de</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">de</a></span><h1>Trait <span class="trait">Read</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/read.rs.html#28-117">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Read<'de>: Sealed { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Trait used by the deserializer for iterating over input. This is manually
|
||||
“specialized” for iterating over <code>&[u8]</code>. Once feature(specialization) is
|
||||
stable we can use actual specialization.</p>
|
||||
<p>This trait is sealed and cannot be implemented for types outside of
|
||||
<code>serde_json</code>.</p>
|
||||
</div></details><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.1/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-Read%3C'de%3E-for-%26mut+R" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#756-821">Source</a><a href="#impl-Read%3C'de%3E-for-%26mut+R" class="anchor">§</a><h3 class="code-header">impl<'de, R> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'de> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut R</a><div class="where">where
|
||||
R: <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'de>,</div></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Read%3C'a%3E-for-SliceRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#537-658">Source</a><a href="#impl-Read%3C'a%3E-for-SliceRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'a> for <a class="struct" href="struct.SliceRead.html" title="struct serde_json::de::SliceRead">SliceRead</a><'a></h3></section><section id="impl-Read%3C'a%3E-for-StrRead%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#675-750">Source</a><a href="#impl-Read%3C'a%3E-for-StrRead%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'a> for <a class="struct" href="struct.StrRead.html" title="struct serde_json::de::StrRead">StrRead</a><'a></h3></section><section id="impl-Read%3C'de%3E-for-IoRead%3CR%3E" class="impl"><a class="src rightside" href="../../src/serde_json/read.rs.html#247-400">Source</a><a href="#impl-Read%3C'de%3E-for-IoRead%3CR%3E" class="anchor">§</a><h3 class="code-header">impl<'de, R> <a class="trait" href="trait.Read.html" title="trait serde_json::de::Read">Read</a><'de> for <a class="struct" href="struct.IoRead.html" title="struct serde_json::de::IoRead">IoRead</a><R><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,</div></h3></section></div><script src="../../trait.impl/serde_json/read/trait.Read.js" async></script></section></div></main></body></html>
|
||||
756
serde_json/enum.Value.html
Normal file
756
serde_json/enum.Value.html
Normal file
File diff suppressed because one or more lines are too long
29
serde_json/error/enum.Category.html
Normal file
29
serde_json/error/enum.Category.html
Normal file
File diff suppressed because one or more lines are too long
3
serde_json/error/index.html
Normal file
3
serde_json/error/index.html
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<!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="When serializing or deserializing JSON goes wrong."><title>serde_json::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module error</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a></span><h1>Module <span>error</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/error.rs.html#1-541">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>When serializing or deserializing JSON goes wrong.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Error.html" title="struct serde_json::error::Error">Error</a></div><div class="desc docblock-short">This type represents all possible errors that can occur when serializing or
|
||||
deserializing JSON data.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Category.html" title="enum serde_json::error::Category">Category</a></div><div class="desc docblock-short">Categorizes the cause of a <code>serde_json::Error</code>.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.Result.html" title="type serde_json::error::Result">Result</a></div><div class="desc docblock-short">Alias for a <code>Result</code> with the error type <code>serde_json::Error</code>.</div></li></ul></section></div></main></body></html>
|
||||
1
serde_json/error/sidebar-items.js
Normal file
1
serde_json/error/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["Category"],"struct":["Error"],"type":["Result"]};
|
||||
110
serde_json/error/struct.Error.html
Normal file
110
serde_json/error/struct.Error.html
Normal file
File diff suppressed because one or more lines are too long
7
serde_json/error/type.Result.html
Normal file
7
serde_json/error/type.Result.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!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="Alias for a `Result` with the error type `serde_json::Error`."><title>Result in serde_json::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Result</a></h2><h3><a href="#aliased-type">Aliased type</a></h3><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Err" title="Err">Err</a></li><li><a href="#variant.Ok" title="Ok">Ok</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>error</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">error</a></span><h1>Type Alias <span class="type">Result</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/error.rs.html#25">Source</a> </span></div><pre class="rust item-decl"><code>pub type Result<T> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../struct.Error.html" title="struct serde_json::Error">Error</a>>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Alias for a <code>Result</code> with the error type <code>serde_json::Error</code>.</p>
|
||||
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>enum Result<T> {
|
||||
Ok(T),
|
||||
Err(<a class="struct" href="../struct.Error.html" title="struct serde_json::Error">Error</a>),
|
||||
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Ok" class="variant"><a href="#variant.Ok" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Ok(T)</h3></section><div class="docblock"><p>Contains the success value</p>
|
||||
</div><section id="variant.Err" class="variant"><a href="#variant.Err" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Err(<a class="struct" href="../struct.Error.html" title="struct serde_json::Error">Error</a>)</h3></section><div class="docblock"><p>Contains the error value</p>
|
||||
</div></div><script src="../../type.impl/core/result/enum.Result.js" data-self-path="serde_json::error::Result" async></script></section></div></main></body></html>
|
||||
83
serde_json/fn.from_reader.html
Normal file
83
serde_json/fn.from_reader.html
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
<!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="Deserialize an instance of type `T` from an I/O stream of JSON."><title>from_reader in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>reader</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">from_reader</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/de.rs.html#2607-2613">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_reader<R, T>(rdr: R) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
R: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Read.html" title="trait std::io::Read">Read</a>,
|
||||
T: <a class="trait" href="../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from an I/O stream of JSON.</p>
|
||||
<p>The content of the I/O stream is deserialized directly from the stream
|
||||
without being buffered in memory by serde_json.</p>
|
||||
<p>When reading from a source against which short reads are not efficient, such
|
||||
as a <a href="https://doc.rust-lang.org/std/fs/struct.File.html"><code>File</code></a>, you will want to apply your own buffering because serde_json
|
||||
will not buffer the input. See <a href="https://doc.rust-lang.org/std/io/struct.BufReader.html"><code>std::io::BufReader</code></a>.</p>
|
||||
<p>It is expected that the input stream ends after the deserialized object.
|
||||
If the stream does not end, such as in the case of a persistent socket connection,
|
||||
this function will not return. It is possible instead to deserialize from a prefix of an input
|
||||
stream without looking for EOF by managing your own <a href="struct.Deserializer.html" title="struct serde_json::Deserializer"><code>Deserializer</code></a>.</p>
|
||||
<p>Note that counter to intuition, this function is usually slower than
|
||||
reading a file completely into memory and then applying <a href="./fn.from_str.html"><code>from_str</code></a>
|
||||
or <a href="./fn.from_slice.html"><code>from_slice</code></a> on it. See <a href="https://github.com/serde-rs/json/issues/160">issue #160</a>.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<p>Reading the contents of a file.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
<span class="kw">use </span>std::fs::File;
|
||||
<span class="kw">use </span>std::io::BufReader;
|
||||
<span class="kw">use </span>std::path::Path;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>read_user_from_file<P: AsRef<Path>>(path: P) -> <span class="prelude-ty">Result</span><User, Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="comment">// Open the file in read-only mode with buffer.
|
||||
</span><span class="kw">let </span>file = File::open(path)<span class="question-mark">?</span>;
|
||||
<span class="kw">let </span>reader = BufReader::new(file);
|
||||
|
||||
<span class="comment">// Read the JSON contents of the file as an instance of `User`.
|
||||
</span><span class="kw">let </span>u = serde_json::from_reader(reader)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Return the `User`.
|
||||
</span><span class="prelude-val">Ok</span>(u)
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="kw">let </span>u = read_user_from_file(<span class="string">"test.json"</span>).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<p>Reading from a persistent socket connection.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
<span class="kw">use </span>std::net::{TcpListener, TcpStream};
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>read_user_from_stream(tcp_stream: TcpStream) -> <span class="prelude-ty">Result</span><User, Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>de = serde_json::Deserializer::from_reader(tcp_stream);
|
||||
<span class="kw">let </span>u = User::deserialize(<span class="kw-2">&mut </span>de)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="prelude-val">Ok</span>(u)
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="kw">let </span>listener = TcpListener::bind(<span class="string">"127.0.0.1:4000"</span>).unwrap();
|
||||
|
||||
<span class="kw">for </span>stream <span class="kw">in </span>listener.incoming() {
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, read_user_from_stream(stream.unwrap()));
|
||||
}
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
31
serde_json/fn.from_slice.html
Normal file
31
serde_json/fn.from_slice.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Deserialize an instance of type `T` from bytes of JSON text."><title>from_slice in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>slice</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">from_slice</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/de.rs.html#2650-2655">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_slice<'a, T>(v: &'a [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>]) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
T: <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from bytes of JSON text.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `&[u8]`
|
||||
</span><span class="kw">let </span>j = <span class="string">b"
|
||||
{
|
||||
\"fingerprint\": \"0xF9BA143B95FF6D82\",
|
||||
\"location\": \"Menlo Park, CA\"
|
||||
}"</span>;
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_slice(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
31
serde_json/fn.from_str.html
Normal file
31
serde_json/fn.from_str.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Deserialize an instance of type `T` from a string of JSON text."><title>from_str in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>str</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">from_str</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/de.rs.html#2692-2697">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_str<'a, T>(s: &'a <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><T><div class="where">where
|
||||
T: <a class="trait" href="../serde/de/trait.Deserialize.html" title="trait serde::de::Deserialize">Deserialize</a><'a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Deserialize an instance of type <code>T</code> from a string of JSON text.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `&str`
|
||||
</span><span class="kw">let </span>j = <span class="string">"
|
||||
{
|
||||
\"fingerprint\": \"0xF9BA143B95FF6D82\",
|
||||
\"location\": \"Menlo Park, CA\"
|
||||
}"</span>;
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_str(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the input does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the input
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
31
serde_json/fn.from_value.html
Normal file
31
serde_json/fn.from_value.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Interpret a `serde_json::Value` as an instance of type `T`."><title>from_value in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>value</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">from_value</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/value/mod.rs.html#1030-1035">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_value<T>(value: <a class="enum" href="enum.Value.html" title="enum serde_json::Value">Value</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a>><div class="where">where
|
||||
T: <a class="trait" href="../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Interpret a <code>serde_json::Value</code> as an instance of type <code>T</code>.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
<span class="kw">use </span>serde_json::json;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>j = <span class="macro">json!</span>({
|
||||
<span class="string">"fingerprint"</span>: <span class="string">"0xF9BA143B95FF6D82"</span>,
|
||||
<span class="string">"location"</span>: <span class="string">"Menlo Park, CA"
|
||||
</span>});
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_value(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the Value does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the Value
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/fn.to_string.html
Normal file
6
serde_json/fn.to_string.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a String of JSON."><title>to_string in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>string</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_string</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2209-2219">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_string<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a String of JSON.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/fn.to_string_pretty.html
Normal file
6
serde_json/fn.to_string_pretty.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a pretty-printed String of JSON."><title>to_string_pretty in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>string_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_string_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2228-2238">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_string_pretty<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a pretty-printed String of JSON.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
45
serde_json/fn.to_value.html
Normal file
45
serde_json/fn.to_value.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="Convert a `T` into `serde_json::Value` which is an enum that can represent any valid JSON data."><title>to_value in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>value</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_value</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/value/mod.rs.html#988-993">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_value<T>(value: T) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="enum" href="enum.Value.html" title="enum serde_json::Value">Value</a>, <a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a>><div class="where">where
|
||||
T: <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Convert a <code>T</code> into <code>serde_json::Value</code> which is an enum that can represent
|
||||
any valid JSON data.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Serialize;
|
||||
<span class="kw">use </span>serde_json::json;
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
|
||||
<span class="attr">#[derive(Serialize)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>compare_json_values() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="kw">let </span>u = User {
|
||||
fingerprint: <span class="string">"0xF9BA143B95FF6D82"</span>.to_owned(),
|
||||
location: <span class="string">"Menlo Park, CA"</span>.to_owned(),
|
||||
};
|
||||
|
||||
<span class="comment">// The type of `expected` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>expected = <span class="macro">json!</span>({
|
||||
<span class="string">"fingerprint"</span>: <span class="string">"0xF9BA143B95FF6D82"</span>,
|
||||
<span class="string">"location"</span>: <span class="string">"Menlo Park, CA"</span>,
|
||||
});
|
||||
|
||||
<span class="kw">let </span>v = serde_json::to_value(u).unwrap();
|
||||
<span class="macro">assert_eq!</span>(v, expected);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::collections::BTreeMap;
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The keys in this map are vectors, not strings.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>map = BTreeMap::new();
|
||||
map.insert(<span class="macro">vec!</span>[<span class="number">32</span>, <span class="number">64</span>], <span class="string">"x86"</span>);
|
||||
|
||||
<span class="macro">println!</span>(<span class="string">"{}"</span>, serde_json::to_value(map).unwrap_err());
|
||||
}</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/fn.to_vec.html
Normal file
6
serde_json/fn.to_vec.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a JSON byte vector."><title>to_vec in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_vec</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_vec</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2177-2184">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_vec<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a JSON byte vector.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/fn.to_vec_pretty.html
Normal file
6
serde_json/fn.to_vec_pretty.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a pretty-printed JSON byte vector."><title>to_vec_pretty in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>vec_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_vec_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2193-2200">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_vec_pretty<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a pretty-printed JSON byte vector.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
8
serde_json/fn.to_writer.html
Normal file
8
serde_json/fn.to_writer.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!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="Serialize the given data structure as JSON into the I/O stream."><title>to_writer in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>writer</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_writer</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2141-2148">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_writer<W, T>(writer: W, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as JSON into the I/O stream.</p>
|
||||
<p>Serialization guarantees it only feeds valid UTF-8 sequences to the writer.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
9
serde_json/fn.to_writer_pretty.html
Normal file
9
serde_json/fn.to_writer_pretty.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!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="Serialize the given data structure as pretty-printed JSON into the I/O stream."><title>to_writer_pretty in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>writer_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Function <span class="fn">to_writer_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/ser.rs.html#2161-2168">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_writer_pretty<W, T>(writer: W, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="type.Result.html" title="type serde_json::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as pretty-printed JSON into the I/O
|
||||
stream.</p>
|
||||
<p>Serialization guarantees it only feeds valid UTF-8 sequences to the writer.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
230
serde_json/index.html
Normal file
230
serde_json/index.html
Normal file
|
|
@ -0,0 +1,230 @@
|
|||
<!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="Serde JSON"><title>serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod 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" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#serde-json" title="Serde JSON">Serde JSON</a></li><li><a href="#operating-on-untyped-json-values" title="Operating on untyped JSON values">Operating on untyped JSON values</a></li><li><a href="#parsing-json-as-strongly-typed-data-structures" title="Parsing JSON as strongly typed data structures">Parsing JSON as strongly typed data structures</a></li><li><a href="#constructing-json-values" title="Constructing JSON values">Constructing JSON values</a></li><li><a href="#creating-json-by-serializing-data-structures" title="Creating JSON by serializing data structures">Creating JSON by serializing data structures</a></li><li><a href="#no-std-support" title="No-std support">No-std support</a></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#macros" title="Macros">Macros</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#types" title="Type Aliases">Type Aliases</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>serde_json</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/lib.rs.html#1-435">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="serde-json"><a class="doc-anchor" href="#serde-json">§</a>Serde JSON</h2>
|
||||
<p>JSON is a ubiquitous open-standard format that uses human-readable text to
|
||||
transmit data objects consisting of key-value pairs.</p>
|
||||
<div class="example-wrap"><pre class="language-json"><code>{
|
||||
"name": "John Doe",
|
||||
"age": 43,
|
||||
"address": {
|
||||
"street": "10 Downing Street",
|
||||
"city": "London"
|
||||
},
|
||||
"phones": [
|
||||
"+44 1234567",
|
||||
"+44 2345678"
|
||||
]
|
||||
}</code></pre></div>
|
||||
<p>There are three common ways that you might find yourself needing to work
|
||||
with JSON data in Rust.</p>
|
||||
<ul>
|
||||
<li><strong>As text data.</strong> An unprocessed string of JSON data that you receive on
|
||||
an HTTP endpoint, read from a file, or prepare to send to a remote
|
||||
server.</li>
|
||||
<li><strong>As an untyped or loosely typed representation.</strong> Maybe you want to
|
||||
check that some JSON data is valid before passing it on, but without
|
||||
knowing the structure of what it contains. Or you want to do very basic
|
||||
manipulations like insert a key in a particular spot.</li>
|
||||
<li><strong>As a strongly typed Rust data structure.</strong> When you expect all or most
|
||||
of your data to conform to a particular structure and want to get real
|
||||
work done without JSON’s loosey-goosey nature tripping you up.</li>
|
||||
</ul>
|
||||
<p>Serde JSON provides efficient, flexible, safe ways of converting data
|
||||
between each of these representations.</p>
|
||||
<h2 id="operating-on-untyped-json-values"><a class="doc-anchor" href="#operating-on-untyped-json-values">§</a>Operating on untyped JSON values</h2>
|
||||
<p>Any valid JSON data can be manipulated in the following recursive enum
|
||||
representation. This data structure is <a href="enum.Value.html" title="enum serde_json::Value"><code>serde_json::Value</code></a>.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">enum </span>Value {
|
||||
Null,
|
||||
Bool(bool),
|
||||
Number(Number),
|
||||
String(String),
|
||||
Array(Vec<Value>),
|
||||
Object(Map<String, Value>),
|
||||
}</code></pre></div>
|
||||
<p>A string of JSON data can be parsed into a <code>serde_json::Value</code> by the
|
||||
<a href="fn.from_str.html" title="fn serde_json::from_str"><code>serde_json::from_str</code></a> function. There is also <a href="fn.from_slice.html" title="fn serde_json::from_slice"><code>from_slice</code></a>
|
||||
for parsing from a byte slice <code>&[u8]</code> and <a href="fn.from_reader.html" title="fn serde_json::from_reader"><code>from_reader</code></a> for parsing from
|
||||
any <code>io::Read</code> like a File or a TCP stream.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::{<span class="prelude-ty">Result</span>, Value};
|
||||
|
||||
<span class="kw">fn </span>untyped_example() -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="comment">// Some JSON input data as a &str. Maybe this comes from the user.
|
||||
</span><span class="kw">let </span>data = <span class="string">r#"
|
||||
{
|
||||
"name": "John Doe",
|
||||
"age": 43,
|
||||
"phones": [
|
||||
"+44 1234567",
|
||||
"+44 2345678"
|
||||
]
|
||||
}"#</span>;
|
||||
|
||||
<span class="comment">// Parse the string of data into serde_json::Value.
|
||||
</span><span class="kw">let </span>v: Value = serde_json::from_str(data)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Access parts of the data by indexing with square brackets.
|
||||
</span><span class="macro">println!</span>(<span class="string">"Please call {} at the number {}"</span>, v[<span class="string">"name"</span>], v[<span class="string">"phones"</span>][<span class="number">0</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<p>The result of square bracket indexing like <code>v["name"]</code> is a borrow of the
|
||||
data at that index, so the type is <code>&Value</code>. A JSON map can be indexed with
|
||||
string keys, while a JSON array can be indexed with integer keys. If the
|
||||
type of the data is not right for the type with which it is being indexed,
|
||||
or if a map does not contain the key being indexed, or if the index into a
|
||||
vector is out of bounds, the returned element is <code>Value::Null</code>.</p>
|
||||
<p>When a <code>Value</code> is printed, it is printed as a JSON string. So in the code
|
||||
above, the output looks like <code>Please call "John Doe" at the number "+44 1234567"</code>. The quotation marks appear because <code>v["name"]</code> is a <code>&Value</code>
|
||||
containing a JSON string and its JSON representation is <code>"John Doe"</code>.
|
||||
Printing as a plain string without quotation marks involves converting from
|
||||
a JSON string to a Rust string with <a href="enum.Value.html#method.as_str" title="method serde_json::Value::as_str"><code>as_str()</code></a> or avoiding the use of
|
||||
<code>Value</code> as described in the following section.</p>
|
||||
<p>The <code>Value</code> representation is sufficient for very basic tasks but can be
|
||||
tedious to work with for anything more significant. Error handling is
|
||||
verbose to implement correctly, for example imagine trying to detect the
|
||||
presence of unrecognized fields in the input data. The compiler is powerless
|
||||
to help you when you make a mistake, for example imagine typoing <code>v["name"]</code>
|
||||
as <code>v["nmae"]</code> in one of the dozens of places it is used in your code.</p>
|
||||
<h2 id="parsing-json-as-strongly-typed-data-structures"><a class="doc-anchor" href="#parsing-json-as-strongly-typed-data-structures">§</a>Parsing JSON as strongly typed data structures</h2>
|
||||
<p>Serde provides a powerful way of mapping JSON data into Rust data structures
|
||||
largely automatically.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>serde_json::Result;
|
||||
|
||||
<span class="attr">#[derive(Serialize, Deserialize)]
|
||||
</span><span class="kw">struct </span>Person {
|
||||
name: String,
|
||||
age: u8,
|
||||
phones: Vec<String>,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>typed_example() -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="comment">// Some JSON input data as a &str. Maybe this comes from the user.
|
||||
</span><span class="kw">let </span>data = <span class="string">r#"
|
||||
{
|
||||
"name": "John Doe",
|
||||
"age": 43,
|
||||
"phones": [
|
||||
"+44 1234567",
|
||||
"+44 2345678"
|
||||
]
|
||||
}"#</span>;
|
||||
|
||||
<span class="comment">// Parse the string of data into a Person object. This is exactly the
|
||||
// same function as the one that produced serde_json::Value above, but
|
||||
// now we are asking it for a Person as output.
|
||||
</span><span class="kw">let </span>p: Person = serde_json::from_str(data)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Do things just like with any other Rust data structure.
|
||||
</span><span class="macro">println!</span>(<span class="string">"Please call {} at the number {}"</span>, p.name, p.phones[<span class="number">0</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<p>This is the same <code>serde_json::from_str</code> function as before, but this time we
|
||||
assign the return value to a variable of type <code>Person</code> so Serde will
|
||||
automatically interpret the input data as a <code>Person</code> and produce informative
|
||||
error messages if the layout does not conform to what a <code>Person</code> is expected
|
||||
to look like.</p>
|
||||
<p>Any type that implements Serde’s <code>Deserialize</code> trait can be deserialized
|
||||
this way. This includes built-in Rust standard library types like <code>Vec<T></code>
|
||||
and <code>HashMap<K, V></code>, as well as any structs or enums annotated with
|
||||
<code>#[derive(Deserialize)]</code>.</p>
|
||||
<p>Once we have <code>p</code> of type <code>Person</code>, our IDE and the Rust compiler can help us
|
||||
use it correctly like they do for any other Rust code. The IDE can
|
||||
autocomplete field names to prevent typos, which was impossible in the
|
||||
<code>serde_json::Value</code> representation. And the Rust compiler can check that
|
||||
when we write <code>p.phones[0]</code>, then <code>p.phones</code> is guaranteed to be a
|
||||
<code>Vec<String></code> so indexing into it makes sense and produces a <code>String</code>.</p>
|
||||
<h2 id="constructing-json-values"><a class="doc-anchor" href="#constructing-json-values">§</a>Constructing JSON values</h2>
|
||||
<p>Serde JSON provides a <a href="macro.json.html" title="macro serde_json::json"><code>json!</code> macro</a> to build <code>serde_json::Value</code>
|
||||
objects with very natural JSON syntax.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::json;
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `john` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>john = <span class="macro">json!</span>({
|
||||
<span class="string">"name"</span>: <span class="string">"John Doe"</span>,
|
||||
<span class="string">"age"</span>: <span class="number">43</span>,
|
||||
<span class="string">"phones"</span>: [
|
||||
<span class="string">"+44 1234567"</span>,
|
||||
<span class="string">"+44 2345678"
|
||||
</span>]
|
||||
});
|
||||
|
||||
<span class="macro">println!</span>(<span class="string">"first phone number: {}"</span>, john[<span class="string">"phones"</span>][<span class="number">0</span>]);
|
||||
|
||||
<span class="comment">// Convert to a string of JSON and print it out
|
||||
</span><span class="macro">println!</span>(<span class="string">"{}"</span>, john.to_string());
|
||||
}</code></pre></div>
|
||||
<p>The <code>Value::to_string()</code> function converts a <code>serde_json::Value</code> into a
|
||||
<code>String</code> of JSON text.</p>
|
||||
<p>One neat thing about the <code>json!</code> macro is that variables and expressions can
|
||||
be interpolated directly into the JSON value as you are building it. Serde
|
||||
will check at compile time that the value you are interpolating is able to
|
||||
be represented as JSON.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>full_name = <span class="string">"John Doe"</span>;
|
||||
<span class="kw">let </span>age_last_year = <span class="number">42</span>;
|
||||
|
||||
<span class="comment">// The type of `john` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>john = <span class="macro">json!</span>({
|
||||
<span class="string">"name"</span>: full_name,
|
||||
<span class="string">"age"</span>: age_last_year + <span class="number">1</span>,
|
||||
<span class="string">"phones"</span>: [
|
||||
<span class="macro">format!</span>(<span class="string">"+44 {}"</span>, random_phone())
|
||||
]
|
||||
});</code></pre></div>
|
||||
<p>This is amazingly convenient, but we have the problem we had before with
|
||||
<code>Value</code>: the IDE and Rust compiler cannot help us if we get it wrong. Serde
|
||||
JSON provides a better way of serializing strongly-typed data structures
|
||||
into JSON text.</p>
|
||||
<h2 id="creating-json-by-serializing-data-structures"><a class="doc-anchor" href="#creating-json-by-serializing-data-structures">§</a>Creating JSON by serializing data structures</h2>
|
||||
<p>A data structure can be converted to a JSON string by
|
||||
<a href="fn.to_string.html" title="fn serde_json::to_string"><code>serde_json::to_string</code></a>. There is also
|
||||
<a href="fn.to_vec.html" title="fn serde_json::to_vec"><code>serde_json::to_vec</code></a> which serializes to a <code>Vec<u8></code> and
|
||||
<a href="fn.to_writer.html" title="fn serde_json::to_writer"><code>serde_json::to_writer</code></a> which serializes to any <code>io::Write</code>
|
||||
such as a File or a TCP stream.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::{Deserialize, Serialize};
|
||||
<span class="kw">use </span>serde_json::Result;
|
||||
|
||||
<span class="attr">#[derive(Serialize, Deserialize)]
|
||||
</span><span class="kw">struct </span>Address {
|
||||
street: String,
|
||||
city: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>print_an_address() -> <span class="prelude-ty">Result</span><()> {
|
||||
<span class="comment">// Some data structure.
|
||||
</span><span class="kw">let </span>address = Address {
|
||||
street: <span class="string">"10 Downing Street"</span>.to_owned(),
|
||||
city: <span class="string">"London"</span>.to_owned(),
|
||||
};
|
||||
|
||||
<span class="comment">// Serialize it to a JSON string.
|
||||
</span><span class="kw">let </span>j = serde_json::to_string(<span class="kw-2">&</span>address)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Print, write to a file, or send to an HTTP server.
|
||||
</span><span class="macro">println!</span>(<span class="string">"{}"</span>, j);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<p>Any type that implements Serde’s <code>Serialize</code> trait can be serialized this
|
||||
way. This includes built-in Rust standard library types like <code>Vec<T></code> and
|
||||
<code>HashMap<K, V></code>, as well as any structs or enums annotated with
|
||||
<code>#[derive(Serialize)]</code>.</p>
|
||||
<h2 id="no-std-support"><a class="doc-anchor" href="#no-std-support">§</a>No-std support</h2>
|
||||
<p>As long as there is a memory allocator, it is possible to use serde_json
|
||||
without the rest of the Rust standard library. Disable the default “std”
|
||||
feature and enable the “alloc” feature:</p>
|
||||
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
|
||||
serde_json = { version = "1.0", default-features = false, features = ["alloc"] }</code></pre></div>
|
||||
<p>For JSON support in Serde without a memory allocator, please see the
|
||||
<a href="https://github.com/rust-embedded-community/serde-json-core"><code>serde-json-core</code></a> crate.</p>
|
||||
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="de/index.html" title="mod serde_json::de">de</a></div><div class="desc docblock-short">Deserialize JSON data to a Rust data structure.</div></li><li><div class="item-name"><a class="mod" href="error/index.html" title="mod serde_json::error">error</a></div><div class="desc docblock-short">When serializing or deserializing JSON goes wrong.</div></li><li><div class="item-name"><a class="mod" href="map/index.html" title="mod serde_json::map">map</a></div><div class="desc docblock-short">A map of String to serde_json::Value.</div></li><li><div class="item-name"><a class="mod" href="ser/index.html" title="mod serde_json::ser">ser</a></div><div class="desc docblock-short">Serialize a Rust data structure into JSON data.</div></li><li><div class="item-name"><a class="mod" href="value/index.html" title="mod serde_json::value">value</a></div><div class="desc docblock-short">The Value enum, a loosely typed way of representing any valid JSON value.</div></li></ul><h2 id="macros" class="section-header">Macros<a href="#macros" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="macro" href="macro.json.html" title="macro serde_json::json">json</a></div><div class="desc docblock-short">Construct a <code>serde_json::Value</code> from a JSON literal.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Deserializer.html" title="struct serde_json::Deserializer">Deserializer</a></div><div class="desc docblock-short">A structure that deserializes JSON into Rust values.</div></li><li><div class="item-name"><a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a></div><div class="desc docblock-short">This type represents all possible errors that can occur when serializing or
|
||||
deserializing JSON data.</div></li><li><div class="item-name"><a class="struct" href="struct.Map.html" title="struct serde_json::Map">Map</a></div><div class="desc docblock-short">Represents a JSON key/value type.</div></li><li><div class="item-name"><a class="struct" href="struct.Number.html" title="struct serde_json::Number">Number</a></div><div class="desc docblock-short">Represents a JSON number, whether integer or floating point.</div></li><li><div class="item-name"><a class="struct" href="struct.Serializer.html" title="struct serde_json::Serializer">Serializer</a></div><div class="desc docblock-short">A structure for serializing Rust values into JSON.</div></li><li><div class="item-name"><a class="struct" href="struct.StreamDeserializer.html" title="struct serde_json::StreamDeserializer">Stream<wbr>Deserializer</a></div><div class="desc docblock-short">Iterator that deserializes a stream into multiple JSON values.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Value.html" title="enum serde_json::Value">Value</a></div><div class="desc docblock-short">Represents any valid JSON value.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.from_reader.html" title="fn serde_json::from_reader">from_<wbr>reader</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from an I/O stream of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.from_slice.html" title="fn serde_json::from_slice">from_<wbr>slice</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from bytes of JSON text.</div></li><li><div class="item-name"><a class="fn" href="fn.from_str.html" title="fn serde_json::from_str">from_<wbr>str</a></div><div class="desc docblock-short">Deserialize an instance of type <code>T</code> from a string of JSON text.</div></li><li><div class="item-name"><a class="fn" href="fn.from_value.html" title="fn serde_json::from_value">from_<wbr>value</a></div><div class="desc docblock-short">Interpret a <code>serde_json::Value</code> as an instance of type <code>T</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.to_string.html" title="fn serde_json::to_string">to_<wbr>string</a></div><div class="desc docblock-short">Serialize the given data structure as a String of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.to_string_pretty.html" title="fn serde_json::to_string_pretty">to_<wbr>string_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as a pretty-printed String of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.to_value.html" title="fn serde_json::to_value">to_<wbr>value</a></div><div class="desc docblock-short">Convert a <code>T</code> into <code>serde_json::Value</code> which is an enum that can represent
|
||||
any valid JSON data.</div></li><li><div class="item-name"><a class="fn" href="fn.to_vec.html" title="fn serde_json::to_vec">to_vec</a></div><div class="desc docblock-short">Serialize the given data structure as a JSON byte vector.</div></li><li><div class="item-name"><a class="fn" href="fn.to_vec_pretty.html" title="fn serde_json::to_vec_pretty">to_<wbr>vec_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as a pretty-printed JSON byte vector.</div></li><li><div class="item-name"><a class="fn" href="fn.to_writer.html" title="fn serde_json::to_writer">to_<wbr>writer</a></div><div class="desc docblock-short">Serialize the given data structure as JSON into the I/O stream.</div></li><li><div class="item-name"><a class="fn" href="fn.to_writer_pretty.html" title="fn serde_json::to_writer_pretty">to_<wbr>writer_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as pretty-printed JSON into the I/O
|
||||
stream.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.Result.html" title="type serde_json::Result">Result</a></div><div class="desc docblock-short">Alias for a <code>Result</code> with the error type <code>serde_json::Error</code>.</div></li></ul></section></div></main></body></html>
|
||||
11
serde_json/macro.json!.html
Normal file
11
serde_json/macro.json!.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=macro.json.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="macro.json.html">macro.json.html</a>...</p>
|
||||
<script>location.replace("macro.json.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
41
serde_json/macro.json.html
Normal file
41
serde_json/macro.json.html
Normal file
|
|
@ -0,0 +1,41 @@
|
|||
<!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="Construct a `serde_json::Value` from a JSON literal."><title>json in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc macro"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Macro <span class="macro">json</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/macros.rs.html#54-59">Source</a> </span></div><pre class="rust item-decl"><code>macro_rules! json {
|
||||
($($json:tt)+) => { ... };
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Construct a <code>serde_json::Value</code> from a JSON literal.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>value = <span class="macro">json!</span>({
|
||||
<span class="string">"code"</span>: <span class="number">200</span>,
|
||||
<span class="string">"success"</span>: <span class="bool-val">true</span>,
|
||||
<span class="string">"payload"</span>: {
|
||||
<span class="string">"features"</span>: [
|
||||
<span class="string">"serde"</span>,
|
||||
<span class="string">"json"
|
||||
</span>],
|
||||
<span class="string">"homepage"</span>: null
|
||||
}
|
||||
});</code></pre></div>
|
||||
<p>Variables or expressions can be interpolated into the JSON literal. Any type
|
||||
interpolated into an array element or object value must implement Serde’s
|
||||
<code>Serialize</code> trait, while any type interpolated into a object key must
|
||||
implement <code>Into<String></code>. If the <code>Serialize</code> implementation of the
|
||||
interpolated type decides to fail, or if the interpolated type contains a
|
||||
map with non-string keys, the <code>json!</code> macro will panic.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>code = <span class="number">200</span>;
|
||||
<span class="kw">let </span>features = <span class="macro">vec!</span>[<span class="string">"serde"</span>, <span class="string">"json"</span>];
|
||||
|
||||
<span class="kw">let </span>value = <span class="macro">json!</span>({
|
||||
<span class="string">"code"</span>: code,
|
||||
<span class="string">"success"</span>: code == <span class="number">200</span>,
|
||||
<span class="string">"payload"</span>: {
|
||||
features[<span class="number">0</span>]: features[<span class="number">1</span>]
|
||||
}
|
||||
});</code></pre></div>
|
||||
<p>Trailing commas are allowed inside both arrays and objects.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>value = <span class="macro">json!</span>([
|
||||
<span class="string">"notice"</span>,
|
||||
<span class="string">"the"</span>,
|
||||
<span class="string">"trailing"</span>,
|
||||
<span class="string">"comma -->"</span>,
|
||||
]);</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
54
serde_json/map/enum.Entry.html
Normal file
54
serde_json/map/enum.Entry.html
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
<!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="A view into a single entry in a map, which may either be vacant or occupied. This enum is constructed from the `entry` method on `Map`."><title>Entry in serde_json::map - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc enum"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Entry</a></h2><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Occupied" title="Occupied">Occupied</a></li><li><a href="#variant.Vacant" title="Vacant">Vacant</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.and_modify" title="and_modify">and_modify</a></li><li><a href="#method.key" title="key">key</a></li><li><a href="#method.or_insert" title="or_insert">or_insert</a></li><li><a href="#method.or_insert_with" title="or_insert_with">or_insert_with</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-UnwindSafe-for-Entry%3C'a%3E" title="!UnwindSafe">!UnwindSafe</a></li><li><a href="#impl-Freeze-for-Entry%3C'a%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Entry%3C'a%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Entry%3C'a%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-Entry%3C'a%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Entry%3C'a%3E" title="Unpin">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>map</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">map</a></span><h1>Enum <span class="enum">Entry</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/map.rs.html#616-621">Source</a> </span></div><pre class="rust item-decl"><code>pub enum Entry<'a> {
|
||||
Vacant(<a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a>),
|
||||
Occupied(<a class="struct" href="struct.OccupiedEntry.html" title="struct serde_json::map::OccupiedEntry">OccupiedEntry</a><'a>),
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A view into a single entry in a map, which may either be vacant or occupied.
|
||||
This enum is constructed from the <a href="struct.Map.html#method.entry"><code>entry</code></a> method on <a href="struct.Map.html"><code>Map</code></a>.</p>
|
||||
</div></details><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Vacant" class="variant"><a href="#variant.Vacant" class="anchor">§</a><h3 class="code-header">Vacant(<a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a>)</h3></section><div class="docblock"><p>A vacant Entry.</p>
|
||||
</div><section id="variant.Occupied" class="variant"><a href="#variant.Occupied" class="anchor">§</a><h3 class="code-header">Occupied(<a class="struct" href="struct.OccupiedEntry.html" title="struct serde_json::map::OccupiedEntry">OccupiedEntry</a><'a>)</h3></section><div class="docblock"><p>An occupied Entry.</p>
|
||||
</div></div><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-Entry%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/map.rs.html#647-740">Source</a><a href="#impl-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.key" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#656-661">Source</a><h4 class="code-header">pub fn <a href="#method.key" class="fn">key</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class="docblock"><p>Returns a reference to this entry’s key.</p>
|
||||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
<span class="macro">assert_eq!</span>(map.entry(<span class="string">"serde"</span>).key(), <span class="kw-2">&</span><span class="string">"serde"</span>);</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.or_insert" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#676-681">Source</a><h4 class="code-header">pub fn <a href="#method.or_insert" class="fn">or_insert</a>(self, default: <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>) -> &'a mut <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a></h4></section></summary><div class="docblock"><p>Ensures a value is in the entry by inserting the default if empty, and
|
||||
returns a mutable reference to the value in the entry.</p>
|
||||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
map.entry(<span class="string">"serde"</span>).or_insert(<span class="macro">json!</span>(<span class="number">12</span>));
|
||||
|
||||
<span class="macro">assert_eq!</span>(map[<span class="string">"serde"</span>], <span class="number">12</span>);</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.or_insert_with" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#697-705">Source</a><h4 class="code-header">pub fn <a href="#method.or_insert_with" class="fn">or_insert_with</a><F>(self, default: F) -> &'a mut <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a><div class="where">where
|
||||
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>() -> <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>,</div></h4></section></summary><div class="docblock"><p>Ensures a value is in the entry by inserting the result of the default
|
||||
function if empty, and returns a mutable reference to the value in the
|
||||
entry.</p>
|
||||
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
map.entry(<span class="string">"serde"</span>).or_insert_with(|| <span class="macro">json!</span>(<span class="string">"hoho"</span>));
|
||||
|
||||
<span class="macro">assert_eq!</span>(map[<span class="string">"serde"</span>], <span class="string">"hoho"</span>.to_owned());</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.and_modify" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#728-739">Source</a><h4 class="code-header">pub fn <a href="#method.and_modify" class="fn">and_modify</a><F>(self, f: F) -> Self<div class="where">where
|
||||
F: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&mut <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>),</div></h4></section></summary><div class="docblock"><p>Provides in-place mutable access to an occupied entry before any
|
||||
potential inserts into the map.</p>
|
||||
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
map.entry(<span class="string">"serde"</span>)
|
||||
.and_modify(|e| <span class="kw-2">*</span>e = <span class="macro">json!</span>(<span class="string">"rust"</span>))
|
||||
.or_insert(<span class="macro">json!</span>(<span class="string">"cpp"</span>));
|
||||
|
||||
<span class="macro">assert_eq!</span>(map[<span class="string">"serde"</span>], <span class="string">"cpp"</span>);
|
||||
|
||||
map.entry(<span class="string">"serde"</span>)
|
||||
.and_modify(|e| <span class="kw-2">*</span>e = <span class="macro">json!</span>(<span class="string">"rust"</span>))
|
||||
.or_insert(<span class="macro">json!</span>(<span class="string">"cpp"</span>));
|
||||
|
||||
<span class="macro">assert_eq!</span>(map[<span class="string">"serde"</span>], <span class="string">"rust"</span>);</code></pre></div>
|
||||
</div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-Entry%3C'a%3E" class="impl"><a href="#impl-Freeze-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section><section id="impl-RefUnwindSafe-for-Entry%3C'a%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section><section id="impl-Send-for-Entry%3C'a%3E" class="impl"><a href="#impl-Send-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section><section id="impl-Sync-for-Entry%3C'a%3E" class="impl"><a href="#impl-Sync-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section><section id="impl-Unpin-for-Entry%3C'a%3E" class="impl"><a href="#impl-Unpin-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section><section id="impl-UnwindSafe-for-Entry%3C'a%3E" class="impl"><a href="#impl-UnwindSafe-for-Entry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a><'a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
5
serde_json/map/index.html
Normal file
5
serde_json/map/index.html
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<!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="A map of String to serde_json::Value."><title>serde_json::map - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module map</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a></span><h1>Module <span>map</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/map.rs.html#1-1157">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A map of String to serde_json::Value.</p>
|
||||
<p>By default the map is backed by a <a href="https://doc.rust-lang.org/std/collections/struct.BTreeMap.html"><code>BTreeMap</code></a>. Enable the <code>preserve_order</code>
|
||||
feature of serde_json to use <a href="https://docs.rs/indexmap/*/indexmap/map/struct.IndexMap.html"><code>IndexMap</code></a> instead.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.IntoIter.html" title="struct serde_json::map::IntoIter">Into<wbr>Iter</a></div><div class="desc docblock-short">An owning iterator over a serde_json::Map’s entries.</div></li><li><div class="item-name"><a class="struct" href="struct.Iter.html" title="struct serde_json::map::Iter">Iter</a></div><div class="desc docblock-short">An iterator over a serde_json::Map’s entries.</div></li><li><div class="item-name"><a class="struct" href="struct.IterMut.html" title="struct serde_json::map::IterMut">IterMut</a></div><div class="desc docblock-short">A mutable iterator over a serde_json::Map’s entries.</div></li><li><div class="item-name"><a class="struct" href="struct.Keys.html" title="struct serde_json::map::Keys">Keys</a></div><div class="desc docblock-short">An iterator over a serde_json::Map’s keys.</div></li><li><div class="item-name"><a class="struct" href="struct.Map.html" title="struct serde_json::map::Map">Map</a></div><div class="desc docblock-short">Represents a JSON key/value type.</div></li><li><div class="item-name"><a class="struct" href="struct.OccupiedEntry.html" title="struct serde_json::map::OccupiedEntry">Occupied<wbr>Entry</a></div><div class="desc docblock-short">An occupied Entry. It is part of the <a href="enum.Entry.html"><code>Entry</code></a> enum.</div></li><li><div class="item-name"><a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">Vacant<wbr>Entry</a></div><div class="desc docblock-short">A vacant Entry. It is part of the <a href="enum.Entry.html"><code>Entry</code></a> enum.</div></li><li><div class="item-name"><a class="struct" href="struct.Values.html" title="struct serde_json::map::Values">Values</a></div><div class="desc docblock-short">An iterator over a serde_json::Map’s values.</div></li><li><div class="item-name"><a class="struct" href="struct.ValuesMut.html" title="struct serde_json::map::ValuesMut">Values<wbr>Mut</a></div><div class="desc docblock-short">A mutable iterator over a serde_json::Map’s values.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Entry.html" title="enum serde_json::map::Entry">Entry</a></div><div class="desc docblock-short">A view into a single entry in a map, which may either be vacant or occupied.
|
||||
This enum is constructed from the <a href="struct.Map.html#method.entry"><code>entry</code></a> method on <a href="struct.Map.html"><code>Map</code></a>.</div></li></ul></section></div></main></body></html>
|
||||
1
serde_json/map/sidebar-items.js
Normal file
1
serde_json/map/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["Entry"],"struct":["IntoIter","Iter","IterMut","Keys","Map","OccupiedEntry","VacantEntry","Values","ValuesMut"]};
|
||||
228
serde_json/map/struct.IntoIter.html
Normal file
228
serde_json/map/struct.IntoIter.html
Normal file
File diff suppressed because one or more lines are too long
228
serde_json/map/struct.Iter.html
Normal file
228
serde_json/map/struct.Iter.html
Normal file
File diff suppressed because one or more lines are too long
228
serde_json/map/struct.IterMut.html
Normal file
228
serde_json/map/struct.IterMut.html
Normal file
File diff suppressed because one or more lines are too long
228
serde_json/map/struct.Keys.html
Normal file
228
serde_json/map/struct.Keys.html
Normal file
File diff suppressed because one or more lines are too long
422
serde_json/map/struct.Map.html
Normal file
422
serde_json/map/struct.Map.html
Normal file
File diff suppressed because one or more lines are too long
121
serde_json/map/struct.OccupiedEntry.html
Normal file
121
serde_json/map/struct.OccupiedEntry.html
Normal file
File diff suppressed because one or more lines are too long
38
serde_json/map/struct.VacantEntry.html
Normal file
38
serde_json/map/struct.VacantEntry.html
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<!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="A vacant Entry. It is part of the `Entry` enum."><title>VacantEntry in serde_json::map - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Vacant<wbr>Entry</a></h2><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.insert" title="insert">insert</a></li><li><a href="#method.key" title="key">key</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-UnwindSafe-for-VacantEntry%3C'a%3E" title="!UnwindSafe">!UnwindSafe</a></li><li><a href="#impl-Freeze-for-VacantEntry%3C'a%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-VacantEntry%3C'a%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-VacantEntry%3C'a%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-VacantEntry%3C'a%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-VacantEntry%3C'a%3E" title="Unpin">Unpin</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>map</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">map</a></span><h1>Struct <span class="struct">VacantEntry</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/map.rs.html#626-628">Source</a> </span></div><pre class="rust item-decl"><code>pub struct VacantEntry<'a> { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A vacant Entry. It is part of the <a href="enum.Entry.html"><code>Entry</code></a> enum.</p>
|
||||
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-VacantEntry%3C'a%3E" class="impl"><a class="src rightside" href="../../src/serde_json/map.rs.html#742-788">Source</a><a href="#impl-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.key" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#761-763">Source</a><h4 class="code-header">pub fn <a href="#method.key" class="fn">key</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h4></section></summary><div class="docblock"><p>Gets a reference to the key that would be used when inserting a value
|
||||
through the VacantEntry.</p>
|
||||
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::map::Entry;
|
||||
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
|
||||
<span class="kw">match </span>map.entry(<span class="string">"serde"</span>) {
|
||||
Entry::Vacant(vacant) => {
|
||||
<span class="macro">assert_eq!</span>(vacant.key(), <span class="kw-2">&</span><span class="string">"serde"</span>);
|
||||
}
|
||||
Entry::Occupied(<span class="kw">_</span>) => <span class="macro">unimplemented!</span>(),
|
||||
}</code></pre></div>
|
||||
</div></details><details class="toggle method-toggle" open><summary><section id="method.insert" class="method"><a class="src rightside" href="../../src/serde_json/map.rs.html#785-787">Source</a><h4 class="code-header">pub fn <a href="#method.insert" class="fn">insert</a>(self, value: <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>) -> &'a mut <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a></h4></section></summary><div class="docblock"><p>Sets the value of the entry with the VacantEntry’s key, and returns a
|
||||
mutable reference to it.</p>
|
||||
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::map::Entry;
|
||||
|
||||
<span class="kw">let </span><span class="kw-2">mut </span>map = serde_json::Map::new();
|
||||
|
||||
<span class="kw">match </span>map.entry(<span class="string">"serde"</span>) {
|
||||
Entry::Vacant(vacant) => {
|
||||
vacant.insert(<span class="macro">json!</span>(<span class="string">"hoho"</span>));
|
||||
}
|
||||
Entry::Occupied(<span class="kw">_</span>) => <span class="macro">unimplemented!</span>(),
|
||||
}</code></pre></div>
|
||||
</div></details></div></details></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-Freeze-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section><section id="impl-RefUnwindSafe-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-RefUnwindSafe-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section><section id="impl-Send-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-Send-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section><section id="impl-Sync-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-Sync-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section><section id="impl-Unpin-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-Unpin-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section><section id="impl-UnwindSafe-for-VacantEntry%3C'a%3E" class="impl"><a href="#impl-UnwindSafe-for-VacantEntry%3C'a%3E" class="anchor">§</a><h3 class="code-header">impl<'a> !<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.VacantEntry.html" title="struct serde_json::map::VacantEntry">VacantEntry</a><'a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
209
serde_json/map/struct.Values.html
Normal file
209
serde_json/map/struct.Values.html
Normal file
File diff suppressed because one or more lines are too long
206
serde_json/map/struct.ValuesMut.html
Normal file
206
serde_json/map/struct.ValuesMut.html
Normal file
File diff suppressed because one or more lines are too long
11
serde_json/number/struct.Number.html
Normal file
11
serde_json/number/struct.Number.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../serde_json/value/struct.Number.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../serde_json/value/struct.Number.html">../../serde_json/value/struct.Number.html</a>...</p>
|
||||
<script>location.replace("../../serde_json/value/struct.Number.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
serde_json/read/struct.IoRead.html
Normal file
11
serde_json/read/struct.IoRead.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../serde_json/de/struct.IoRead.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../serde_json/de/struct.IoRead.html">../../serde_json/de/struct.IoRead.html</a>...</p>
|
||||
<script>location.replace("../../serde_json/de/struct.IoRead.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
serde_json/read/struct.SliceRead.html
Normal file
11
serde_json/read/struct.SliceRead.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../serde_json/de/struct.SliceRead.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../serde_json/de/struct.SliceRead.html">../../serde_json/de/struct.SliceRead.html</a>...</p>
|
||||
<script>location.replace("../../serde_json/de/struct.SliceRead.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
serde_json/read/struct.StrRead.html
Normal file
11
serde_json/read/struct.StrRead.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../serde_json/de/struct.StrRead.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../serde_json/de/struct.StrRead.html">../../serde_json/de/struct.StrRead.html</a>...</p>
|
||||
<script>location.replace("../../serde_json/de/struct.StrRead.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
serde_json/read/trait.Read.html
Normal file
11
serde_json/read/trait.Read.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../serde_json/de/trait.Read.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../serde_json/de/trait.Read.html">../../serde_json/de/trait.Read.html</a>...</p>
|
||||
<script>location.replace("../../serde_json/de/trait.Read.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
32
serde_json/ser/enum.CharEscape.html
Normal file
32
serde_json/ser/enum.CharEscape.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="Represents a character escape code in a type-safe manner."><title>CharEscape in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc enum"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Char<wbr>Escape</a></h2><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.AsciiControl" title="AsciiControl">AsciiControl</a></li><li><a href="#variant.Backspace" title="Backspace">Backspace</a></li><li><a href="#variant.CarriageReturn" title="CarriageReturn">CarriageReturn</a></li><li><a href="#variant.FormFeed" title="FormFeed">FormFeed</a></li><li><a href="#variant.LineFeed" title="LineFeed">LineFeed</a></li><li><a href="#variant.Quote" title="Quote">Quote</a></li><li><a href="#variant.ReverseSolidus" title="ReverseSolidus">ReverseSolidus</a></li><li><a href="#variant.Solidus" title="Solidus">Solidus</a></li><li><a href="#variant.Tab" title="Tab">Tab</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-CharEscape" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-CharEscape" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-CharEscape" title="Send">Send</a></li><li><a href="#impl-Sync-for-CharEscape" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-CharEscape" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-CharEscape" title="UnwindSafe">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow<T>">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut<T>">BorrowMut<T></a></li><li><a href="#impl-From%3CT%3E-for-T" title="From<T>">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into<U>">Into<U></a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom<U>">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto<U>">TryInto<U></a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Enum <span class="enum">CharEscape</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#1515-1535">Source</a> </span></div><pre class="rust item-decl"><code>pub enum CharEscape {
|
||||
Quote,
|
||||
ReverseSolidus,
|
||||
Solidus,
|
||||
Backspace,
|
||||
FormFeed,
|
||||
LineFeed,
|
||||
CarriageReturn,
|
||||
Tab,
|
||||
AsciiControl(<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>),
|
||||
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Represents a character escape code in a type-safe manner.</p>
|
||||
</div></details><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Quote" class="variant"><a href="#variant.Quote" class="anchor">§</a><h3 class="code-header">Quote</h3></section><div class="docblock"><p>An escaped quote <code>"</code></p>
|
||||
</div><section id="variant.ReverseSolidus" class="variant"><a href="#variant.ReverseSolidus" class="anchor">§</a><h3 class="code-header">ReverseSolidus</h3></section><div class="docblock"><p>An escaped reverse solidus <code>\</code></p>
|
||||
</div><section id="variant.Solidus" class="variant"><a href="#variant.Solidus" class="anchor">§</a><h3 class="code-header">Solidus</h3></section><div class="docblock"><p>An escaped solidus <code>/</code></p>
|
||||
</div><section id="variant.Backspace" class="variant"><a href="#variant.Backspace" class="anchor">§</a><h3 class="code-header">Backspace</h3></section><div class="docblock"><p>An escaped backspace character (usually escaped as <code>\b</code>)</p>
|
||||
</div><section id="variant.FormFeed" class="variant"><a href="#variant.FormFeed" class="anchor">§</a><h3 class="code-header">FormFeed</h3></section><div class="docblock"><p>An escaped form feed character (usually escaped as <code>\f</code>)</p>
|
||||
</div><section id="variant.LineFeed" class="variant"><a href="#variant.LineFeed" class="anchor">§</a><h3 class="code-header">LineFeed</h3></section><div class="docblock"><p>An escaped line feed character (usually escaped as <code>\n</code>)</p>
|
||||
</div><section id="variant.CarriageReturn" class="variant"><a href="#variant.CarriageReturn" class="anchor">§</a><h3 class="code-header">CarriageReturn</h3></section><div class="docblock"><p>An escaped carriage return character (usually escaped as <code>\r</code>)</p>
|
||||
</div><section id="variant.Tab" class="variant"><a href="#variant.Tab" class="anchor">§</a><h3 class="code-header">Tab</h3></section><div class="docblock"><p>An escaped tab character (usually escaped as <code>\t</code>)</p>
|
||||
</div><section id="variant.AsciiControl" class="variant"><a href="#variant.AsciiControl" class="anchor">§</a><h3 class="code-header">AsciiControl(<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>)</h3></section><div class="docblock"><p>An escaped ASCII plane control character (usually escaped as
|
||||
<code>\u00XX</code> where <code>XX</code> are two hex characters)</p>
|
||||
</div></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-CharEscape" class="impl"><a href="#impl-Freeze-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section><section id="impl-RefUnwindSafe-for-CharEscape" class="impl"><a href="#impl-RefUnwindSafe-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section><section id="impl-Send-for-CharEscape" class="impl"><a href="#impl-Send-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section><section id="impl-Sync-for-CharEscape" class="impl"><a href="#impl-Sync-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section><section id="impl-Unpin-for-CharEscape" class="impl"><a href="#impl-Unpin-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section><section id="impl-UnwindSafe-for-CharEscape" class="impl"><a href="#impl-UnwindSafe-for-CharEscape" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">CharEscape</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
|
||||
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/1.84.1/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#209">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#211">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#217">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/borrow.rs.html#218">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.84.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#765">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#768">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#748-750">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#758">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
|
||||
<p>That is, this conversion is whatever the implementation of
|
||||
<code><a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
|
||||
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#805-807">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#809">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#812">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#790-792">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
|
||||
U: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#794">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.84.1/src/core/convert/mod.rs.html#797">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/1.84.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>
|
||||
6
serde_json/ser/fn.to_string.html
Normal file
6
serde_json/ser/fn.to_string.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a String of JSON."><title>to_string in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>string</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_string</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2209-2219">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_string<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a String of JSON.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/ser/fn.to_string_pretty.html
Normal file
6
serde_json/ser/fn.to_string_pretty.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a pretty-printed String of JSON."><title>to_string_pretty in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>string_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_string_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2228-2238">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_string_pretty<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a pretty-printed String of JSON.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/ser/fn.to_vec.html
Normal file
6
serde_json/ser/fn.to_vec.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a JSON byte vector."><title>to_vec in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_vec</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_vec</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2177-2184">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_vec<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a JSON byte vector.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
6
serde_json/ser/fn.to_vec_pretty.html
Normal file
6
serde_json/ser/fn.to_vec_pretty.html
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
<!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="Serialize the given data structure as a pretty-printed JSON byte vector."><title>to_vec_pretty in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>vec_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_vec_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2193-2200">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_vec_pretty<T>(value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/vec/struct.Vec.html" title="struct alloc::vec::Vec">Vec</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.u8.html">u8</a>>><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as a pretty-printed JSON byte vector.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
8
serde_json/ser/fn.to_writer.html
Normal file
8
serde_json/ser/fn.to_writer.html
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
<!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="Serialize the given data structure as JSON into the I/O stream."><title>to_writer in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>writer</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_writer</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2141-2148">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_writer<W, T>(writer: W, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as JSON into the I/O stream.</p>
|
||||
<p>Serialization guarantees it only feeds valid UTF-8 sequences to the writer.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
9
serde_json/ser/fn.to_writer_pretty.html
Normal file
9
serde_json/ser/fn.to_writer_pretty.html
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
<!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="Serialize the given data structure as pretty-printed JSON into the I/O stream."><title>to_writer_pretty in serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>writer_<wbr>pretty</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>ser</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">ser</a></span><h1>Function <span class="fn">to_writer_pretty</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#2161-2168">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_writer_pretty<W, T>(writer: W, value: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a>) -> <a class="type" href="../type.Result.html" title="type serde_json::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.unit.html">()</a>><div class="where">where
|
||||
W: <a class="trait" href="https://doc.rust-lang.org/1.84.1/std/io/trait.Write.html" title="trait std::io::Write">Write</a>,
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize the given data structure as pretty-printed JSON into the I/O
|
||||
stream.</p>
|
||||
<p>Serialization guarantees it only feeds valid UTF-8 sequences to the writer.</p>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>Serialization can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
4
serde_json/ser/index.html
Normal file
4
serde_json/ser/index.html
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
<!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="Serialize a Rust data structure into JSON data."><title>serde_json::ser - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module ser</a></h2><h3><a href="#structs">Module Items</a></h3><ul class="block"><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><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a></span><h1>Module <span>ser</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/ser.rs.html#1-2249">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Serialize a Rust data structure into JSON data.</p>
|
||||
</div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.CompactFormatter.html" title="struct serde_json::ser::CompactFormatter">Compact<wbr>Formatter</a></div><div class="desc docblock-short">This structure compacts a JSON value with no extra whitespace.</div></li><li><div class="item-name"><a class="struct" href="struct.PrettyFormatter.html" title="struct serde_json::ser::PrettyFormatter">Pretty<wbr>Formatter</a></div><div class="desc docblock-short">This structure pretty prints a JSON value to make it human readable.</div></li><li><div class="item-name"><a class="struct" href="struct.Serializer.html" title="struct serde_json::ser::Serializer">Serializer</a></div><div class="desc docblock-short">A structure for serializing Rust values into JSON.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.CharEscape.html" title="enum serde_json::ser::CharEscape">Char<wbr>Escape</a></div><div class="desc docblock-short">Represents a character escape code in a type-safe manner.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Formatter.html" title="trait serde_json::ser::Formatter">Formatter</a></div><div class="desc docblock-short">This trait abstracts away serializing the JSON control characters, which allows the user to
|
||||
optionally pretty print the JSON output.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.to_string.html" title="fn serde_json::ser::to_string">to_<wbr>string</a></div><div class="desc docblock-short">Serialize the given data structure as a String of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.to_string_pretty.html" title="fn serde_json::ser::to_string_pretty">to_<wbr>string_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as a pretty-printed String of JSON.</div></li><li><div class="item-name"><a class="fn" href="fn.to_vec.html" title="fn serde_json::ser::to_vec">to_vec</a></div><div class="desc docblock-short">Serialize the given data structure as a JSON byte vector.</div></li><li><div class="item-name"><a class="fn" href="fn.to_vec_pretty.html" title="fn serde_json::ser::to_vec_pretty">to_<wbr>vec_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as a pretty-printed JSON byte vector.</div></li><li><div class="item-name"><a class="fn" href="fn.to_writer.html" title="fn serde_json::ser::to_writer">to_<wbr>writer</a></div><div class="desc docblock-short">Serialize the given data structure as JSON into the I/O stream.</div></li><li><div class="item-name"><a class="fn" href="fn.to_writer_pretty.html" title="fn serde_json::ser::to_writer_pretty">to_<wbr>writer_<wbr>pretty</a></div><div class="desc docblock-short">Serialize the given data structure as pretty-printed JSON into the I/O
|
||||
stream.</div></li></ul></section></div></main></body></html>
|
||||
1
serde_json/ser/sidebar-items.js
Normal file
1
serde_json/ser/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["CharEscape"],"fn":["to_string","to_string_pretty","to_vec","to_vec_pretty","to_writer","to_writer_pretty"],"struct":["CompactFormatter","PrettyFormatter","Serializer"],"trait":["Formatter"]};
|
||||
72
serde_json/ser/struct.CompactFormatter.html
Normal file
72
serde_json/ser/struct.CompactFormatter.html
Normal file
File diff suppressed because one or more lines are too long
74
serde_json/ser/struct.PrettyFormatter.html
Normal file
74
serde_json/ser/struct.PrettyFormatter.html
Normal file
File diff suppressed because one or more lines are too long
105
serde_json/ser/struct.Serializer.html
Normal file
105
serde_json/ser/struct.Serializer.html
Normal file
File diff suppressed because one or more lines are too long
176
serde_json/ser/trait.Formatter.html
Normal file
176
serde_json/ser/trait.Formatter.html
Normal file
File diff suppressed because one or more lines are too long
1
serde_json/sidebar-items.js
Normal file
1
serde_json/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["Value"],"fn":["from_reader","from_slice","from_str","from_value","to_string","to_string_pretty","to_value","to_vec","to_vec_pretty","to_writer","to_writer_pretty"],"macro":["json"],"mod":["de","error","map","ser","value"],"struct":["Deserializer","Error","Map","Number","Serializer","StreamDeserializer"],"type":["Result"]};
|
||||
167
serde_json/struct.Deserializer.html
Normal file
167
serde_json/struct.Deserializer.html
Normal file
File diff suppressed because one or more lines are too long
110
serde_json/struct.Error.html
Normal file
110
serde_json/struct.Error.html
Normal file
File diff suppressed because one or more lines are too long
422
serde_json/struct.Map.html
Normal file
422
serde_json/struct.Map.html
Normal file
File diff suppressed because one or more lines are too long
290
serde_json/struct.Number.html
Normal file
290
serde_json/struct.Number.html
Normal file
File diff suppressed because one or more lines are too long
105
serde_json/struct.Serializer.html
Normal file
105
serde_json/struct.Serializer.html
Normal file
File diff suppressed because one or more lines are too long
276
serde_json/struct.StreamDeserializer.html
Normal file
276
serde_json/struct.StreamDeserializer.html
Normal file
File diff suppressed because one or more lines are too long
7
serde_json/type.Result.html
Normal file
7
serde_json/type.Result.html
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<!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="Alias for a `Result` with the error type `serde_json::Error`."><title>Result in serde_json - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Result</a></h2><h3><a href="#aliased-type">Aliased type</a></h3><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Err" title="Err">Err</a></li><li><a href="#variant.Ok" title="Ok">Ok</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">serde_json</a></span><h1>Type Alias <span class="type">Result</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_json/error.rs.html#25">Source</a> </span></div><pre class="rust item-decl"><code>pub type Result<T> = <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a>>;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Alias for a <code>Result</code> with the error type <code>serde_json::Error</code>.</p>
|
||||
</div></details><h2 id="aliased-type" class="section-header">Aliased Type<a href="#aliased-type" class="anchor">§</a></h2><pre class="rust item-decl"><code>enum Result<T> {
|
||||
Ok(T),
|
||||
Err(<a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a>),
|
||||
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Ok" class="variant"><a href="#variant.Ok" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Ok(T)</h3></section><div class="docblock"><p>Contains the success value</p>
|
||||
</div><section id="variant.Err" class="variant"><a href="#variant.Err" class="anchor">§</a><span class="since rightside" title="Stable since Rust version 1.0.0">1.0.0</span><h3 class="code-header">Err(<a class="struct" href="struct.Error.html" title="struct serde_json::Error">Error</a>)</h3></section><div class="docblock"><p>Contains the error value</p>
|
||||
</div></div><script src="../type.impl/core/result/enum.Result.js" data-self-path="serde_json::error::Result" async></script></section></div></main></body></html>
|
||||
756
serde_json/value/enum.Value.html
Normal file
756
serde_json/value/enum.Value.html
Normal file
File diff suppressed because one or more lines are too long
31
serde_json/value/fn.from_value.html
Normal file
31
serde_json/value/fn.from_value.html
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Interpret a `serde_json::Value` as an instance of type `T`."><title>from_value in serde_json::value - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">from_<wbr>value</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>value</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">value</a></span><h1>Function <span class="fn">from_value</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/value/mod.rs.html#1030-1035">Source</a> </span></div><pre class="rust item-decl"><code>pub fn from_value<T>(value: <a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <a class="struct" href="../struct.Error.html" title="struct serde_json::Error">Error</a>><div class="where">where
|
||||
T: <a class="trait" href="../../serde/de/trait.DeserializeOwned.html" title="trait serde::de::DeserializeOwned">DeserializeOwned</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Interpret a <code>serde_json::Value</code> as an instance of type <code>T</code>.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Deserialize;
|
||||
<span class="kw">use </span>serde_json::json;
|
||||
|
||||
<span class="attr">#[derive(Deserialize, Debug)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `j` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>j = <span class="macro">json!</span>({
|
||||
<span class="string">"fingerprint"</span>: <span class="string">"0xF9BA143B95FF6D82"</span>,
|
||||
<span class="string">"location"</span>: <span class="string">"Menlo Park, CA"
|
||||
</span>});
|
||||
|
||||
<span class="kw">let </span>u: User = serde_json::from_value(j).unwrap();
|
||||
<span class="macro">println!</span>(<span class="string">"{:#?}"</span>, u);
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if the structure of the Value does not match the
|
||||
structure expected by <code>T</code>, for example if <code>T</code> is a struct type but the Value
|
||||
contains something other than a JSON map. It can also fail if the structure
|
||||
is correct but <code>T</code>’s implementation of <code>Deserialize</code> decides that something
|
||||
is wrong with the data, for example required struct fields are missing from
|
||||
the JSON map or some number is too big to fit in the expected primitive
|
||||
type.</p>
|
||||
</div></details></section></div></main></body></html>
|
||||
45
serde_json/value/fn.to_value.html
Normal file
45
serde_json/value/fn.to_value.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="Convert a `T` into `serde_json::Value` which is an enum that can represent any valid JSON data."><title>to_value in serde_json::value - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc fn"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">to_<wbr>value</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li><li><a href="#errors" title="Errors">Errors</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>value</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">value</a></span><h1>Function <span class="fn">to_value</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/value/mod.rs.html#988-993">Source</a> </span></div><pre class="rust item-decl"><code>pub fn to_value<T>(value: T) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="enum" href="../enum.Value.html" title="enum serde_json::Value">Value</a>, <a class="struct" href="../struct.Error.html" title="struct serde_json::Error">Error</a>><div class="where">where
|
||||
T: <a class="trait" href="../../serde/ser/trait.Serialize.html" title="trait serde::ser::Serialize">Serialize</a>,</div></code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Convert a <code>T</code> into <code>serde_json::Value</code> which is an enum that can represent
|
||||
any valid JSON data.</p>
|
||||
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::Serialize;
|
||||
<span class="kw">use </span>serde_json::json;
|
||||
<span class="kw">use </span>std::error::Error;
|
||||
|
||||
<span class="attr">#[derive(Serialize)]
|
||||
</span><span class="kw">struct </span>User {
|
||||
fingerprint: String,
|
||||
location: String,
|
||||
}
|
||||
|
||||
<span class="kw">fn </span>compare_json_values() -> <span class="prelude-ty">Result</span><(), Box<<span class="kw">dyn </span>Error>> {
|
||||
<span class="kw">let </span>u = User {
|
||||
fingerprint: <span class="string">"0xF9BA143B95FF6D82"</span>.to_owned(),
|
||||
location: <span class="string">"Menlo Park, CA"</span>.to_owned(),
|
||||
};
|
||||
|
||||
<span class="comment">// The type of `expected` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>expected = <span class="macro">json!</span>({
|
||||
<span class="string">"fingerprint"</span>: <span class="string">"0xF9BA143B95FF6D82"</span>,
|
||||
<span class="string">"location"</span>: <span class="string">"Menlo Park, CA"</span>,
|
||||
});
|
||||
|
||||
<span class="kw">let </span>v = serde_json::to_value(u).unwrap();
|
||||
<span class="macro">assert_eq!</span>(v, expected);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
<h2 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h2>
|
||||
<p>This conversion can fail if <code>T</code>’s implementation of <code>Serialize</code> decides to
|
||||
fail, or if <code>T</code> contains a map with non-string keys.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::collections::BTreeMap;
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The keys in this map are vectors, not strings.
|
||||
</span><span class="kw">let </span><span class="kw-2">mut </span>map = BTreeMap::new();
|
||||
map.insert(<span class="macro">vec!</span>[<span class="number">32</span>, <span class="number">64</span>], <span class="string">"x86"</span>);
|
||||
|
||||
<span class="macro">println!</span>(<span class="string">"{}"</span>, serde_json::to_value(map).unwrap_err());
|
||||
}</code></pre></div>
|
||||
</div></details></section></div></main></body></html>
|
||||
71
serde_json/value/index.html
Normal file
71
serde_json/value/index.html
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
<!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="The Value enum, a loosely typed way of representing any valid JSON value."><title>serde_json::value - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module value</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#constructing-json" title="Constructing JSON">Constructing JSON</a></li></ul><h3><a href="#reexports">Module Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate serde_<wbr>json</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a></span><h1>Module <span>value</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/value/mod.rs.html#1-1035">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The Value enum, a loosely typed way of representing any valid JSON value.</p>
|
||||
<h2 id="constructing-json"><a class="doc-anchor" href="#constructing-json">§</a>Constructing JSON</h2>
|
||||
<p>Serde JSON provides a <a href="../macro.json.html" title="macro serde_json::json"><code>json!</code> macro</a> to build <code>serde_json::Value</code>
|
||||
objects with very natural JSON syntax.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::json;
|
||||
|
||||
<span class="kw">fn </span>main() {
|
||||
<span class="comment">// The type of `john` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>john = <span class="macro">json!</span>({
|
||||
<span class="string">"name"</span>: <span class="string">"John Doe"</span>,
|
||||
<span class="string">"age"</span>: <span class="number">43</span>,
|
||||
<span class="string">"phones"</span>: [
|
||||
<span class="string">"+44 1234567"</span>,
|
||||
<span class="string">"+44 2345678"
|
||||
</span>]
|
||||
});
|
||||
|
||||
<span class="macro">println!</span>(<span class="string">"first phone number: {}"</span>, john[<span class="string">"phones"</span>][<span class="number">0</span>]);
|
||||
|
||||
<span class="comment">// Convert to a string of JSON and print it out
|
||||
</span><span class="macro">println!</span>(<span class="string">"{}"</span>, john.to_string());
|
||||
}</code></pre></div>
|
||||
<p>The <code>Value::to_string()</code> function converts a <code>serde_json::Value</code> into a
|
||||
<code>String</code> of JSON text.</p>
|
||||
<p>One neat thing about the <code>json!</code> macro is that variables and expressions can
|
||||
be interpolated directly into the JSON value as you are building it. Serde
|
||||
will check at compile time that the value you are interpolating is able to
|
||||
be represented as JSON.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>full_name = <span class="string">"John Doe"</span>;
|
||||
<span class="kw">let </span>age_last_year = <span class="number">42</span>;
|
||||
|
||||
<span class="comment">// The type of `john` is `serde_json::Value`
|
||||
</span><span class="kw">let </span>john = <span class="macro">json!</span>({
|
||||
<span class="string">"name"</span>: full_name,
|
||||
<span class="string">"age"</span>: age_last_year + <span class="number">1</span>,
|
||||
<span class="string">"phones"</span>: [
|
||||
<span class="macro">format!</span>(<span class="string">"+44 {}"</span>, random_phone())
|
||||
]
|
||||
});</code></pre></div>
|
||||
<p>A string of JSON data can be parsed into a <code>serde_json::Value</code> by the
|
||||
<a href="../fn.from_str.html" title="fn serde_json::from_str"><code>serde_json::from_str</code></a> function. There is also
|
||||
<a href="../fn.from_slice.html" title="fn serde_json::from_slice"><code>from_slice</code></a> for parsing from a byte slice <code>&[u8]</code> and
|
||||
<a href="../fn.from_reader.html" title="fn serde_json::from_reader"><code>from_reader</code></a> for parsing from any <code>io::Read</code> like a File or
|
||||
a TCP stream.</p>
|
||||
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde_json::{json, Value, Error};
|
||||
|
||||
<span class="kw">fn </span>untyped_example() -> <span class="prelude-ty">Result</span><(), Error> {
|
||||
<span class="comment">// Some JSON input data as a &str. Maybe this comes from the user.
|
||||
</span><span class="kw">let </span>data = <span class="string">r#"
|
||||
{
|
||||
"name": "John Doe",
|
||||
"age": 43,
|
||||
"phones": [
|
||||
"+44 1234567",
|
||||
"+44 2345678"
|
||||
]
|
||||
}"#</span>;
|
||||
|
||||
<span class="comment">// Parse the string of data into serde_json::Value.
|
||||
</span><span class="kw">let </span>v: Value = serde_json::from_str(data)<span class="question-mark">?</span>;
|
||||
|
||||
<span class="comment">// Access parts of the data by indexing with square brackets.
|
||||
</span><span class="macro">println!</span>(<span class="string">"Please call {} at the number {}"</span>, v[<span class="string">"name"</span>], v[<span class="string">"phones"</span>][<span class="number">0</span>]);
|
||||
|
||||
<span class="prelude-val">Ok</span>(())
|
||||
}</code></pre></div>
|
||||
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Map"><code>pub use crate::map::<a class="struct" href="../struct.Map.html" title="struct serde_json::Map">Map</a>;</code></div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.Number.html" title="struct serde_json::value::Number">Number</a></div><div class="desc docblock-short">Represents a JSON number, whether integer or floating point.</div></li><li><div class="item-name"><a class="struct" href="struct.Serializer.html" title="struct serde_json::value::Serializer">Serializer</a></div><div class="desc docblock-short">Serializer whose output is a <code>Value</code>.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.Value.html" title="enum serde_json::value::Value">Value</a></div><div class="desc docblock-short">Represents any valid JSON value.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a></div><div class="desc docblock-short">A type that can be used to index into a <code>serde_json::Value</code>.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.from_value.html" title="fn serde_json::value::from_value">from_<wbr>value</a></div><div class="desc docblock-short">Interpret a <code>serde_json::Value</code> as an instance of type <code>T</code>.</div></li><li><div class="item-name"><a class="fn" href="fn.to_value.html" title="fn serde_json::value::to_value">to_<wbr>value</a></div><div class="desc docblock-short">Convert a <code>T</code> into <code>serde_json::Value</code> which is an enum that can represent
|
||||
any valid JSON data.</div></li></ul></section></div></main></body></html>
|
||||
11
serde_json/value/index/trait.Index.html
Normal file
11
serde_json/value/index/trait.Index.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../serde_json/value/trait.Index.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../serde_json/value/trait.Index.html">../../../serde_json/value/trait.Index.html</a>...</p>
|
||||
<script>location.replace("../../../serde_json/value/trait.Index.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
11
serde_json/value/ser/struct.Serializer.html
Normal file
11
serde_json/value/ser/struct.Serializer.html
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta http-equiv="refresh" content="0;URL=../../../serde_json/value/struct.Serializer.html">
|
||||
<title>Redirection</title>
|
||||
</head>
|
||||
<body>
|
||||
<p>Redirecting to <a href="../../../serde_json/value/struct.Serializer.html">../../../serde_json/value/struct.Serializer.html</a>...</p>
|
||||
<script>location.replace("../../../serde_json/value/struct.Serializer.html" + location.search + location.hash);</script>
|
||||
</body>
|
||||
</html>
|
||||
1
serde_json/value/sidebar-items.js
Normal file
1
serde_json/value/sidebar-items.js
Normal file
|
|
@ -0,0 +1 @@
|
|||
window.SIDEBAR_ITEMS = {"enum":["Value"],"fn":["from_value","to_value"],"struct":["Number","Serializer"],"trait":["Index"]};
|
||||
290
serde_json/value/struct.Number.html
Normal file
290
serde_json/value/struct.Number.html
Normal file
File diff suppressed because one or more lines are too long
96
serde_json/value/struct.Serializer.html
Normal file
96
serde_json/value/struct.Serializer.html
Normal file
File diff suppressed because one or more lines are too long
19
serde_json/value/trait.Index.html
Normal file
19
serde_json/value/trait.Index.html
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
<!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="A type that can be used to index into a `serde_json::Value`."><title>Index in serde_json::value - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="serde_json" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.1 (e71f9a9a9 2025-01-27)" data-channel="1.84.1" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../serde_json/index.html">serde_<wbr>json</a><span class="version">1.0.133</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Index</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Index-for-%26T" title="&T">&T</a></li><li><a href="#impl-Index-for-String" title="String">String</a></li><li><a href="#impl-Index-for-str" title="str">str</a></li><li><a href="#impl-Index-for-usize" title="usize">usize</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In serde_<wbr>json::<wbr>value</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="../index.html">serde_json</a>::<wbr><a href="index.html">value</a></span><h1>Trait <span class="trait">Index</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/serde_json/value/index.rs.html#37-52">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Index: Sealed { }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>A type that can be used to index into a <code>serde_json::Value</code>.</p>
|
||||
<p>The <a href="../enum.Value.html#method.get"><code>get</code></a> and <a href="../enum.Value.html#method.get_mut"><code>get_mut</code></a> methods of <code>Value</code> accept any type that
|
||||
implements <code>Index</code>, as does the <a href="../enum.Value.html#impl-Index%3CI%3E-for-Value">square-bracket indexing operator</a>. This
|
||||
trait is implemented for strings which are used as the index into a JSON
|
||||
map, and for <code>usize</code> which is used as the index into a JSON array.</p>
|
||||
<p>This trait is sealed and cannot be implemented for types outside of
|
||||
<code>serde_json</code>.</p>
|
||||
<h2 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h2>
|
||||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">let </span>data = <span class="macro">json!</span>({ <span class="string">"inner"</span>: [<span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>] });
|
||||
|
||||
<span class="comment">// Data is a JSON map so it can be indexed with a string.
|
||||
</span><span class="kw">let </span>inner = <span class="kw-2">&</span>data[<span class="string">"inner"</span>];
|
||||
|
||||
<span class="comment">// Inner is a JSON array so it can be indexed with an integer.
|
||||
</span><span class="kw">let </span>first = <span class="kw-2">&</span>inner[<span class="number">0</span>];
|
||||
|
||||
<span class="macro">assert_eq!</span>(first, <span class="number">1</span>);</code></pre></div>
|
||||
</div></details><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-Index-for-str" class="impl"><a class="src rightside" href="../../src/serde_json/value/index.rs.html#83-105">Source</a><a href="#impl-Index-for-str" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.str.html">str</a></h3></section><section id="impl-Index-for-usize" class="impl"><a class="src rightside" href="../../src/serde_json/value/index.rs.html#54-81">Source</a><a href="#impl-Index-for-usize" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.usize.html">usize</a></h3></section><section id="impl-Index-for-String" class="impl"><a class="src rightside" href="../../src/serde_json/value/index.rs.html#107-117">Source</a><a href="#impl-Index-for-String" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></h3></section><section id="impl-Index-for-%26T" class="impl"><a class="src rightside" href="../../src/serde_json/value/index.rs.html#119-132">Source</a><a href="#impl-Index-for-%26T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/std/primitive.reference.html">&T</a><div class="where">where
|
||||
T: ?<a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="trait.Index.html" title="trait serde_json::value::Index">Index</a>,</div></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../../trait.impl/serde_json/value/index/trait.Index.js" data-ignore-extern-crates="std,alloc" async></script></section></div></main></body></html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue