Adding large folders

This commit is contained in:
2026-02-26 12:00:21 -05:00
parent 5400d82acd
commit 49701c85ad
47332 changed files with 1942573 additions and 0 deletions

File diff suppressed because one or more lines are too long

View 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="Types related to error reporting."><title>zerocopy::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zerocopy" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="../sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc mod"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">Module error</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../zerocopy/index.html">zerocopy</a><span class="version">0.8.39</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module error</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#single-failure-mode-errors" title="Single failure mode errors">Single failure mode errors</a></li><li><a href="#compound-errors" title="Compound errors">Compound errors</a></li><li><a href="#unaligned-destination-types" title="`Unaligned` destination types"><code>Unaligned</code> destination types</a></li><li><a href="#accessing-the-conversion-source" title="Accessing the conversion source">Accessing the conversion source</a></li><li><a href="#display-formatting" title="Display formatting">Display formatting</a></li><li><a href="#validation-order" title="Validation order">Validation order</a></li><li><a href="#send-sync-and-static" title="`Send`, `Sync`, and `&#39;static`"><code>Send</code>, <code>Sync</code>, and <code>'static</code></a></li></ul><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 zerocopy</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">zerocopy</a></div><h1>Module <span>error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/zerocopy/error.rs.html#10-1346">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Types related to error reporting.</p>
<h3 id="single-failure-mode-errors"><a class="doc-anchor" href="#single-failure-mode-errors">§</a>Single failure mode errors</h3>
<p>Generally speaking, zerocopys conversions may fail for one of up to three
reasons:</p>
<ul>
<li><a href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError"><code>AlignmentError</code></a>: the conversion source was improperly aligned</li>
<li><a href="struct.SizeError.html" title="struct zerocopy::error::SizeError"><code>SizeError</code></a>: the conversion source was of incorrect size</li>
<li><a href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError"><code>ValidityError</code></a>: the conversion source contained invalid data</li>
</ul>
<p>Methods that only have one failure mode, like
<a href="../trait.FromBytes.html#method.read_from_bytes" title="associated function zerocopy::FromBytes::read_from_bytes"><code>FromBytes::read_from_bytes</code></a>, return that modes corresponding error type
directly.</p>
<h3 id="compound-errors"><a class="doc-anchor" href="#compound-errors">§</a>Compound errors</h3>
<p>Conversion methods that have either two or three possible failure modes
return one of these error types:</p>
<ul>
<li><a href="type.CastError.html" title="type zerocopy::error::CastError"><code>CastError</code></a>: the error type of reference conversions</li>
<li><a href="type.TryCastError.html" title="type zerocopy::error::TryCastError"><code>TryCastError</code></a>: the error type of fallible reference conversions</li>
<li><a href="type.TryReadError.html" title="type zerocopy::error::TryReadError"><code>TryReadError</code></a>: the error type of fallible read conversions</li>
</ul>
<h3 id="unaligned-destination-types"><a class="doc-anchor" href="#unaligned-destination-types">§</a><a href="../trait.Unaligned.html" title="trait zerocopy::Unaligned"><code>Unaligned</code></a> destination types</h3>
<p>For <a href="../trait.Unaligned.html" title="trait zerocopy::Unaligned"><code>Unaligned</code></a> destination types, alignment errors are impossible. All
compound error types support infallibly discarding the alignment error via
<a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From"><code>From</code></a> so long as <code>Dst: Unaligned</code>. For example, see <a href="struct.SizeError.html#method.from-1"><code>&lt;SizeError as From&lt;ConvertError&gt;&gt;::from</code></a>.</p>
<h3 id="accessing-the-conversion-source"><a class="doc-anchor" href="#accessing-the-conversion-source">§</a>Accessing the conversion source</h3>
<p>All error types provide an <code>into_src</code> method that converts the error into
the source value underlying the failed conversion.</p>
<h3 id="display-formatting"><a class="doc-anchor" href="#display-formatting">§</a>Display formatting</h3>
<p>All error types provide a <code>Display</code> implementation that produces a
human-readable error message. When <code>debug_assertions</code> are enabled, these
error messages are verbose and may include potentially sensitive
information, including:</p>
<ul>
<li>the names of the involved types</li>
<li>the sizes of the involved types</li>
<li>the addresses of the involved types</li>
<li>the contents of the involved types</li>
</ul>
<p>When <code>debug_assertions</code> are disabled (as is default for <code>release</code> builds),
such potentially sensitive information is excluded.</p>
<p>In the future, we may support manually configuring this behavior. If you are
interested in this feature, <a href="https://github.com/google/zerocopy/issues/1457">let us know on GitHub</a> so we know
to prioritize it.</p>
<h3 id="validation-order"><a class="doc-anchor" href="#validation-order">§</a>Validation order</h3>
<p>Our conversion methods typically check alignment, then size, then bit
validity. However, we do not guarantee that this is always the case, and
this behavior may change between releases.</p>
<h3 id="send-sync-and-static"><a class="doc-anchor" href="#send-sync-and-static">§</a><code>Send</code>, <code>Sync</code>, and <code>'static</code></h3>
<p>Our error types are <code>Send</code>, <code>Sync</code>, and <code>'static</code> when their <code>Src</code> parameter
is <code>Send</code>, <code>Sync</code>, or <code>'static</code>, respectively. This can cause issues when an
error is sent or synchronized across threads; e.g.:</p>
<div class="example-wrap compile_fail"><a href="#" class="tooltip" title="This example deliberately fails to compile"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::<span class="kw-2">*</span>;
<span class="kw">let </span>result: SizeError&lt;<span class="kw-2">&amp;</span>[u8], u32&gt; = std::thread::spawn(|| {
<span class="kw">let </span>source = <span class="kw-2">&amp;mut </span>[<span class="number">0u8</span>, <span class="number">1</span>, <span class="number">2</span>][..];
<span class="comment">// Try (and fail) to read a `u32` from `source`.
</span>u32::read_from_bytes(source).unwrap_err()
}).join().unwrap();</code></pre></div>
<p>To work around this, use <a href="enum.ConvertError.html#method.map_src" title="method zerocopy::error::ConvertError::map_src"><code>map_src</code></a> to convert the
source parameter to an unproblematic type; e.g.:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::<span class="kw-2">*</span>;
<span class="kw">let </span>result: SizeError&lt;(), u32&gt; = std::thread::spawn(|| {
<span class="kw">let </span>source = <span class="kw-2">&amp;mut </span>[<span class="number">0u8</span>, <span class="number">1</span>, <span class="number">2</span>][..];
<span class="comment">// Try (and fail) to read a `u32` from `source`.
</span>u32::read_from_bytes(source).unwrap_err()
<span class="comment">// Erase the error source.
</span>.map_src(drop)
}).join().unwrap();</code></pre></div>
<p>Alternatively, use <code>.to_string()</code> to eagerly convert the error into a
human-readable message; e.g.:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::<span class="kw-2">*</span>;
<span class="kw">let </span>result: <span class="prelude-ty">Result</span>&lt;u32, String&gt; = std::thread::spawn(|| {
<span class="kw">let </span>source = <span class="kw-2">&amp;mut </span>[<span class="number">0u8</span>, <span class="number">1</span>, <span class="number">2</span>][..];
<span class="comment">// Try (and fail) to read a `u32` from `source`.
</span>u32::read_from_bytes(source)
<span class="comment">// Eagerly render the error message.
</span>.map_err(|err| err.to_string())
}).join().unwrap();</code></pre></div></div></details><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><dl class="item-table"><dt><a class="struct" href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError">Alignment<wbr>Error</a></dt><dd>The error emitted if the conversion source is improperly aligned.</dd><dt><a class="struct" href="struct.AllocError.html" title="struct zerocopy::error::AllocError">Alloc<wbr>Error</a></dt><dd>The error type of a failed allocation.</dd><dt><a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">Size<wbr>Error</a></dt><dd>The error emitted if the conversion source is of incorrect size.</dd><dt><a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">Validity<wbr>Error</a></dt><dd>The error emitted if the conversion source contains invalid data.</dd></dl><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><dl class="item-table"><dt><a class="enum" href="enum.ConvertError.html" title="enum zerocopy::error::ConvertError">Convert<wbr>Error</a></dt><dd>Zerocopys generic error type.</dd></dl><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><dl class="item-table"><dt><a class="type" href="type.AlignedTryCastError.html" title="type zerocopy::error::AlignedTryCastError">Aligned<wbr>TryCast<wbr>Error</a></dt><dd>The error type of well-aligned, fallible casts.</dd><dt><a class="type" href="type.CastError.html" title="type zerocopy::error::CastError">Cast<wbr>Error</a></dt><dd>The error type of reference conversions.</dd><dt><a class="type" href="type.TryCastError.html" title="type zerocopy::error::TryCastError">TryCast<wbr>Error</a></dt><dd>The error type of fallible reference conversions.</dd><dt><a class="type" href="type.TryReadError.html" title="type zerocopy::error::TryReadError">TryRead<wbr>Error</a></dt><dd>The error type of fallible read-conversions.</dd></dl></section></div></main></body></html>

