mirror of
https://github.com/NotAShelf/mpvrc.git
synced 2026-04-17 16:29:50 +00:00
21 lines
No EOL
10 KiB
HTML
21 lines
No EOL
10 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 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!"><title>bincode - 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="../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="../bincode/index.html">bincode</a><span class="version">1.3.3</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="#using-basic-functions" title="Using Basic Functions">Using Basic Functions</a></li><li><a href="#128bit-numbers" title="128bit numbers">128bit numbers</a></li></ul><h3><a href="#reexports">Crate Items</a></h3><ul class="block"><li><a href="#reexports" title="Re-exports">Re-exports</a></li><li><a href="#modules" title="Modules">Modules</a></li><li><a href="#structs" title="Structs">Structs</a></li><li><a href="#enums" title="Enums">Enums</a></li><li><a href="#functions" title="Functions">Functions</a></li><li><a href="#types" title="Type Aliases">Type Aliases</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>bincode</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/lib.rs.html#1-201">Source</a> </span></div><details class="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"><a class="doc-anchor" href="#using-basic-functions">§</a>Using Basic Functions</h4>
|
|
<div class="example-wrap edition"><a href="#" class="tooltip" title="This example runs with edition 2018">ⓘ</a><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>main() {
|
|
<span class="comment">// The object that we will serialize.
|
|
</span><span class="kw">let </span>target: <span class="prelude-ty">Option</span><String> = <span class="prelude-val">Some</span>(<span class="string">"hello world"</span>.to_string());
|
|
|
|
<span class="kw">let </span>encoded: Vec<u8> = bincode::serialize(<span class="kw-2">&</span>target).unwrap();
|
|
<span class="kw">let </span>decoded: <span class="prelude-ty">Option</span><String> = bincode::deserialize(<span class="kw-2">&</span>encoded[..]).unwrap();
|
|
<span class="macro">assert_eq!</span>(target, decoded);
|
|
}</code></pre></div>
|
|
<h4 id="128bit-numbers"><a class="doc-anchor" href="#128bit-numbers">§</a>128bit numbers</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="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.Config"><code>pub use config::<a class="struct" href="config/struct.Config.html" title="struct bincode::config::Config">Config</a>;</code></div><div class="desc docblock-short"><wbr><span class="stab deprecated" title="">Deprecated</span></div></li><li><div class="item-name" id="reexport.DefaultOptions"><code>pub use config::<a class="struct" href="config/struct.DefaultOptions.html" title="struct bincode::config::DefaultOptions">DefaultOptions</a>;</code></div></li><li><div class="item-name" id="reexport.Options"><code>pub use config::<a class="trait" href="config/trait.Options.html" title="trait bincode::config::Options">Options</a>;</code></div></li><li><div class="item-name" id="reexport.BincodeRead"><code>pub use de::read::<a class="trait" href="de/read/trait.BincodeRead.html" title="trait bincode::de::read::BincodeRead">BincodeRead</a>;</code></div></li><li><div class="item-name" id="reexport.Deserializer"><code>pub use de::<a class="struct" href="de/struct.Deserializer.html" title="struct bincode::de::Deserializer">Deserializer</a>;</code></div></li></ul><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="config/index.html" title="mod bincode::config">config</a></div><div class="desc docblock-short"><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:</div></li><li><div class="item-name"><a class="mod" href="de/index.html" title="mod bincode::de">de</a></div><div class="desc docblock-short">Deserialize bincode data to a Rust data structure.</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.Serializer.html" title="struct bincode::Serializer">Serializer</a></div><div class="desc docblock-short">An Serializer that encodes values directly into a Writer.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.ErrorKind.html" title="enum bincode::ErrorKind">Error<wbr>Kind</a></div><div class="desc docblock-short">The kind of error that can be produced during a serialization or deserialization.</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.config.html" title="fn bincode::config">config</a><wbr><span class="stab deprecated" title="">Deprecated</span></div><div class="desc docblock-short">Get a default configuration object.</div></li><li><div class="item-name"><a class="fn" href="fn.deserialize.html" title="fn bincode::deserialize">deserialize</a></div><div class="desc docblock-short">Deserializes a slice of bytes into an instance of <code>T</code> using the default configuration.</div></li><li><div class="item-name"><a class="fn" href="fn.deserialize_from.html" title="fn bincode::deserialize_from">deserialize_<wbr>from</a></div><div class="desc docblock-short">Deserializes an object directly from a <code>Read</code>er using the default configuration.</div></li><li><div class="item-name"><a class="fn" href="fn.deserialize_from_custom.html" title="fn bincode::deserialize_from_custom">deserialize_<wbr>from_<wbr>custom</a></div><div class="desc docblock-short">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.</div></li><li><div class="item-name"><a class="fn" href="fn.options.html" title="fn bincode::options">options</a></div><div class="desc docblock-short">Get a default configuration object.</div></li><li><div class="item-name"><a class="fn" href="fn.serialize.html" title="fn bincode::serialize">serialize</a></div><div class="desc docblock-short">Serializes a serializable object into a <code>Vec</code> of bytes using the default configuration.</div></li><li><div class="item-name"><a class="fn" href="fn.serialize_into.html" title="fn bincode::serialize_into">serialize_<wbr>into</a></div><div class="desc docblock-short">Serializes an object directly into a <code>Writer</code> using the default configuration.</div></li><li><div class="item-name"><a class="fn" href="fn.serialized_size.html" title="fn bincode::serialized_size">serialized_<wbr>size</a></div><div class="desc docblock-short">Returns the size that an object would be if serialized using Bincode with the default configuration.</div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.Error.html" title="type bincode::Error">Error</a></div><div class="desc docblock-short">An error that can be produced during (de)serializing.</div></li><li><div class="item-name"><a class="type" href="type.Result.html" title="type bincode::Result">Result</a></div><div class="desc docblock-short">The result of a serialization or deserialization operation.</div></li></ul></section></div></main></body></html> |