46 lines
20 KiB
HTML
46 lines
20 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="rend"><title>rend - 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="rend" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../rend/index.html">rend</a><span class="version">0.5.2</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section id="rustdoc-toc"><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#rend" title="rend">rend</a><ul><li><a href="#features" title="Features">Features</a></li><li><a href="#crates" title="Crates">Crates</a></li><li><a href="#example" title="Example:">Example:</a></li></ul></li></ul><h3><a href="#modules">Crate Items</a></h3><ul class="block"><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>rend</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/rend/lib.rs.html#1-1227">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><h2 id="rend"><a class="doc-anchor" href="#rend">§</a>rend</h2>
|
|
<p>rend provides cross-platform, endian-aware primitives for Rust.</p>
|
|
<p>rend does not provide cross-platform alternatives for types that are
|
|
inherently cross-platform, such as <code>bool</code> and <code>u8</code>. It also does not provide
|
|
cross-platform alternatives for types that have an architecture-dependent
|
|
size, such as <code>isize</code> and <code>usize</code>. rend does not support custom types.</p>
|
|
<p>rend is intended to be used to build portable types that can be shared
|
|
between different architectures.</p>
|
|
<h3 id="features"><a class="doc-anchor" href="#features">§</a>Features</h3>
|
|
<ul>
|
|
<li><code>bytecheck</code>: Enables support for validating types using <code>bytecheck</code>.</li>
|
|
</ul>
|
|
<h3 id="crates"><a class="doc-anchor" href="#crates">§</a>Crates</h3>
|
|
<ul>
|
|
<li><code>zerocopy-0_8</code></li>
|
|
</ul>
|
|
<h3 id="example"><a class="doc-anchor" href="#example">§</a>Example:</h3>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>core::mem::transmute;
|
|
<span class="kw">use </span>rend::<span class="kw-2">*</span>;
|
|
|
|
<span class="kw">let </span>little_int = i32_le::from_native(<span class="number">0x12345678</span>);
|
|
<span class="comment">// Internal representation is little-endian
|
|
</span><span class="macro">assert_eq!</span>(
|
|
[<span class="number">0x78</span>, <span class="number">0x56</span>, <span class="number">0x34</span>, <span class="number">0x12</span>],
|
|
<span class="kw">unsafe </span>{ transmute::<<span class="kw">_</span>, [u8; <span class="number">4</span>]>(little_int) }
|
|
);
|
|
|
|
<span class="comment">// Can also be made with `.into()`
|
|
</span><span class="kw">let </span>little_int: i32_le = <span class="number">0x12345678</span>.into();
|
|
<span class="comment">// Still formats correctly
|
|
</span><span class="macro">assert_eq!</span>(<span class="string">"305419896"</span>, <span class="macro">format!</span>(<span class="string">"{}"</span>, little_int));
|
|
<span class="macro">assert_eq!</span>(<span class="string">"0x12345678"</span>, <span class="macro">format!</span>(<span class="string">"0x{:x}"</span>, little_int));
|
|
|
|
<span class="kw">let </span>big_int = i32_be::from_native(<span class="number">0x12345678</span>);
|
|
<span class="comment">// Internal representation is big-endian
|
|
</span><span class="macro">assert_eq!</span>(
|
|
[<span class="number">0x12</span>, <span class="number">0x34</span>, <span class="number">0x56</span>, <span class="number">0x78</span>],
|
|
<span class="kw">unsafe </span>{ transmute::<<span class="kw">_</span>, [u8; <span class="number">4</span>]>(big_int) }
|
|
);
|
|
|
|
<span class="comment">// Can also be made with `.into()`
|
|
</span><span class="kw">let </span>big_int: i32_be = <span class="number">0x12345678</span>.into();
|
|
<span class="comment">// Still formats correctly
|
|
</span><span class="macro">assert_eq!</span>(<span class="string">"305419896"</span>, <span class="macro">format!</span>(<span class="string">"{}"</span>, big_int));
|
|
<span class="macro">assert_eq!</span>(<span class="string">"0x12345678"</span>, <span class="macro">format!</span>(<span class="string">"0x{:x}"</span>, big_int));</code></pre></div>
|
|
</div></details><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="unaligned/index.html" title="mod rend::unaligned">unaligned</a></div><div class="desc docblock-short">Cross-platform primitives with unaligned representations.</div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.AtomicI16_be.html" title="struct rend::AtomicI16_be">Atomic<wbr>I16_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicI16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicI16_le.html" title="struct rend::AtomicI16_le">Atomic<wbr>I16_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicI16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicI32_be.html" title="struct rend::AtomicI32_be">Atomic<wbr>I32_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicI32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicI32_le.html" title="struct rend::AtomicI32_le">Atomic<wbr>I32_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicI32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicI64_be.html" title="struct rend::AtomicI64_be">Atomic<wbr>I64_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicI64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicI64_le.html" title="struct rend::AtomicI64_le">Atomic<wbr>I64_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicI64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU16_be.html" title="struct rend::AtomicU16_be">Atomic<wbr>U16_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicU16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU16_le.html" title="struct rend::AtomicU16_le">Atomic<wbr>U16_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicU16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU32_be.html" title="struct rend::AtomicU32_be">Atomic<wbr>U32_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicU32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU32_le.html" title="struct rend::AtomicU32_le">Atomic<wbr>U32_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicU32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU64_be.html" title="struct rend::AtomicU64_be">Atomic<wbr>U64_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>AtomicU64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.AtomicU64_le.html" title="struct rend::AtomicU64_le">Atomic<wbr>U64_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>AtomicU64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI16_be.html" title="struct rend::NonZeroI16_be">NonZero<wbr>I16_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroI16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI16_le.html" title="struct rend::NonZeroI16_le">NonZero<wbr>I16_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroI16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI32_be.html" title="struct rend::NonZeroI32_be">NonZero<wbr>I32_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroI32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI32_le.html" title="struct rend::NonZeroI32_le">NonZero<wbr>I32_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroI32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI64_be.html" title="struct rend::NonZeroI64_be">NonZero<wbr>I64_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroI64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI64_le.html" title="struct rend::NonZeroI64_le">NonZero<wbr>I64_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroI64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI128_be.html" title="struct rend::NonZeroI128_be">NonZero<wbr>I128_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroI128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroI128_le.html" title="struct rend::NonZeroI128_le">NonZero<wbr>I128_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroI128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU16_be.html" title="struct rend::NonZeroU16_be">NonZero<wbr>U16_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroU16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU16_le.html" title="struct rend::NonZeroU16_le">NonZero<wbr>U16_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroU16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU32_be.html" title="struct rend::NonZeroU32_be">NonZero<wbr>U32_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroU32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU32_le.html" title="struct rend::NonZeroU32_le">NonZero<wbr>U32_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroU32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU64_be.html" title="struct rend::NonZeroU64_be">NonZero<wbr>U64_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroU64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU64_le.html" title="struct rend::NonZeroU64_le">NonZero<wbr>U64_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroU64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU128_be.html" title="struct rend::NonZeroU128_be">NonZero<wbr>U128_<wbr>be</a></div><div class="desc docblock-short">A big-endian <code>NonZeroU128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.NonZeroU128_le.html" title="struct rend::NonZeroU128_le">NonZero<wbr>U128_<wbr>le</a></div><div class="desc docblock-short">A little-endian <code>NonZeroU128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.char_be.html" title="struct rend::char_be">char_be</a></div><div class="desc docblock-short">A big-endian <code>u32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.char_le.html" title="struct rend::char_le">char_le</a></div><div class="desc docblock-short">A little-endian <code>u32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.f32_be.html" title="struct rend::f32_be">f32_be</a></div><div class="desc docblock-short">A big-endian <code>f32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.f32_le.html" title="struct rend::f32_le">f32_le</a></div><div class="desc docblock-short">A little-endian <code>f32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.f64_be.html" title="struct rend::f64_be">f64_be</a></div><div class="desc docblock-short">A big-endian <code>f64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.f64_le.html" title="struct rend::f64_le">f64_le</a></div><div class="desc docblock-short">A little-endian <code>f64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i16_be.html" title="struct rend::i16_be">i16_be</a></div><div class="desc docblock-short">A big-endian <code>i16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i16_le.html" title="struct rend::i16_le">i16_le</a></div><div class="desc docblock-short">A little-endian <code>i16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i32_be.html" title="struct rend::i32_be">i32_be</a></div><div class="desc docblock-short">A big-endian <code>i32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i32_le.html" title="struct rend::i32_le">i32_le</a></div><div class="desc docblock-short">A little-endian <code>i32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i64_be.html" title="struct rend::i64_be">i64_be</a></div><div class="desc docblock-short">A big-endian <code>i64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i64_le.html" title="struct rend::i64_le">i64_le</a></div><div class="desc docblock-short">A little-endian <code>i64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i128_be.html" title="struct rend::i128_be">i128_be</a></div><div class="desc docblock-short">A big-endian <code>i128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.i128_le.html" title="struct rend::i128_le">i128_le</a></div><div class="desc docblock-short">A little-endian <code>i128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u16_be.html" title="struct rend::u16_be">u16_be</a></div><div class="desc docblock-short">A big-endian <code>u16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u16_le.html" title="struct rend::u16_le">u16_le</a></div><div class="desc docblock-short">A little-endian <code>u16</code> with a guaranteed size and alignment of <code>2</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u32_be.html" title="struct rend::u32_be">u32_be</a></div><div class="desc docblock-short">A big-endian <code>u32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u32_le.html" title="struct rend::u32_le">u32_le</a></div><div class="desc docblock-short">A little-endian <code>u32</code> with a guaranteed size and alignment of <code>4</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u64_be.html" title="struct rend::u64_be">u64_be</a></div><div class="desc docblock-short">A big-endian <code>u64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u64_le.html" title="struct rend::u64_le">u64_le</a></div><div class="desc docblock-short">A little-endian <code>u64</code> with a guaranteed size and alignment of <code>8</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u128_be.html" title="struct rend::u128_be">u128_be</a></div><div class="desc docblock-short">A big-endian <code>u128</code> with a guaranteed size and alignment of <code>16</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.u128_le.html" title="struct rend::u128_le">u128_le</a></div><div class="desc docblock-short">A little-endian <code>u128</code> with a guaranteed size and alignment of <code>16</code>.</div></li></ul></section></div></main></body></html> |