View File

@@ -0,0 +1 @@
window.SIDEBAR_ITEMS = {"enum":["ConvertError"],"struct":["AlignmentError","AllocError","SizeError","ValidityError"],"type":["AlignedTryCastError","CastError","TryCastError","TryReadError"]};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The error type of well-aligned, fallible casts."><title>AlignedTryCastError in zerocopy::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zerocopy" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">AlignedTryCastError</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../zerocopy/index.html">zerocopy</a><span class="version">0.8.39</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Aligned<wbr>TryCast<wbr>Error</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="#aliased-type">Aliased Type</a></h3><h3><a href="#variants">Variants</a></h3><ul class="block variant"><li><a href="#variant.Alignment" title="Alignment">Alignment</a></li><li><a href="#variant.Size" title="Size">Size</a></li><li><a href="#variant.Validity" title="Validity">Validity</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In zerocopy::<wbr>error</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">zerocopy</a>::<wbr><a href="index.html">error</a></div><h1>Type Alias <span class="type">Aligned<wbr>TryCast<wbr>Error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/zerocopy/error.rs.html#1017-1018">Source</a> </span></div><pre class="rust item-decl"><code>pub type AlignedTryCastError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.TryFromBytes.html" title="trait zerocopy::TryFromBytes">TryFromBytes</a>&gt; = <a class="enum" href="enum.ConvertError.html" title="enum zerocopy::error::ConvertError">ConvertError</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>, <a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;, <a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The error type of well-aligned, fallible casts.</p>
<p>This is like <a href="type.TryCastError.html" title="type zerocopy::error::TryCastError"><code>TryCastError</code></a>, but for casts that are always well-aligned.
It is identical to <code>TryCastError</code>, except that its alignment error is
<a href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible"><code>Infallible</code></a>.</p>
<p>As of this writing, none of zerocopys API produces this error directly.
However, it is useful since it permits users to infallibly discard alignment
errors when they can prove statically that alignment errors are impossible.</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">use </span>core::convert::Infallible;
<span class="kw">use </span>zerocopy::<span class="kw-2">*</span>;
<span class="attr">#[derive(TryFromBytes, KnownLayout, Unaligned, Immutable)]
#[repr(C, packed)]
</span><span class="kw">struct </span>Bools {
one: bool,
two: bool,
many: [bool],
}
<span class="kw">impl </span>Bools {
<span class="kw">fn </span>parse(bytes: <span class="kw-2">&amp;</span>[u8]) -&gt; <span class="prelude-ty">Result</span>&lt;<span class="kw-2">&amp;</span>Bools, AlignedTryCastError&lt;<span class="kw-2">&amp;</span>[u8], Bools&gt;&gt; {
<span class="comment">// Since `Bools: Unaligned`, we can infallibly discard
// the alignment error.
</span>Bools::try_ref_from_bytes(bytes).map_err(Into::into)
}
}</code></pre></div></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>pub enum AlignedTryCastError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.TryFromBytes.html" title="trait zerocopy::TryFromBytes">TryFromBytes</a>&gt; {
Alignment(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>),
Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;),
Validity(<a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;),
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Alignment" class="variant"><a href="#variant.Alignment" class="anchor">§</a><h3 class="code-header">Alignment(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>)</h3></section><div class="docblock"><p>The conversion source was improperly aligned.</p>
</div><section id="variant.Size" class="variant"><a href="#variant.Size" class="anchor">§</a><h3 class="code-header">Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source was of incorrect size.</p>
</div><section id="variant.Validity" class="variant"><a href="#variant.Validity" class="anchor">§</a><h3 class="code-header">Validity(<a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source contained invalid data.</p>
</div></div><script src="../../type.impl/zerocopy/error/enum.ConvertError.js" data-self-path="zerocopy::error::AlignedTryCastError" async></script></section></div></main></body></html>

View File

@@ -0,0 +1,30 @@
<!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 error type of reference conversions."><title>CastError in zerocopy::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zerocopy" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">CastError</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../zerocopy/index.html">zerocopy</a><span class="version">0.8.39</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Cast<wbr>Error</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.Alignment" title="Alignment">Alignment</a></li><li><a href="#variant.Size" title="Size">Size</a></li><li><a href="#variant.Validity" title="Validity">Validity</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.into_src" title="into_src">into_src</a></li><li><a href="#method.map_src" title="map_src">map_src</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In zerocopy::<wbr>error</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">zerocopy</a>::<wbr><a href="index.html">error</a></div><h1>Type Alias <span class="type">Cast<wbr>Error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/zerocopy/error.rs.html#726-727">Source</a> </span></div><pre class="rust item-decl"><code>pub type CastError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; = <a class="enum" href="enum.ConvertError.html" title="enum zerocopy::error::ConvertError">ConvertError</a>&lt;<a class="struct" href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError">AlignmentError</a>&lt;Src, Dst&gt;, <a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;, <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The error type of reference conversions.</p>
<p>Reference conversions, like <a href="../trait.FromBytes.html#method.ref_from_bytes" title="associated function zerocopy::FromBytes::ref_from_bytes"><code>FromBytes::ref_from_bytes</code></a> may emit
<a href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError">alignment</a> and <a href="struct.SizeError.html" title="struct zerocopy::error::SizeError">size</a> errors.</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>pub enum CastError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; {
Alignment(<a class="struct" href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError">AlignmentError</a>&lt;Src, Dst&gt;),
Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;),
Validity(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>),
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Alignment" class="variant"><a href="#variant.Alignment" class="anchor">§</a><h3 class="code-header">Alignment(<a class="struct" href="struct.AlignmentError.html" title="struct zerocopy::error::AlignmentError">AlignmentError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source was improperly aligned.</p>
</div><section id="variant.Size" class="variant"><a href="#variant.Size" class="anchor">§</a><h3 class="code-header">Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source was of incorrect size.</p>
</div><section id="variant.Validity" class="variant"><a href="#variant.Validity" class="anchor">§</a><h3 class="code-header">Validity(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>)</h3></section><div class="docblock"><p>The conversion source contained invalid data.</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-ConvertError%3CAlignmentError%3CSrc,+Dst%3E,+SizeError%3CSrc,+Dst%3E,+Infallible%3E" class="impl"><a class="src rightside" href="../../src/zerocopy/error.rs.html#729-790">Source</a><a href="#impl-ConvertError%3CAlignmentError%3CSrc,+Dst%3E,+SizeError%3CSrc,+Dst%3E,+Infallible%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>&gt; <a class="type" href="type.CastError.html" title="type zerocopy::error::CastError">CastError</a>&lt;Src, Dst&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_src" class="method"><a class="src rightside" href="../../src/zerocopy/error.rs.html#732-738">Source</a><h4 class="code-header">pub fn <a href="#method.into_src" class="fn">into_src</a>(self) -&gt; Src</h4></section></summary><div class="docblock"><p>Produces the source underlying the failed conversion.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_src" class="method"><a class="src rightside" href="../../src/zerocopy/error.rs.html#771-777">Source</a><h4 class="code-header">pub fn <a href="#method.map_src" class="fn">map_src</a>&lt;NewSrc&gt;(
self,
f: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Src) -&gt; NewSrc,
) -&gt; <a class="type" href="type.CastError.html" title="type zerocopy::error::CastError">CastError</a>&lt;NewSrc, Dst&gt;</h4></section></summary><div class="docblock"><p>Maps the source value associated with the conversion error.</p>
<p>This can help mitigate <a href="index.html#send-sync-and-static" title="mod zerocopy::error">issues with <code>Send</code>, <code>Sync</code> and <code>'static</code>
bounds</a>.</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>zerocopy::<span class="kw-2">*</span>;
<span class="kw">let </span>source: [u8; <span class="number">3</span>] = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>];
<span class="comment">// Try to read a `u32` from `source`. This will fail because there are insufficient
// bytes in `source`.
</span><span class="kw">let </span>maybe_u32: <span class="prelude-ty">Result</span>&lt;<span class="kw-2">&amp;</span>u32, CastError&lt;<span class="kw-2">&amp;</span>[u8], u32&gt;&gt; = u32::ref_from_bytes(<span class="kw-2">&amp;</span>source[..]);
<span class="comment">// Map the error's source to its size and address.
</span><span class="kw">let </span>maybe_u32: <span class="prelude-ty">Result</span>&lt;<span class="kw-2">&amp;</span>u32, CastError&lt;(usize, usize), u32&gt;&gt; = maybe_u32.map_err(|err| {
err.map_src(|src| (src.len(), src.as_ptr() <span class="kw">as </span>usize))
});</code></pre></div></div></details></div></details></div><script src="../../type.impl/zerocopy/error/enum.ConvertError.js" data-self-path="zerocopy::error::CastError" async></script></section></div></main></body></html>

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,33 @@
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="The error type of fallible read-conversions."><title>TryReadError in zerocopy::error - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../../" data-static-root-path="../../static.files/" data-current-crate="zerocopy" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../../static.files/favicon-044be391.svg"></head><body class="rustdoc type"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><rustdoc-topbar><h2><a href="#">TryReadError</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../../zerocopy/index.html">zerocopy</a><span class="version">0.8.39</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">TryRead<wbr>Error</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.Alignment" title="Alignment">Alignment</a></li><li><a href="#variant.Size" title="Size">Size</a></li><li><a href="#variant.Validity" title="Validity">Validity</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.into_src" title="into_src">into_src</a></li><li><a href="#method.map_src" title="map_src">map_src</a></li></ul></section><div id="rustdoc-modnav"><h2><a href="index.html">In zerocopy::<wbr>error</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="../index.html">zerocopy</a>::<wbr><a href="index.html">error</a></div><h1>Type Alias <span class="type">TryRead<wbr>Error</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../../src/zerocopy/error.rs.html#936-937">Source</a> </span></div><pre class="rust item-decl"><code>pub type TryReadError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.TryFromBytes.html" title="trait zerocopy::TryFromBytes">TryFromBytes</a>&gt; = <a class="enum" href="enum.ConvertError.html" title="enum zerocopy::error::ConvertError">ConvertError</a>&lt;<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>, <a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;, <a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;&gt;;</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>The error type of fallible read-conversions.</p>
<p>Fallible read-conversions, like <a href="../trait.TryFromBytes.html#method.try_read_from_bytes" title="associated function zerocopy::TryFromBytes::try_read_from_bytes"><code>TryFromBytes::try_read_from_bytes</code></a> may
emit <a href="struct.SizeError.html" title="struct zerocopy::error::SizeError">size</a> and <a href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">validity</a> errors, but not
alignment errors.</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>pub enum TryReadError&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.TryFromBytes.html" title="trait zerocopy::TryFromBytes">TryFromBytes</a>&gt; {
Alignment(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>),
Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;),
Validity(<a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;),
}</code></pre><h2 id="variants" class="variants section-header">Variants<a href="#variants" class="anchor">§</a></h2><div class="variants"><section id="variant.Alignment" class="variant"><a href="#variant.Alignment" class="anchor">§</a><h3 class="code-header">Alignment(<a class="enum" href="https://doc.rust-lang.org/1.93.1/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a>)</h3></section><div class="docblock"><p>The conversion source was improperly aligned.</p>
</div><section id="variant.Size" class="variant"><a href="#variant.Size" class="anchor">§</a><h3 class="code-header">Size(<a class="struct" href="struct.SizeError.html" title="struct zerocopy::error::SizeError">SizeError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source was of incorrect size.</p>
</div><section id="variant.Validity" class="variant"><a href="#variant.Validity" class="anchor">§</a><h3 class="code-header">Validity(<a class="struct" href="struct.ValidityError.html" title="struct zerocopy::error::ValidityError">ValidityError</a>&lt;Src, Dst&gt;)</h3></section><div class="docblock"><p>The conversion source contained invalid data.</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-ConvertError%3CInfallible,+SizeError%3CSrc,+Dst%3E,+ValidityError%3CSrc,+Dst%3E%3E" class="impl"><a class="src rightside" href="../../src/zerocopy/error.rs.html#939-981">Source</a><a href="#impl-ConvertError%3CInfallible,+SizeError%3CSrc,+Dst%3E,+ValidityError%3CSrc,+Dst%3E%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Src, Dst: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a> + <a class="trait" href="../trait.TryFromBytes.html" title="trait zerocopy::TryFromBytes">TryFromBytes</a>&gt; <a class="type" href="type.TryReadError.html" title="type zerocopy::error::TryReadError">TryReadError</a>&lt;Src, Dst&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_src" class="method"><a class="src rightside" href="../../src/zerocopy/error.rs.html#942-948">Source</a><h4 class="code-header">pub fn <a href="#method.into_src" class="fn">into_src</a>(self) -&gt; Src</h4></section></summary><div class="docblock"><p>Produces the source underlying the failed conversion.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_src" class="method"><a class="src rightside" href="../../src/zerocopy/error.rs.html#974-980">Source</a><h4 class="code-header">pub fn <a href="#method.map_src" class="fn">map_src</a>&lt;NewSrc&gt;(
self,
f: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(Src) -&gt; NewSrc,
) -&gt; <a class="type" href="type.TryReadError.html" title="type zerocopy::error::TryReadError">TryReadError</a>&lt;NewSrc, Dst&gt;</h4></section></summary><div class="docblock"><p>Maps the source value associated with the conversion error.</p>
<p>This can help mitigate <a href="index.html#send-sync-and-static" title="mod zerocopy::error">issues with <code>Send</code>, <code>Sync</code> and <code>'static</code>
bounds</a>.</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>core::num::NonZeroU32;
<span class="kw">use </span>zerocopy::<span class="kw-2">*</span>;
<span class="kw">let </span>source: [u8; <span class="number">3</span>] = [<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>];
<span class="comment">// Try to read a `NonZeroU32` from `source`.
</span><span class="kw">let </span>maybe_u32: <span class="prelude-ty">Result</span>&lt;NonZeroU32, TryReadError&lt;<span class="kw-2">&amp;</span>[u8], NonZeroU32&gt;&gt;
= NonZeroU32::try_read_from_bytes(<span class="kw-2">&amp;</span>source[..]);
<span class="comment">// Map the error's source to its size.
</span><span class="kw">let </span>maybe_u32: <span class="prelude-ty">Result</span>&lt;NonZeroU32, TryReadError&lt;usize, NonZeroU32&gt;&gt; =
maybe_u32.map_err(|err| {
err.map_src(|src| src.len())
});</code></pre></div></div></details></div></details></div><script src="../../type.impl/zerocopy/error/enum.ConvertError.js" data-self-path="zerocopy::error::TryReadError" async></script></section></div></main></body></html>