-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathindex.html
26 lines (22 loc) · 7.61 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<!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="Wrapper types to enable optimized handling of `&[u8]` and `Vec<u8>`."><title>serde_bytes - 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-46132b98.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="serde_bytes" data-themes="" data-resource-suffix="" data-rustdoc-version="1.85.0 (4d91de4e4 2025-02-17)" data-channel="1.85.0" data-search-js="search-75f5ac3e.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../serde_bytes/index.html">serde_<wbr>bytes</a><span class="version">0.11.17</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="#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><li><a href="#traits" title="Traits">Traits</a></li><li><a href="#functions" title="Functions">Functions</a></li></ul></section><div id="rustdoc-modnav"></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <span>serde_bytes</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/serde_bytes/lib.rs.html#1-124">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Wrapper types to enable optimized handling of <code>&[u8]</code> and <code>Vec<u8></code>.</p>
<p>Without specialization, Rust forces Serde to treat <code>&[u8]</code> just like any
other slice and <code>Vec<u8></code> just like any other vector. In reality this
particular slice and vector can often be serialized and deserialized in a
more efficient, compact representation in many formats.</p>
<p>When working with such a format, you can opt into specialized handling of
<code>&[u8]</code> by wrapping it in <code>serde_bytes::Bytes</code> and <code>Vec<u8></code> by wrapping it
in <code>serde_bytes::ByteBuf</code>.</p>
<p>Additionally this crate supports the Serde <code>with</code> attribute to enable
efficient handling of <code>&[u8]</code> and <code>Vec<u8></code> in structs without needing a
wrapper type.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>serde::{Deserialize, Serialize};
<span class="attr">#[derive(Deserialize, Serialize)]
</span><span class="kw">struct </span>Efficient<<span class="lifetime">'a</span>> {
<span class="attr">#[serde(with = <span class="string">"serde_bytes"</span>)]
</span>bytes: <span class="kw-2">&</span><span class="lifetime">'a </span>[u8],
<span class="attr">#[serde(with = <span class="string">"serde_bytes"</span>)]
</span>byte_buf: Vec<u8>,
<span class="attr">#[serde(with = <span class="string">"serde_bytes"</span>)]
</span>byte_array: [u8; <span class="number">314</span>],
}</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="bytearray/index.html" title="mod serde_bytes::bytearray">bytearray</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="mod" href="bytebuf/index.html" title="mod serde_bytes::bytebuf">bytebuf</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="mod" href="bytes/index.html" title="mod serde_bytes::bytes">bytes</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="mod" href="de/index.html" title="mod serde_bytes::de">de</a><span title="Restricted Visibility"> 🔒</span> </div></li><li><div class="item-name"><a class="mod" href="ser/index.html" title="mod serde_bytes::ser">ser</a><span title="Restricted Visibility"> 🔒</span> </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.ByteArray.html" title="struct serde_bytes::ByteArray">Byte<wbr>Array</a></div><div class="desc docblock-short">Wrapper around <code>[u8; N]</code> to serialize and deserialize efficiently.</div></li><li><div class="item-name"><a class="struct" href="struct.ByteBuf.html" title="struct serde_bytes::ByteBuf">ByteBuf</a></div><div class="desc docblock-short">Wrapper around <code>Vec<u8></code> to serialize and deserialize efficiently.</div></li><li><div class="item-name"><a class="struct" href="struct.Bytes.html" title="struct serde_bytes::Bytes">Bytes</a></div><div class="desc docblock-short">Wrapper around <code>[u8]</code> to serialize and deserialize efficiently.</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.Deserialize.html" title="trait serde_bytes::Deserialize">Deserialize</a></div><div class="desc docblock-short">Types that can be deserialized via <code>#[serde(with = "serde_bytes")]</code>.</div></li><li><div class="item-name"><a class="trait" href="trait.Serialize.html" title="trait serde_bytes::Serialize">Serialize</a></div><div class="desc docblock-short">Types that can be serialized via <code>#[serde(with = "serde_bytes")]</code>.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.deserialize.html" title="fn serde_bytes::deserialize">deserialize</a></div><div class="desc docblock-short">Serde <code>deserialize_with</code> function to deserialize bytes efficiently.</div></li><li><div class="item-name"><a class="fn" href="fn.serialize.html" title="fn serde_bytes::serialize">serialize</a></div><div class="desc docblock-short">Serde <code>serialize_with</code> function to serialize bytes efficiently.</div></li></ul></section></div></main></body></html>