]> Untitled Git - bitcoindevkit.org/blob
c547beeb72fdd19e01faca70dd1301dc21e50238
[bitcoindevkit.org] /
1 <!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="`Expected` represents an explanation of what data a `Visitor` was expecting to receive."><title>Expected in bdk_chain::bitcoin::hashes::serde::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-5d1d17d0.css"><meta name="rustdoc-vars" data-root-path="../../../../../" data-static-root-path="../../../../../static.files/" data-current-crate="bdk_chain" data-themes="" data-resource-suffix="" data-rustdoc-version="1.86.0-nightly (f3d1d47fd 2025-01-20)" data-channel="nightly" data-search-js="search-ccb196c1.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><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt=""></a></nav><nav class="sidebar"><div class="sidebar-crate"><a class="logo-container" href="../../../../../bdk_chain/index.html"><img src="https://github.com/bitcoindevkit/bdk/raw/master/static/bdk.png" alt="logo"></a><h2><a href="../../../../../bdk_chain/index.html">bdk_<wbr>chain</a><span class="version">0.21.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Expected</a></h2><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.fmt" title="fmt">fmt</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-Expected-for-%26str" title="&#38;str">&#38;str</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Display-for-dyn+Expected" title="Display">Display</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2><a href="index.html">In bdk_<wbr>chain::<wbr>bitcoin::<wbr>hashes::<wbr>serde::<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">bdk_chain</a>::<wbr><a href="../../../index.html">bitcoin</a>::<wbr><a href="../../index.html">hashes</a>::<wbr><a href="../index.html">serde</a>::<wbr><a href="index.html">de</a></span><h1>Trait <span class="trait">Expected</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="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#474">Source</a> </span></div><pre class="rust item-decl"><code>pub trait Expected {
2 // Required method
3 fn <a href="#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;;
4 }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>Expected</code> represents an explanation of what data a <code>Visitor</code> was expecting
5 to receive.</p>
6 <p>This is used as an argument to the <code>invalid_type</code>, <code>invalid_value</code>, and
7 <code>invalid_length</code> methods of the <code>Error</code> trait to build error messages. The
8 message should be a noun or noun phrase that completes the sentence “This
9 Visitor expects to receive …”, for example the message could be “an
10 integer between 0 and 64”. The message should not be capitalized and should
11 not end with a period.</p>
12 <p>Within the context of a <code>Visitor</code> implementation, the <code>Visitor</code> itself
13 (<code>&amp;self</code>) is an implementation of this trait.</p>
14
15 <div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>visit_bool&lt;E&gt;(<span class="self">self</span>, v: bool) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="self">Self</span>::Value, E&gt;
16 <span class="kw">where
17 </span>E: de::Error,
18 {
19 <span class="prelude-val">Err</span>(de::Error::invalid_type(Unexpected::Bool(v), <span class="kw-2">&amp;</span><span class="self">self</span>))
20 }</code></pre></div>
21 <p>Outside of a <code>Visitor</code>, <code>&amp;"..."</code> can be used.</p>
22
23 <div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2021">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">return </span><span class="prelude-val">Err</span>(de::Error::invalid_type(
24 Unexpected::Bool(v),
25 <span class="kw-2">&amp;</span><span class="string">"a negative integer"</span>,
26 ));</code></pre></div>
27 </div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.fmt" class="method"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#477">Source</a><h4 class="code-header">fn <a href="#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</h4></section></summary><div class="docblock"><p>Format an explanation of what data was being expected. Same signature as
28 the <code>Display</code> and <code>Debug</code> traits.</p>
29 </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"><details class="toggle implementors-toggle" open><summary><section id="impl-Display-for-dyn+Expected" class="impl"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#495">Source</a><a href="#impl-Display-for-dyn+Expected" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display">Display</a> for dyn <a class="trait" href="trait.Expected.html" title="trait bdk_chain::bitcoin::hashes::serde::de::Expected">Expected</a> + '_</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#496">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html#tymethod.fmt">Read more</a></div></details></div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-Expected-for-%26str" class="impl"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#489">Source</a><a href="#impl-Expected-for-%26str" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.Expected.html" title="trait bdk_chain::bitcoin::hashes::serde::de::Expected">Expected</a> for &amp;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></h3></section></summary><div class="impl-items"><section id="method.fmt-1" class="method trait-impl"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#490">Source</a><a href="#method.fmt-1" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.fmt" class="fn">fmt</a>(&amp;self, formatter: &amp;mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Error.html" title="struct core::fmt::Error">Error</a>&gt;</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-Expected-for-T" class="impl"><a class="src rightside" href="https://docs.rs/serde/1.0.217/src/serde/de/mod.rs.html#480-482">Source</a><a href="#impl-Expected-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;'de, T&gt; <a class="trait" href="trait.Expected.html" title="trait bdk_chain::bitcoin::hashes::serde::de::Expected">Expected</a> for T<div class="where">where
30 T: <a class="trait" href="trait.Visitor.html" title="trait bdk_chain::bitcoin::hashes::serde::de::Visitor">Visitor</a>&lt;'de&gt;,</div></h3></section></div><script src="../../../../../trait.impl/serde/de/trait.Expected.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>