This repository has been archived on 2022-04-04. You can view files and clone it, but cannot push or open issues or pull requests.

46 lines
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 is a crate for encoding and decoding using a tiny binary serialization strategy. Using it, you can easily go from having an object in memory, quickly serialize it to bytes, and then deserialize it back just as fast!"><meta name="keywords" content="rust, rustlang, rust-lang, bincode"><title>bincode - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../ayu.css" disabled><link rel="stylesheet" type="text/css" href="../dark.css" disabled><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script src="../crates.js"></script><script defer src="../main.js"></script>
<noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="alternate icon" type="image/png" href="../favicon-16x16.png"><link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><link rel="icon" type="image/svg+xml" href="../favicon.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="sidebar"><div class="sidebar-menu" role="button">&#9776;</div><a class="sidebar-logo" href="../bincode/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.png" alt="logo"></div>
</a><h2 class="location">Crate bincode</h2><div class="block version"><div class="narrow-helper"></div><p>Version 1.3.3</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all bincode's items</p></a><div class="block items"><ul><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></div><div id="sidebar-vars" data-name="bincode" data-ty="mod" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><main><div class="width-limiter"><div class="sub-container"><a class="sub-logo-container" href="../bincode/index.html"><img class="rust-logo" src="../rust-logo.png" alt="logo"></a><nav class="sub"><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu" title="themes"><img width="18" height="18" alt="Pick another theme!" src="../brush.svg"></button><div id="theme-choices" role="menu"></div></div><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" id="help-button" title="help">?</button><a id="settings-menu" href="../settings.html" title="settings"><img width="18" height="18" alt="Change settings" src="../wheel.svg"></a></div></form></nav></div><section id="main-content" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="#">bincode</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../src/bincode/lib.rs.html#1-201" title="goto source code">[src]</a></span></h1><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Bincode is a crate for encoding and decoding using a tiny binary
serialization strategy. Using it, you can easily go from having
an object in memory, quickly serialize it to bytes, and then
deserialize it back just as fast!</p>
<h4 id="using-basic-functions" class="section-header"><a href="#using-basic-functions">Using Basic Functions</a></h4>
<div class='information'><div class='tooltip edition' data-edition="2018"></div></div><div class="example-wrap"><pre class="rust rust-example-rendered edition"><code><span class="kw">fn</span> <span class="ident">main</span>() {
<span class="comment">// The object that we will serialize.</span>
<span class="kw">let</span> <span class="ident">target</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="prelude-val">Some</span>(<span class="string">&quot;hello world&quot;</span>.<span class="ident">to_string</span>());
<span class="kw">let</span> <span class="ident">encoded</span>: <span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">u8</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">bincode::serialize</span>(<span class="kw-2">&amp;</span><span class="ident">target</span>).<span class="ident">unwrap</span>();
<span class="kw">let</span> <span class="ident">decoded</span>: <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="ident">String</span><span class="op">&gt;</span> <span class="op">=</span> <span class="ident">bincode::deserialize</span>(<span class="kw-2">&amp;</span><span class="ident">encoded</span>[..]).<span class="ident">unwrap</span>();
<span class="macro">assert_eq!</span>(<span class="ident">target</span>, <span class="ident">decoded</span>);
}</code></pre></div>
<h4 id="128bit-numbers" class="section-header"><a href="#128bit-numbers">128bit numbers</a></h4>
<p>Support for <code>i128</code> and <code>u128</code> is automatically enabled on Rust toolchains
greater than or equal to <code>1.26.0</code> and disabled for targets which do not support it</p>
</div></details><h2 id="reexports" class="small-section-header"><a href="#reexports">Re-exports</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left import-item"><code>pub use config::<a class="struct" href="config/struct.DefaultOptions.html" title="struct bincode::config::DefaultOptions">DefaultOptions</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use config::<a class="trait" href="config/trait.Options.html" title="trait bincode::config::Options">Options</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use de::read::<a class="trait" href="de/read/trait.BincodeRead.html" title="trait bincode::de::read::BincodeRead">BincodeRead</a>;</code></div><div class="item-right docblock-short"></div></div><div class="item-row"><div class="item-left import-item"><code>pub use de::<a class="struct" href="de/struct.Deserializer.html" title="struct bincode::de::Deserializer">Deserializer</a>;</code></div><div class="item-right docblock-short"></div></div></div><h2 id="modules" class="small-section-header"><a href="#modules">Modules</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="mod" href="config/index.html" title="bincode::config mod">config</a></div><div class="item-right docblock-short"><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></div><div class="item-row"><div class="item-left module-item"><a class="mod" href="de/index.html" title="bincode::de mod">de</a></div><div class="item-right docblock-short"><p>Deserialize bincode data to a Rust data structure.</p>
</div></div></div><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Config.html" title="bincode::Config struct">Config</a><span class="stab deprecated" title="">Deprecated</span></div><div class="item-right docblock-short"><p>A configuration builder whose options Bincode will use
while serializing and deserializing.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Serializer.html" title="bincode::Serializer struct">Serializer</a></div><div class="item-right docblock-short"><p>An Serializer that encodes values directly into a Writer.</p>
</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.ErrorKind.html" title="bincode::ErrorKind enum">ErrorKind</a></div><div class="item-right docblock-short"><p>The kind of error that can be produced during a serialization or deserialization.</p>
</div></div></div><h2 id="functions" class="small-section-header"><a href="#functions">Functions</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.config.html" title="bincode::config fn">config</a><span class="stab deprecated" title="">Deprecated</span></div><div class="item-right docblock-short"><p>Get a default configuration object.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.deserialize.html" title="bincode::deserialize fn">deserialize</a></div><div class="item-right docblock-short"><p>Deserializes a slice of bytes into an instance of <code>T</code> using the default configuration.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.deserialize_from.html" title="bincode::deserialize_from fn">deserialize_from</a></div><div class="item-right docblock-short"><p>Deserializes an object directly from a <code>Read</code>er using the default configuration.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.deserialize_from_custom.html" title="bincode::deserialize_from_custom fn">deserialize_from_custom</a></div><div class="item-right docblock-short"><p>Deserializes an object from a custom <code>BincodeRead</code>er using the default configuration.
It is highly recommended to use <code>deserialize_from</code> unless you need to implement
<code>BincodeRead</code> for performance reasons.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.options.html" title="bincode::options fn">options</a></div><div class="item-right docblock-short"><p>Get a default configuration object.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.serialize.html" title="bincode::serialize fn">serialize</a></div><div class="item-right docblock-short"><p>Serializes a serializable object into a <code>Vec</code> of bytes using the default configuration.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.serialize_into.html" title="bincode::serialize_into fn">serialize_into</a></div><div class="item-right docblock-short"><p>Serializes an object directly into a <code>Writer</code> using the default configuration.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="fn" href="fn.serialized_size.html" title="bincode::serialized_size fn">serialized_size</a></div><div class="item-right docblock-short"><p>Returns the size that an object would be if serialized using Bincode with the default configuration.</p>
</div></div></div><h2 id="types" class="small-section-header"><a href="#types">Type Definitions</a></h2>
<div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="type" href="type.Error.html" title="bincode::Error type">Error</a></div><div class="item-right docblock-short"><p>An error that can be produced during (de)serializing.</p>
</div></div><div class="item-row"><div class="item-left module-item"><a class="type" href="type.Result.html" title="bincode::Result type">Result</a></div><div class="item-right docblock-short"><p>The result of a serialization or deserialization operation.</p>
</div></div></div></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="bincode" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.59.0 (9d1b2106e 2022-02-23)" ></div>
</body></html>