mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-17 16:29:50 +00:00
26 lines
No EOL
9.4 KiB
HTML
26 lines
No EOL
9.4 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="`bincode` uses a Builder-pattern to configure the Serializers and Deserializers in this crate. This means that if you need to customize the behavior of `bincode`, you should create an instance of the `DefaultOptions` struct:"><title>bincode::config - 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="bincode" 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 mod"><!--[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="../../bincode/index.html">bincode</a><span class="version">1.3.3</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Module config</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#options-struct-vs-bincode-functions" title="Options Struct vs bincode functions">Options Struct vs bincode functions</a></li></ul><h3><a href="#structs">Module Items</a></h3><ul class="block"><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#traits" title="Traits">Traits</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="../index.html">In crate bincode</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">bincode</a></span><h1>Module <span>config</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/bincode/config/mod.rs.html#1-408">Source</a> </span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p><code>bincode</code> uses a Builder-pattern to configure the Serializers and Deserializers in this
|
||
crate. This means that if you need to customize the behavior of <code>bincode</code>, you should create an
|
||
instance of the <code>DefaultOptions</code> struct:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bincode::Options;
|
||
<span class="kw">let </span>my_options = bincode::DefaultOptions::new();</code></pre></div>
|
||
<h2 id="options-struct-vs-bincode-functions"><a class="doc-anchor" href="#options-struct-vs-bincode-functions">§</a>Options Struct vs bincode functions</h2>
|
||
<p>Due to historical reasons, the default options used by the <code>serialize()</code> and <code>deserialize()</code>
|
||
family of functions are different than the default options created by the <code>DefaultOptions</code> struct:</p>
|
||
<div><table><thead><tr><th></th><th>Byte limit</th><th>Endianness</th><th>Int Encoding</th><th>Trailing Behavior</th></tr></thead><tbody>
|
||
<tr><td>struct</td><td>Unlimited</td><td>Little</td><td>Varint</td><td>Reject</td></tr>
|
||
<tr><td>function</td><td>Unlimited</td><td>Little</td><td>Fixint</td><td>Allow</td></tr>
|
||
</tbody></table>
|
||
</div>
|
||
<p>This means that if you want to use the <code>Serialize</code> / <code>Deserialize</code> structs with the same
|
||
settings as the functions, you should adjust the <code>DefaultOptions</code> struct like so:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>bincode::Options;
|
||
<span class="kw">let </span>my_options = bincode::DefaultOptions::new()
|
||
.with_fixint_encoding()
|
||
.allow_trailing_bytes();</code></pre></div>
|
||
</div></details><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.AllowTrailing.html" title="struct bincode::config::AllowTrailing">Allow<wbr>Trailing</a></div><div class="desc docblock-short">A TrailingBytes config that will allow trailing bytes in slices after deserialization.</div></li><li><div class="item-name"><a class="struct" href="struct.BigEndian.html" title="struct bincode::config::BigEndian">BigEndian</a></div><div class="desc docblock-short">Big-endian byte ordering.</div></li><li><div class="item-name"><a class="struct" href="struct.Bounded.html" title="struct bincode::config::Bounded">Bounded</a></div><div class="desc docblock-short">A SizeLimit that restricts serialized or deserialized messages from
|
||
exceeding a certain byte length.</div></li><li><div class="item-name"><a class="struct" href="struct.Config.html" title="struct bincode::config::Config">Config</a><wbr><span class="stab deprecated" title="">Deprecated</span></div><div class="desc docblock-short">A configuration builder whose options Bincode will use
|
||
while serializing and deserializing.</div></li><li><div class="item-name"><a class="struct" href="struct.DefaultOptions.html" title="struct bincode::config::DefaultOptions">Default<wbr>Options</a></div><div class="desc docblock-short">The default options for bincode serialization/deserialization.</div></li><li><div class="item-name"><a class="struct" href="struct.FixintEncoding.html" title="struct bincode::config::FixintEncoding">Fixint<wbr>Encoding</a></div><div class="desc docblock-short">Fixed-size integer encoding.</div></li><li><div class="item-name"><a class="struct" href="struct.Infinite.html" title="struct bincode::config::Infinite">Infinite</a></div><div class="desc docblock-short">A SizeLimit without a limit!
|
||
Use this if you don’t care about the size of encoded or decoded messages.</div></li><li><div class="item-name"><a class="struct" href="struct.LittleEndian.html" title="struct bincode::config::LittleEndian">Little<wbr>Endian</a></div><div class="desc docblock-short">Little-endian byte ordering.</div></li><li><div class="item-name"><a class="struct" href="struct.NativeEndian.html" title="struct bincode::config::NativeEndian">Native<wbr>Endian</a></div><div class="desc docblock-short">The native byte ordering of the current system.</div></li><li><div class="item-name"><a class="struct" href="struct.RejectTrailing.html" title="struct bincode::config::RejectTrailing">Reject<wbr>Trailing</a></div><div class="desc docblock-short">A TrailingBytes config that will cause bincode to produce an error if bytes are left over in the slice when deserialization is complete.</div></li><li><div class="item-name"><a class="struct" href="struct.VarintEncoding.html" title="struct bincode::config::VarintEncoding">Varint<wbr>Encoding</a></div><div class="desc docblock-short">Variable-size integer encoding (excepting [ui]8).</div></li><li><div class="item-name"><a class="struct" href="struct.WithOtherEndian.html" title="struct bincode::config::WithOtherEndian">With<wbr>Other<wbr>Endian</a></div><div class="desc docblock-short">A configuration struct with a user-specified endian order</div></li><li><div class="item-name"><a class="struct" href="struct.WithOtherIntEncoding.html" title="struct bincode::config::WithOtherIntEncoding">With<wbr>Other<wbr>IntEncoding</a></div><div class="desc docblock-short">A configuration struct with a user-specified length encoding</div></li><li><div class="item-name"><a class="struct" href="struct.WithOtherLimit.html" title="struct bincode::config::WithOtherLimit">With<wbr>Other<wbr>Limit</a></div><div class="desc docblock-short">A configuration struct with a user-specified byte limit</div></li><li><div class="item-name"><a class="struct" href="struct.WithOtherTrailing.html" title="struct bincode::config::WithOtherTrailing">With<wbr>Other<wbr>Trailing</a></div><div class="desc docblock-short">A configuration struct with a user-specified trailing bytes behavior.</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.Options.html" title="trait bincode::config::Options">Options</a></div><div class="desc docblock-short">A configuration builder trait whose options Bincode will use
|
||
while serializing and deserializing.</div></li></ul></section></div></main></body></html> |