mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-17 08:19:51 +00:00
554 lines
No EOL
97 KiB
HTML
554 lines
No EOL
97 KiB
HTML
<!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 for which any bit pattern is valid."><title>FromBytes in zerocopy - 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="zerocopy" 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="../zerocopy/index.html">zerocopy</a><span class="version">0.7.35</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">From<wbr>Bytes</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#implementation" title="Implementation">Implementation</a></li><li><a href="#safety" title="Safety">Safety</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.mut_from" title="mut_from">mut_from</a></li><li><a href="#method.mut_from_prefix" title="mut_from_prefix">mut_from_prefix</a></li><li><a href="#method.mut_from_suffix" title="mut_from_suffix">mut_from_suffix</a></li><li><a href="#method.mut_slice_from" title="mut_slice_from">mut_slice_from</a></li><li><a href="#method.mut_slice_from_prefix" title="mut_slice_from_prefix">mut_slice_from_prefix</a></li><li><a href="#method.mut_slice_from_suffix" title="mut_slice_from_suffix">mut_slice_from_suffix</a></li><li><a href="#method.read_from" title="read_from">read_from</a></li><li><a href="#method.read_from_prefix" title="read_from_prefix">read_from_prefix</a></li><li><a href="#method.read_from_suffix" title="read_from_suffix">read_from_suffix</a></li><li><a href="#method.ref_from" title="ref_from">ref_from</a></li><li><a href="#method.ref_from_prefix" title="ref_from_prefix">ref_from_prefix</a></li><li><a href="#method.ref_from_suffix" title="ref_from_suffix">ref_from_suffix</a></li><li><a href="#method.slice_from" title="slice_from">slice_from</a></li><li><a href="#method.slice_from_prefix" title="slice_from_prefix">slice_from_prefix</a></li><li><a href="#method.slice_from_suffix" title="slice_from_suffix">slice_from_suffix</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-FromBytes-for-()" title="()">()</a></li><li><a href="#impl-FromBytes-for-ManuallyDrop%3CT%3E" title="ManuallyDrop<T>">ManuallyDrop<T></a></li><li><a href="#impl-FromBytes-for-MaybeUninit%3CT%3E" title="MaybeUninit<T>">MaybeUninit<T></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci128%3E%3E" title="Option<NonZeroI128>">Option<NonZeroI128></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci16%3E%3E" title="Option<NonZeroI16>">Option<NonZeroI16></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci32%3E%3E" title="Option<NonZeroI32>">Option<NonZeroI32></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci64%3E%3E" title="Option<NonZeroI64>">Option<NonZeroI64></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci8%3E%3E" title="Option<NonZeroI8>">Option<NonZeroI8></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cisize%3E%3E" title="Option<NonZeroIsize>">Option<NonZeroIsize></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu128%3E%3E" title="Option<NonZeroU128>">Option<NonZeroU128></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu16%3E%3E" title="Option<NonZeroU16>">Option<NonZeroU16></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu32%3E%3E" title="Option<NonZeroU32>">Option<NonZeroU32></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu64%3E%3E" title="Option<NonZeroU64>">Option<NonZeroU64></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu8%3E%3E" title="Option<NonZeroU8>">Option<NonZeroU8></a></li><li><a href="#impl-FromBytes-for-Option%3CNonZero%3Cusize%3E%3E" title="Option<NonZeroUsize>">Option<NonZeroUsize></a></li><li><a href="#impl-FromBytes-for-PhantomData%3CT%3E" title="PhantomData<T>">PhantomData<T></a></li><li><a href="#impl-FromBytes-for-Wrapping%3CT%3E" title="Wrapping<T>">Wrapping<T></a></li><li><a href="#impl-FromBytes-for-%5BT;+N%5D" title="[T; N]">[T; N]</a></li><li><a href="#impl-FromBytes-for-%5BT%5D" title="[T]">[T]</a></li><li><a href="#impl-FromBytes-for-__m128" title="__m128">__m128</a></li><li><a href="#impl-FromBytes-for-__m128d" title="__m128d">__m128d</a></li><li><a href="#impl-FromBytes-for-__m128i" title="__m128i">__m128i</a></li><li><a href="#impl-FromBytes-for-__m256" title="__m256">__m256</a></li><li><a href="#impl-FromBytes-for-__m256d" title="__m256d">__m256d</a></li><li><a href="#impl-FromBytes-for-__m256i" title="__m256i">__m256i</a></li><li><a href="#impl-FromBytes-for-f32" title="f32">f32</a></li><li><a href="#impl-FromBytes-for-f64" title="f64">f64</a></li><li><a href="#impl-FromBytes-for-i128" title="i128">i128</a></li><li><a href="#impl-FromBytes-for-i16" title="i16">i16</a></li><li><a href="#impl-FromBytes-for-i32" title="i32">i32</a></li><li><a href="#impl-FromBytes-for-i64" title="i64">i64</a></li><li><a href="#impl-FromBytes-for-i8" title="i8">i8</a></li><li><a href="#impl-FromBytes-for-isize" title="isize">isize</a></li><li><a href="#impl-FromBytes-for-u128" title="u128">u128</a></li><li><a href="#impl-FromBytes-for-u16" title="u16">u16</a></li><li><a href="#impl-FromBytes-for-u32" title="u32">u32</a></li><li><a href="#impl-FromBytes-for-u64" title="u64">u64</a></li><li><a href="#impl-FromBytes-for-u8" title="u8">u8</a></li><li><a href="#impl-FromBytes-for-usize" title="usize">usize</a></li></ul><h3><a href="#implementors">Implementors</a></h3></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"></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">zerocopy</a></span><h1>Trait <span class="trait">FromBytes</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/zerocopy/lib.rs.html#1824-2497">Source</a> </span></div><pre class="rust item-decl"><code>pub unsafe trait FromBytes: <a class="trait" href="trait.FromZeroes.html" title="trait zerocopy::FromZeroes">FromZeroes</a> {
|
||
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 15 methods</span></summary> // Provided methods
|
||
fn <a href="#method.ref_from" class="fn">ref_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.ref_from_prefix" class="fn">ref_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.ref_from_suffix" class="fn">ref_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_from" class="fn">mut_from</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_from_prefix" class="fn">mut_from_prefix</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_from_suffix" class="fn">mut_from_suffix</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.slice_from" class="fn">slice_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[Self]>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.slice_from_prefix" class="fn">slice_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&[Self], &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>])>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.slice_from_suffix" class="fn">slice_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], &[Self])>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_slice_from" class="fn">mut_slice_from</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut [Self]>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_slice_from_prefix" class="fn">mut_slice_from_prefix</a>(
|
||
bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>],
|
||
count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&mut [Self], &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>])>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.mut_slice_from_suffix" class="fn">mut_slice_from_suffix</a>(
|
||
bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>],
|
||
count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], &mut [Self])>
|
||
<span class="where">where Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.read_from" class="fn">read_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.read_from_prefix" class="fn">read_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
<span class="item-spacer"></span> fn <a href="#method.read_from_suffix" class="fn">read_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self>
|
||
<span class="where">where Self: <a class="trait" href="https://doc.rust-lang.org/1.84.1/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a></span> { ... }
|
||
</details>}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Types for which any bit pattern is valid.</p>
|
||
<p>Any memory region of the appropriate length which contains initialized bytes
|
||
can be viewed as any <code>FromBytes</code> type with no runtime overhead. This is
|
||
useful for efficiently parsing bytes as structured data.</p>
|
||
<h2 id="implementation"><a class="doc-anchor" href="#implementation">§</a>Implementation</h2>
|
||
<p><strong>Do not implement this trait yourself!</strong> Instead, use
|
||
<a href="derive.FromBytes.html" title="derive zerocopy::FromBytes"><code>#[derive(FromBytes)]</code></a> (requires the <code>derive</code> Cargo feature);
|
||
e.g.:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
</span><span class="kw">struct </span>MyStruct {
|
||
...
|
||
}
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(u8)]
|
||
</span><span class="kw">enum </span>MyEnum {
|
||
...
|
||
}
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
</span><span class="kw">union </span>MyUnion {
|
||
...
|
||
}</code></pre></div>
|
||
<p>This derive performs a sophisticated, compile-time safety analysis to
|
||
determine whether a type is <code>FromBytes</code>.</p>
|
||
<h2 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h2>
|
||
<p><em>This section describes what is required in order for <code>T: FromBytes</code>, and
|
||
what unsafe code may assume of such types. If you don’t plan on implementing
|
||
<code>FromBytes</code> manually, and you don’t plan on writing unsafe code that
|
||
operates on <code>FromBytes</code> types, then you don’t need to read this section.</em></p>
|
||
<p>If <code>T: FromBytes</code>, then unsafe code may assume that:</p>
|
||
<ul>
|
||
<li>It is sound to treat any initialized sequence of bytes of length
|
||
<code>size_of::<T>()</code> as a <code>T</code>.</li>
|
||
<li>Given <code>b: &[u8]</code> where <code>b.len() == size_of::<T>()</code>, <code>b</code> is aligned to
|
||
<code>align_of::<T>()</code> it is sound to construct a <code>t: &T</code> at the same address
|
||
as <code>b</code>, and it is sound for both <code>b</code> and <code>t</code> to be live at the same time.</li>
|
||
</ul>
|
||
<p>If a type is marked as <code>FromBytes</code> which violates this contract, it may
|
||
cause undefined behavior.</p>
|
||
<p><code>#[derive(FromBytes)]</code> only permits <a href="derive.FromBytes.html#analysis" title="derive zerocopy::FromBytes">types which satisfy these
|
||
requirements</a>.</p>
|
||
</div></details><h2 id="provided-methods" class="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.ref_from" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#1863-1868">Source</a><h4 class="code-header">fn <a href="#method.ref_from" class="fn">ref_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the given <code>bytes</code> as a <code>&Self</code> without copying.</p>
|
||
<p>If <code>bytes.len() != size_of::<Self>()</code> or <code>bytes</code> is not aligned to
|
||
<code>align_of::<Self>()</code>, this returns <code>None</code>.</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::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These bytes encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>].as_slice();
|
||
|
||
<span class="kw">let </span>header = PacketHeader::ref_from(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.ref_from_prefix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#1905-1910">Source</a><h4 class="code-header">fn <a href="#method.ref_from_prefix" class="fn">ref_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the prefix of the given <code>bytes</code> as a <code>&Self</code> without copying.</p>
|
||
<p><code>ref_from_prefix</code> returns a reference to the first <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code> or <code>bytes</code> is not
|
||
aligned to <code>align_of::<Self>()</code>, this returns <code>None</code>.</p>
|
||
<p>To also access the prefix bytes, use <a href="struct.Ref.html#method.new_from_prefix" title="associated function zerocopy::Ref::new_from_prefix"><code>Ref::new_from_prefix</code></a>. Then, use
|
||
<a href="struct.Ref.html#method.into_ref" title="method zerocopy::Ref::into_ref"><code>Ref::into_ref</code></a> to get a <code>&Self</code> with the same lifetime.</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>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>header = PacketHeader::ref_from_prefix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.ref_from_suffix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#1941-1946">Source</a><h4 class="code-header">fn <a href="#method.ref_from_suffix" class="fn">ref_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the suffix of the given <code>bytes</code> as a <code>&Self</code> without copying.</p>
|
||
<p><code>ref_from_suffix</code> returns a reference to the last <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code> or the suffix of
|
||
<code>bytes</code> is not aligned to <code>align_of::<Self>()</code>, this returns <code>None</code>.</p>
|
||
<p>To also access the suffix bytes, use <a href="struct.Ref.html#method.new_from_suffix" title="associated function zerocopy::Ref::new_from_suffix"><code>Ref::new_from_suffix</code></a>. Then, use
|
||
<a href="struct.Ref.html#method.into_ref" title="method zerocopy::Ref::into_ref"><code>Ref::into_ref</code></a> to get a <code>&Self</code> with the same lifetime.</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">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketTrailer {
|
||
frame_check_sequence: [u8; <span class="number">4</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketTrailer`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>trailer = PacketTrailer::ref_from_suffix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(trailer.frame_check_sequence, [<span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_from" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#1983-1988">Source</a><h4 class="code-header">fn <a href="#method.mut_from" class="fn">mut_from</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the given <code>bytes</code> as a <code>&mut Self</code> without copying.</p>
|
||
<p>If <code>bytes.len() != size_of::<Self>()</code> or <code>bytes</code> is not aligned to
|
||
<code>align_of::<Self>()</code>, this returns <code>None</code>.</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">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These bytes encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>][..];
|
||
|
||
<span class="kw">let </span>header = PacketHeader::mut_from(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);
|
||
|
||
header.checksum = [<span class="number">0</span>, <span class="number">0</span>];
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_from_prefix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2030-2035">Source</a><h4 class="code-header">fn <a href="#method.mut_from_prefix" class="fn">mut_from_prefix</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the prefix of the given <code>bytes</code> as a <code>&mut Self</code> without
|
||
copying.</p>
|
||
<p><code>mut_from_prefix</code> returns a reference to the first <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code> or <code>bytes</code> is not
|
||
aligned to <code>align_of::<Self>()</code>, this returns <code>None</code>.</p>
|
||
<p>To also access the prefix bytes, use <a href="struct.Ref.html#method.new_from_prefix" title="associated function zerocopy::Ref::new_from_prefix"><code>Ref::new_from_prefix</code></a>. Then, use
|
||
<a href="struct.Ref.html#method.into_mut" title="method zerocopy::Ref::into_mut"><code>Ref::into_mut</code></a> to get a <code>&mut Self</code> with the same lifetime.</p>
|
||
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>][..];
|
||
|
||
<span class="kw">let </span>header = PacketHeader::mut_from_prefix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);
|
||
|
||
header.checksum = [<span class="number">0</span>, <span class="number">0</span>];
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">8</span>, <span class="number">9</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_from_suffix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2070-2075">Source</a><h4 class="code-header">fn <a href="#method.mut_from_suffix" class="fn">mut_from_suffix</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut Self><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the suffix of the given <code>bytes</code> as a <code>&mut Self</code> without copying.</p>
|
||
<p><code>mut_from_suffix</code> returns a reference to the last <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code> or the suffix of
|
||
<code>bytes</code> is not aligned to <code>align_of::<Self>()</code>, this returns <code>None</code>.</p>
|
||
<p>To also access the suffix bytes, use <a href="struct.Ref.html#method.new_from_suffix" title="associated function zerocopy::Ref::new_from_suffix"><code>Ref::new_from_suffix</code></a>. Then,
|
||
use <a href="struct.Ref.html#method.into_mut" title="method zerocopy::Ref::into_mut"><code>Ref::into_mut</code></a> to get a <code>&mut Self</code> with the same lifetime.</p>
|
||
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketTrailer {
|
||
frame_check_sequence: [u8; <span class="number">4</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketTrailer`.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>][..];
|
||
|
||
<span class="kw">let </span>trailer = PacketTrailer::mut_from_suffix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(trailer.frame_check_sequence, [<span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]);
|
||
|
||
trailer.frame_check_sequence = [<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>];
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.slice_from" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2117-2122">Source</a><h4 class="code-header">fn <a href="#method.slice_from" class="fn">slice_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&[Self]><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the given <code>bytes</code> as a <code>&[Self]</code> without copying.</p>
|
||
<p>If <code>bytes.len() % size_of::<Self>() != 0</code> or <code>bytes</code> is not aligned to
|
||
<code>align_of::<Self>()</code>, this returns <code>None</code>.</p>
|
||
<p>If you need to convert a specific number of slice elements, see
|
||
<a href="trait.FromBytes.html#method.slice_from_prefix" title="associated function zerocopy::FromBytes::slice_from_prefix"><code>slice_from_prefix</code></a> or
|
||
<a href="trait.FromBytes.html#method.slice_from_suffix" title="associated function zerocopy::FromBytes::slice_from_suffix"><code>slice_from_suffix</code></a>.</p>
|
||
<h5 id="panics"><a class="doc-anchor" href="#panics">§</a>Panics</h5>
|
||
<p>If <code>Self</code> is a zero-sized type.</p>
|
||
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These bytes encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>].as_slice();
|
||
|
||
<span class="kw">let </span>pixels = Pixel::slice_from(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">0</span>, g: <span class="number">1</span>, b: <span class="number">2</span>, a: <span class="number">3 </span>},
|
||
Pixel { r: <span class="number">4</span>, g: <span class="number">5</span>, b: <span class="number">6</span>, a: <span class="number">7 </span>},
|
||
]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.slice_from_prefix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2168-2173">Source</a><h4 class="code-header">fn <a href="#method.slice_from_prefix" class="fn">slice_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&[Self], &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>])><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the prefix of the given <code>bytes</code> as a <code>&[Self]</code> with length
|
||
equal to <code>count</code> without copying.</p>
|
||
<p>This method verifies that <code>bytes.len() >= size_of::<T>() * count</code>
|
||
and that <code>bytes</code> is aligned to <code>align_of::<T>()</code>. It consumes the
|
||
first <code>size_of::<T>() * count</code> bytes from <code>bytes</code> to construct a
|
||
<code>&[Self]</code>, and returns the remaining bytes to the caller. It also
|
||
ensures that <code>sizeof::<T>() * count</code> does not overflow a <code>usize</code>.
|
||
If any of the length, alignment, or overflow checks fail, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="panics-1"><a class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
||
<p>If <code>T</code> is a zero-sized type.</p>
|
||
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>(pixels, rest) = Pixel::slice_from_prefix(bytes, <span class="number">2</span>).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">0</span>, g: <span class="number">1</span>, b: <span class="number">2</span>, a: <span class="number">3 </span>},
|
||
Pixel { r: <span class="number">4</span>, g: <span class="number">5</span>, b: <span class="number">6</span>, a: <span class="number">7 </span>},
|
||
]);
|
||
|
||
<span class="macro">assert_eq!</span>(rest, <span class="kw-2">&</span>[<span class="number">8</span>, <span class="number">9</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.slice_from_suffix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2219-2224">Source</a><h4 class="code-header">fn <a href="#method.slice_from_suffix" class="fn">slice_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], &[Self])><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Interprets the suffix of the given <code>bytes</code> as a <code>&[Self]</code> with length
|
||
equal to <code>count</code> without copying.</p>
|
||
<p>This method verifies that <code>bytes.len() >= size_of::<T>() * count</code>
|
||
and that <code>bytes</code> is aligned to <code>align_of::<T>()</code>. It consumes the
|
||
last <code>size_of::<T>() * count</code> bytes from <code>bytes</code> to construct a
|
||
<code>&[Self]</code>, and returns the preceding bytes to the caller. It also
|
||
ensures that <code>sizeof::<T>() * count</code> does not overflow a <code>usize</code>.
|
||
If any of the length, alignment, or overflow checks fail, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="panics-2"><a class="doc-anchor" href="#panics-2">§</a>Panics</h5>
|
||
<p>If <code>T</code> is a zero-sized type.</p>
|
||
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>(rest, pixels) = Pixel::slice_from_suffix(bytes, <span class="number">2</span>).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(rest, <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>]);
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">2</span>, g: <span class="number">3</span>, b: <span class="number">4</span>, a: <span class="number">5 </span>},
|
||
Pixel { r: <span class="number">6</span>, g: <span class="number">7</span>, b: <span class="number">8</span>, a: <span class="number">9 </span>},
|
||
]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_slice_from" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2270-2275">Source</a><h4 class="code-header">fn <a href="#method.mut_slice_from" class="fn">mut_slice_from</a>(bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&mut [Self]><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the given <code>bytes</code> as a <code>&mut [Self]</code> without copying.</p>
|
||
<p>If <code>bytes.len() % size_of::<T>() != 0</code> or <code>bytes</code> is not aligned to
|
||
<code>align_of::<T>()</code>, this returns <code>None</code>.</p>
|
||
<p>If you need to convert a specific number of slice elements, see
|
||
<a href="trait.FromBytes.html#method.mut_slice_from_prefix" title="associated function zerocopy::FromBytes::mut_slice_from_prefix"><code>mut_slice_from_prefix</code></a> or
|
||
<a href="trait.FromBytes.html#method.mut_slice_from_suffix" title="associated function zerocopy::FromBytes::mut_slice_from_suffix"><code>mut_slice_from_suffix</code></a>.</p>
|
||
<h5 id="panics-3"><a class="doc-anchor" href="#panics-3">§</a>Panics</h5>
|
||
<p>If <code>T</code> is a zero-sized type.</p>
|
||
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These bytes encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>][..];
|
||
|
||
<span class="kw">let </span>pixels = Pixel::mut_slice_from(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">0</span>, g: <span class="number">1</span>, b: <span class="number">2</span>, a: <span class="number">3 </span>},
|
||
Pixel { r: <span class="number">4</span>, g: <span class="number">5</span>, b: <span class="number">6</span>, a: <span class="number">7 </span>},
|
||
]);
|
||
|
||
pixels[<span class="number">1</span>] = Pixel { r: <span class="number">0</span>, g: <span class="number">0</span>, b: <span class="number">0</span>, a: <span class="number">0 </span>};
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_slice_from_prefix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2325-2330">Source</a><h4 class="code-header">fn <a href="#method.mut_slice_from_prefix" class="fn">mut_slice_from_prefix</a>(
|
||
bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>],
|
||
count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&mut [Self], &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>])><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the prefix of the given <code>bytes</code> as a <code>&mut [Self]</code> with length
|
||
equal to <code>count</code> without copying.</p>
|
||
<p>This method verifies that <code>bytes.len() >= size_of::<T>() * count</code>
|
||
and that <code>bytes</code> is aligned to <code>align_of::<T>()</code>. It consumes the
|
||
first <code>size_of::<T>() * count</code> bytes from <code>bytes</code> to construct a
|
||
<code>&[Self]</code>, and returns the remaining bytes to the caller. It also
|
||
ensures that <code>sizeof::<T>() * count</code> does not overflow a <code>usize</code>.
|
||
If any of the length, alignment, or overflow checks fail, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="panics-4"><a class="doc-anchor" href="#panics-4">§</a>Panics</h5>
|
||
<p>If <code>T</code> is a zero-sized type.</p>
|
||
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>][..];
|
||
|
||
<span class="kw">let </span>(pixels, rest) = Pixel::mut_slice_from_prefix(bytes, <span class="number">2</span>).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">0</span>, g: <span class="number">1</span>, b: <span class="number">2</span>, a: <span class="number">3 </span>},
|
||
Pixel { r: <span class="number">4</span>, g: <span class="number">5</span>, b: <span class="number">6</span>, a: <span class="number">7 </span>},
|
||
]);
|
||
|
||
<span class="macro">assert_eq!</span>(rest, <span class="kw-2">&</span>[<span class="number">8</span>, <span class="number">9</span>]);
|
||
|
||
pixels[<span class="number">1</span>] = Pixel { r: <span class="number">0</span>, g: <span class="number">0</span>, b: <span class="number">0</span>, a: <span class="number">0 </span>};
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">8</span>, <span class="number">9</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.mut_slice_from_suffix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2380-2385">Source</a><h4 class="code-header">fn <a href="#method.mut_slice_from_suffix" class="fn">mut_slice_from_suffix</a>(
|
||
bytes: &mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>],
|
||
count: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>,
|
||
) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&mut [<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>], &mut [Self])><div class="where">where
|
||
Self: <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.AsBytes.html" title="trait zerocopy::AsBytes">AsBytes</a>,</div></h4></section></summary><div class="docblock"><p>Interprets the suffix of the given <code>bytes</code> as a <code>&mut [Self]</code> with length
|
||
equal to <code>count</code> without copying.</p>
|
||
<p>This method verifies that <code>bytes.len() >= size_of::<T>() * count</code>
|
||
and that <code>bytes</code> is aligned to <code>align_of::<T>()</code>. It consumes the
|
||
last <code>size_of::<T>() * count</code> bytes from <code>bytes</code> to construct a
|
||
<code>&[Self]</code>, and returns the preceding bytes to the caller. It also
|
||
ensures that <code>sizeof::<T>() * count</code> does not overflow a <code>usize</code>.
|
||
If any of the length, alignment, or overflow checks fail, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="panics-5"><a class="doc-anchor" href="#panics-5">§</a>Panics</h5>
|
||
<p>If <code>T</code> is a zero-sized type.</p>
|
||
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(AsBytes, FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>Pixel {
|
||
r: u8,
|
||
g: u8,
|
||
b: u8,
|
||
a: u8,
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode two `Pixel`s.
|
||
</span><span class="kw">let </span>bytes = <span class="kw-2">&mut </span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>][..];
|
||
|
||
<span class="kw">let </span>(rest, pixels) = Pixel::mut_slice_from_suffix(bytes, <span class="number">2</span>).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(rest, <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>]);
|
||
|
||
<span class="macro">assert_eq!</span>(pixels, <span class="kw-2">&</span>[
|
||
Pixel { r: <span class="number">2</span>, g: <span class="number">3</span>, b: <span class="number">4</span>, a: <span class="number">5 </span>},
|
||
Pixel { r: <span class="number">6</span>, g: <span class="number">7</span>, b: <span class="number">8</span>, a: <span class="number">9 </span>},
|
||
]);
|
||
|
||
pixels[<span class="number">1</span>] = Pixel { r: <span class="number">0</span>, g: <span class="number">0</span>, b: <span class="number">0</span>, a: <span class="number">0 </span>};
|
||
|
||
<span class="macro">assert_eq!</span>(bytes, [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_from" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2417-2422">Source</a><h4 class="code-header">fn <a href="#method.read_from" class="fn">read_from</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Reads a copy of <code>Self</code> from <code>bytes</code>.</p>
|
||
<p>If <code>bytes.len() != size_of::<Self>()</code>, <code>read_from</code> returns <code>None</code>.</p>
|
||
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These bytes encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>].as_slice();
|
||
|
||
<span class="kw">let </span>header = PacketHeader::read_from(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_from_prefix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2456-2462">Source</a><h4 class="code-header">fn <a href="#method.read_from_prefix" class="fn">read_from_prefix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Reads a copy of <code>Self</code> from the prefix of <code>bytes</code>.</p>
|
||
<p><code>read_from_prefix</code> reads a <code>Self</code> from the first <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code>, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketHeader {
|
||
src_port: [u8; <span class="number">2</span>],
|
||
dst_port: [u8; <span class="number">2</span>],
|
||
length: [u8; <span class="number">2</span>],
|
||
checksum: [u8; <span class="number">2</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketHeader`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>header = PacketHeader::read_from_prefix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(header.src_port, [<span class="number">0</span>, <span class="number">1</span>]);
|
||
<span class="macro">assert_eq!</span>(header.dst_port, [<span class="number">2</span>, <span class="number">3</span>]);
|
||
<span class="macro">assert_eq!</span>(header.length, [<span class="number">4</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq!</span>(header.checksum, [<span class="number">6</span>, <span class="number">7</span>]);</code></pre></div>
|
||
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_from_suffix" class="method"><a class="src rightside" href="../src/zerocopy/lib.rs.html#2490-2496">Source</a><h4 class="code-header">fn <a href="#method.read_from_suffix" class="fn">read_from_suffix</a>(bytes: &[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>]) -> <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><Self><div class="where">where
|
||
Self: <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></h4></section></summary><div class="docblock"><p>Reads a copy of <code>Self</code> from the suffix of <code>bytes</code>.</p>
|
||
<p><code>read_from_suffix</code> reads a <code>Self</code> from the last <code>size_of::<Self>()</code>
|
||
bytes of <code>bytes</code>. If <code>bytes.len() < size_of::<Self>()</code>, it returns
|
||
<code>None</code>.</p>
|
||
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>zerocopy::FromBytes;
|
||
|
||
<span class="attr">#[derive(FromZeroes, FromBytes)]
|
||
#[repr(C)]
|
||
</span><span class="kw">struct </span>PacketTrailer {
|
||
frame_check_sequence: [u8; <span class="number">4</span>],
|
||
}
|
||
|
||
<span class="comment">// These are more bytes than are needed to encode a `PacketTrailer`.
|
||
</span><span class="kw">let </span>bytes = [<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">4</span>, <span class="number">5</span>, <span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>].as_slice();
|
||
|
||
<span class="kw">let </span>trailer = PacketTrailer::read_from_suffix(bytes).unwrap();
|
||
|
||
<span class="macro">assert_eq!</span>(trailer.frame_check_sequence, [<span class="number">6</span>, <span class="number">7</span>, <span class="number">8</span>, <span class="number">9</span>]);</code></pre></div>
|
||
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><section id="impl-FromBytes-for-Option%3CNonZero%3Ci8%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci8%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroI8.html" title="type core::num::nonzero::NonZeroI8">NonZeroI8</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Ci16%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci16%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroI16.html" title="type core::num::nonzero::NonZeroI16">NonZeroI16</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Ci32%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci32%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroI32.html" title="type core::num::nonzero::NonZeroI32">NonZeroI32</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Ci64%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci64%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroI64.html" title="type core::num::nonzero::NonZeroI64">NonZeroI64</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Ci128%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Ci128%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroI128.html" title="type core::num::nonzero::NonZeroI128">NonZeroI128</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cisize%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cisize%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroIsize.html" title="type core::num::nonzero::NonZeroIsize">NonZeroIsize</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cu8%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu8%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroU8.html" title="type core::num::nonzero::NonZeroU8">NonZeroU8</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cu16%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu16%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroU16.html" title="type core::num::nonzero::NonZeroU16">NonZeroU16</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cu32%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu32%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroU32.html" title="type core::num::nonzero::NonZeroU32">NonZeroU32</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cu64%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu64%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroU64.html" title="type core::num::nonzero::NonZeroU64">NonZeroU64</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cu128%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cu128%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroU128.html" title="type core::num::nonzero::NonZeroU128">NonZeroU128</a>></h3></section><section id="impl-FromBytes-for-Option%3CNonZero%3Cusize%3E%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3309-3342">Source</a><a href="#impl-FromBytes-for-Option%3CNonZero%3Cusize%3E%3E" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="enum" href="https://doc.rust-lang.org/1.84.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="type" href="https://doc.rust-lang.org/1.84.1/core/num/nonzero/type.NonZeroUsize.html" title="type core::num::nonzero::NonZeroUsize">NonZeroUsize</a>></h3></section><section id="impl-FromBytes-for-f32" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-f32" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.f32.html">f32</a></h3></section><section id="impl-FromBytes-for-f64" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-f64" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.f64.html">f64</a></h3></section><section id="impl-FromBytes-for-i8" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-i8" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.i8.html">i8</a></h3></section><section id="impl-FromBytes-for-i16" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-i16" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.i16.html">i16</a></h3></section><section id="impl-FromBytes-for-i32" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-i32" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.i32.html">i32</a></h3></section><section id="impl-FromBytes-for-i64" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-i64" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.i64.html">i64</a></h3></section><section id="impl-FromBytes-for-i128" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-i128" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.i128.html">i128</a></h3></section><section id="impl-FromBytes-for-isize" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-isize" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.isize.html">isize</a></h3></section><section id="impl-FromBytes-for-u8" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-u8" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a></h3></section><section id="impl-FromBytes-for-u16" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-u16" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u16.html">u16</a></h3></section><section id="impl-FromBytes-for-u32" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-u32" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u32.html">u32</a></h3></section><section id="impl-FromBytes-for-u64" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-u64" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u64.html">u64</a></h3></section><section id="impl-FromBytes-for-u128" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-u128" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u128.html">u128</a></h3></section><section id="impl-FromBytes-for-()" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3028-3040">Source</a><a href="#impl-FromBytes-for-()" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.unit.html">()</a></h3></section><section id="impl-FromBytes-for-usize" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3042-3091">Source</a><a href="#impl-FromBytes-for-usize" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a></h3></section><section id="impl-FromBytes-for-__m128" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m128" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m128.html" title="struct core::core_arch::x86::__m128">__m128</a></h3></section><section id="impl-FromBytes-for-__m128d" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m128d" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m128d.html" title="struct core::core_arch::x86::__m128d">__m128d</a></h3></section><section id="impl-FromBytes-for-__m128i" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m128i" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m128i.html" title="struct core::core_arch::x86::__m128i">__m128i</a></h3></section><section id="impl-FromBytes-for-__m256" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m256" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m256.html" title="struct core::core_arch::x86::__m256">__m256</a></h3></section><section id="impl-FromBytes-for-__m256d" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m256d" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m256d.html" title="struct core::core_arch::x86::__m256d">__m256d</a></h3></section><section id="impl-FromBytes-for-__m256i" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3718-3721">Source</a><a href="#impl-FromBytes-for-__m256i" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/core_arch/x86/struct.__m256i.html" title="struct core::core_arch::x86::__m256i">__m256i</a></h3></section><section id="impl-FromBytes-for-%5BT%5D" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3527-3595">Source</a><a href="#impl-FromBytes-for-%5BT%5D" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.slice.html">[T]</a></h3></section><section id="impl-FromBytes-for-Wrapping%3CT%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3404-3464">Source</a><a href="#impl-FromBytes-for-Wrapping%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/num/wrapping/struct.Wrapping.html" title="struct core::num::wrapping::Wrapping">Wrapping</a><T></h3></section><section id="impl-FromBytes-for-MaybeUninit%3CT%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3465-3491">Source</a><a href="#impl-FromBytes-for-MaybeUninit%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="union" href="https://doc.rust-lang.org/1.84.1/core/mem/maybe_uninit/union.MaybeUninit.html" title="union core::mem::maybe_uninit::MaybeUninit">MaybeUninit</a><T></h3></section><section id="impl-FromBytes-for-ManuallyDrop%3CT%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3492-3526">Source</a><a href="#impl-FromBytes-for-ManuallyDrop%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<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.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/mem/manually_drop/struct.ManuallyDrop.html" title="struct core::mem::manually_drop::ManuallyDrop">ManuallyDrop</a><T></h3></section><section id="impl-FromBytes-for-PhantomData%3CT%3E" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3381-3403">Source</a><a href="#impl-FromBytes-for-PhantomData%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<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.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><T></h3></section><section id="impl-FromBytes-for-%5BT;+N%5D" class="impl"><a class="src rightside" href="../src/zerocopy/lib.rs.html#3527-3595">Source</a><a href="#impl-FromBytes-for-%5BT;+N%5D" class="anchor">§</a><h3 class="code-header">impl<const N: <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.usize.html">usize</a>, T: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">[T; N]</a></h3></section><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-FromBytes-for-F32%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#551-564">Source</a><a href="#impl-FromBytes-for-F32%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.F32.html" title="struct zerocopy::byteorder::F32">F32</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">4</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-F64%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#565">Source</a><a href="#impl-FromBytes-for-F64%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.F64.html" title="struct zerocopy::byteorder::F64">F64</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">8</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-I16%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#508-521">Source</a><a href="#impl-FromBytes-for-I16%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.I16.html" title="struct zerocopy::byteorder::I16">I16</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">2</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-I32%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#522-535">Source</a><a href="#impl-FromBytes-for-I32%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.I32.html" title="struct zerocopy::byteorder::I32">I32</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">4</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-I64%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#536-549">Source</a><a href="#impl-FromBytes-for-I64%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.I64.html" title="struct zerocopy::byteorder::I64">I64</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">8</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-I128%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#550">Source</a><a href="#impl-FromBytes-for-I128%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.I128.html" title="struct zerocopy::byteorder::I128">I128</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">16</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-U16%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#465-478">Source</a><a href="#impl-FromBytes-for-U16%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.U16.html" title="struct zerocopy::byteorder::U16">U16</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">2</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-U32%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#479-492">Source</a><a href="#impl-FromBytes-for-U32%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.U32.html" title="struct zerocopy::byteorder::U32">U32</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">4</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-U64%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#493-506">Source</a><a href="#impl-FromBytes-for-U64%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.U64.html" title="struct zerocopy::byteorder::U64">U64</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">8</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-U128%3CO%3E" class="impl"><a class="src rightside" href="../src/zerocopy/byteorder.rs.html#507">Source</a><a href="#impl-FromBytes-for-U128%3CO%3E" class="anchor">§</a><h3 class="code-header">impl<O> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="byteorder/struct.U128.html" title="struct zerocopy::byteorder::U128">U128</a><O><div class="where">where
|
||
[<a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.u8.html">u8</a>; <a class="primitive" href="https://doc.rust-lang.org/1.84.1/core/primitive.array.html">16</a>]: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,
|
||
<a class="struct" href="https://doc.rust-lang.org/1.84.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a><O>: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section><section id="impl-FromBytes-for-Unalign%3CT%3E" class="impl"><a class="src rightside" href="../src/zerocopy/wrappers.rs.html#63">Source</a><a href="#impl-FromBytes-for-Unalign%3CT%3E" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a> for <a class="struct" href="struct.Unalign.html" title="struct zerocopy::Unalign">Unalign</a><T><div class="where">where
|
||
T: <a class="trait" href="trait.FromBytes.html" title="trait zerocopy::FromBytes">FromBytes</a>,</div></h3></section></div><script src="../trait.impl/zerocopy/trait.FromBytes.js" data-ignore-extern-crates="core" async></script></section></div></main></body></html> |