254 lines
60 KiB
HTML
254 lines
60 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="Extends `Write` with methods for writing numbers. (For `std::io`.)"><meta name="keywords" content="rust, rustlang, rust-lang, WriteBytesExt"><title>WriteBytesExt in byteorder - 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 trait"><!--[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">☰</div><a class="sidebar-logo" href="../byteorder/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.png" alt="logo"></div>
|
||
</a><h2 class="location">Trait WriteBytesExt</h2><div class="sidebar-elems"><div class="block items"><h3 class="sidebar-title"><a href="#provided-methods">Provided Methods</a></h3><div class="sidebar-links"><a href="#method.write_f32">write_f32</a><a href="#method.write_f64">write_f64</a><a href="#method.write_i128">write_i128</a><a href="#method.write_i16">write_i16</a><a href="#method.write_i24">write_i24</a><a href="#method.write_i32">write_i32</a><a href="#method.write_i48">write_i48</a><a href="#method.write_i64">write_i64</a><a href="#method.write_i8">write_i8</a><a href="#method.write_int">write_int</a><a href="#method.write_int128">write_int128</a><a href="#method.write_u128">write_u128</a><a href="#method.write_u16">write_u16</a><a href="#method.write_u24">write_u24</a><a href="#method.write_u32">write_u32</a><a href="#method.write_u48">write_u48</a><a href="#method.write_u64">write_u64</a><a href="#method.write_u8">write_u8</a><a href="#method.write_uint">write_uint</a><a href="#method.write_uint128">write_uint128</a></div><h3 class="sidebar-title"><a href="#implementors">Implementors</a></h3></div><h2 class="location">Other items in<br><a href="index.html">byteorder</a></h2><div id="sidebar-vars" data-name="WriteBytesExt" data-ty="trait" 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="../byteorder/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">Trait <a href="index.html">byteorder</a>::<wbr><a class="trait" href="#">WriteBytesExt</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">−</span>]</a></span><a class="srclink" href="../src/byteorder/io.rs.html#1073-1575" title="goto source code">[src]</a></span></h1><div class="docblock item-decl"><pre class="rust trait"><code>pub trait WriteBytesExt: <a class="trait" href="https://doc.rust-lang.org/1.59.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> {
|
||
<details class="rustdoc-toggle type-contents-toggle"><summary class="hideme"><span>Show 20 methods</span></summary> fn <a href="#method.write_u8" class="fnname">write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i8" class="fnname">write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u16" class="fnname">write_u16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i16" class="fnname">write_i16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u24" class="fnname">write_u24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i24" class="fnname">write_i24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u32" class="fnname">write_u32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i32" class="fnname">write_i32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u48" class="fnname">write_u48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i48" class="fnname">write_i48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u64" class="fnname">write_u64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i64" class="fnname">write_i64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_u128" class="fnname">write_u128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_i128" class="fnname">write_i128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_uint" class="fnname">write_uint</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_int" class="fnname">write_int</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_uint128" class="fnname">write_uint128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u128.html">u128</a>, <br> nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a><br> ) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_int128" class="fnname">write_int128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i128.html">i128</a>, <br> nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a><br> ) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_f32" class="fnname">write_f32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
<div class="item-spacer"></div> fn <a href="#method.write_f64" class="fnname">write_f64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>> { ... }
|
||
</details>}</code></pre></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Extends <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>Write</code></a> with methods for writing numbers. (For <code>std::io</code>.)</p>
|
||
<p>Most of the methods defined here have an unconstrained type parameter that
|
||
must be explicitly instantiated. Typically, it is instantiated with either
|
||
the <a href="enum.BigEndian.html"><code>BigEndian</code></a> or <a href="enum.LittleEndian.html"><code>LittleEndian</code></a> types defined in this crate.</p>
|
||
<h2 id="examples" class="section-header"><a href="#examples">Examples</a></h2>
|
||
<p>Write unsigned 16 bit big-endian integers to a <a href="https://doc.rust-lang.org/std/io/trait.Write.html"><code>Write</code></a>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="macro">vec!</span>[];
|
||
<span class="ident">wtr</span>.<span class="ident">write_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">517</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">768</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="macro">vec!</span>[<span class="number">2</span>, <span class="number">5</span>, <span class="number">3</span>, <span class="number">0</span>]);</code></pre></div>
|
||
</div></details><h2 id="provided-methods" class="small-section-header">Provided methods<a href="#provided-methods" class="anchor"></a></h2><div class="methods"><details class="rustdoc-toggle" open><summary><div id="method.write_u8" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1098-1100" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u8" class="fnname">write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 8 bit integer to the underlying writer.</p>
|
||
<p>Note that since this writes a single byte, no byte order conversions
|
||
are used. It is included for completeness.</p>
|
||
<h5 id="errors" class="section-header"><a href="#errors">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h5>
|
||
<p>Write unsigned 8 bit integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder::WriteBytesExt</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u8</span>(<span class="number">2</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u8</span>(<span class="number">5</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\x05"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i8" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1126-1128" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i8" class="fnname">write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 8 bit integer to the underlying writer.</p>
|
||
<p>Note that since this writes a single byte, no byte order conversions
|
||
are used. It is included for completeness.</p>
|
||
<h5 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h5>
|
||
<p>Write signed 8 bit integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder::WriteBytesExt</span>;
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i8</span>(<span class="number">2</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i8</span>(<span class="op">-</span><span class="number">5</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\xfb"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u16" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1151-1155" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u16" class="fnname">write_u16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 16 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h5>
|
||
<p>Write unsigned 16 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">517</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">768</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\x05\x03\x00"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i16" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1178-1182" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i16" class="fnname">write_i16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 16 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h5>
|
||
<p>Write signed 16 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">193</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="op">-</span><span class="number">132</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\xc1\xff\x7c"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u24" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1205-1209" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u24" class="fnname">write_u24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 24 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-4" class="section-header"><a href="#errors-4">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h5>
|
||
<p>Write unsigned 24 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">267</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">120111</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\x01\x0b\x01\xd5\x2f"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i24" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1232-1236" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i24" class="fnname">write_i24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 24 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-5" class="section-header"><a href="#errors-5">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h5>
|
||
<p>Write signed 24 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="op">-</span><span class="number">34253</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">120111</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\xff\x7a\x33\x01\xd5\x2f"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u32" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1259-1263" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u32" class="fnname">write_u32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 32 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-6" class="section-header"><a href="#errors-6">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h5>
|
||
<p>Write unsigned 32 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">267</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">1205419366</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\x00\x01\x0b\x47\xd9\x3d\x66"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i32" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1286-1290" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i32" class="fnname">write_i32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 32 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-7" class="section-header"><a href="#errors-7">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h5>
|
||
<p>Write signed 32 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="op">-</span><span class="number">34253</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">1205419366</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\xff\xff\x7a\x33\x47\xd9\x3d\x66"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u48" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1313-1317" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u48" class="fnname">write_u48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 48 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-8" class="section-header"><a href="#errors-8">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h5>
|
||
<p>Write unsigned 48 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u48</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">52360336390828</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u48</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">541</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x2f\x9f\x17\x40\x3a\xac\x00\x00\x00\x00\x02\x1d"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i48" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1340-1344" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i48" class="fnname">write_i48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 48 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-9" class="section-header"><a href="#errors-9">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h5>
|
||
<p>Write signed 48 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i48</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="op">-</span><span class="number">108363435763825</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i48</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">77</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x9d\x71\xab\xe7\x97\x8f\x00\x00\x00\x00\x00\x4d"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u64" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1367-1371" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u64" class="fnname">write_u64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 64 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-10" class="section-header"><a href="#errors-10">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h5>
|
||
<p>Write unsigned 64 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">918733457491587</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_u64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">143</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\x03\x43\x95\x4d\x60\x86\x83\x00\x00\x00\x00\x00\x00\x00\x8f"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i64" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1394-1398" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i64" class="fnname">write_i64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 64 bit integer to the underlying writer.</p>
|
||
<h5 id="errors-11" class="section-header"><a href="#errors-11">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h5>
|
||
<p>Write signed 64 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="ident">i64::min_value</span>()).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_i64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="ident">i64::max_value</span>()).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x80\x00\x00\x00\x00\x00\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_u128" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1402-1406" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_u128" class="fnname">write_u128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned 128 bit integer to the underlying writer.</p>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_i128" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1410-1414" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_i128" class="fnname">write_i128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed 128 bit integer to the underlying writer.</p>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_uint" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1442-1450" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_uint" class="fnname">write_uint</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned n-bytes integer to the underlying writer.</p>
|
||
<h5 id="errors-12" class="section-header"><a href="#errors-12">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="panics" class="section-header"><a href="#panics">Panics</a></h5>
|
||
<p>If the given integer is not representable in the given number of bytes,
|
||
this method panics. If <code>nbytes > 8</code>, this method panics.</p>
|
||
<h5 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h5>
|
||
<p>Write unsigned 40 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_uint</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">312550384361</span>, <span class="number">5</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_uint</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">43</span>, <span class="number">5</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x48\xc5\x74\x62\xe9\x00\x00\x00\x00\x2b"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_int" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1478-1486" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_int" class="fnname">write_int</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed n-bytes integer to the underlying writer.</p>
|
||
<h5 id="errors-13" class="section-header"><a href="#errors-13">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h5>
|
||
<p>If the given integer is not representable in the given number of bytes,
|
||
this method panics. If <code>nbytes > 8</code>, this method panics.</p>
|
||
<h5 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h5>
|
||
<p>Write signed 56 bit big-endian integers to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_int</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="op">-</span><span class="number">3548172039376767</span>, <span class="number">7</span>).<span class="ident">unwrap</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_int</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">43</span>, <span class="number">7</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\xf3\x64\xf4\xd1\xfd\xb0\x81\x00\x00\x00\x00\x00\x00\x2b"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_uint128" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1493-1501" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_uint128" class="fnname">write_uint128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.u128.html">u128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes an unsigned n-bytes integer to the underlying writer.</p>
|
||
<p>If the given integer is not representable in the given number of bytes,
|
||
this method panics. If <code>nbytes > 16</code>, this method panics.</p>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_int128" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1508-1516" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_int128" class="fnname">write_int128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.i128.html">i128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a signed n-bytes integer to the underlying writer.</p>
|
||
<p>If the given integer is not representable in the given number of bytes,
|
||
this method panics. If <code>nbytes > 16</code>, this method panics.</p>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_f32" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1541-1545" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_f32" class="fnname">write_f32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a IEEE754 single-precision (4 bytes) floating point number to
|
||
the underlying writer.</p>
|
||
<h5 id="errors-14" class="section-header"><a href="#errors-14">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h5>
|
||
<p>Write a big-endian single-precision floating point number to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">std::f32</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_f32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="ident">f32::consts::PI</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x40\x49\x0f\xdb"</span>);</code></pre></div>
|
||
</div></details><details class="rustdoc-toggle" open><summary><div id="method.write_f64" class="method has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1570-1574" title="goto source code">[src]</a></div><h4 class="code-header">fn <a href="#method.write_f64" class="fnname">write_f64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.59.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.59.0/std/primitive.unit.html">()</a>></h4></div></summary><div class="docblock"><p>Writes a IEEE754 double-precision (8 bytes) floating point number to
|
||
the underlying writer.</p>
|
||
<h5 id="errors-15" class="section-header"><a href="#errors-15">Errors</a></h5>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Write.html#method.write_all"><code>Write::write_all</code></a>.</p>
|
||
<h5 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h5>
|
||
<p>Write a big-endian double-precision floating point number to a <code>Write</code>:</p>
|
||
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use</span> <span class="ident">std::f64</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">WriteBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">wtr</span> <span class="op">=</span> <span class="ident">Vec::new</span>();
|
||
<span class="ident">wtr</span>.<span class="ident">write_f64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="ident">f64::consts::PI</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq!</span>(<span class="ident">wtr</span>, <span class="string">b"\x40\x09\x21\xfb\x54\x44\x2d\x18"</span>);</code></pre></div>
|
||
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"><div id="impl-WriteBytesExt" class="impl has-srclink"><div class="rightside"><a class="srclink" href="../src/byteorder/io.rs.html#1579" title="goto source code">[src]</a></div><a href="#impl-WriteBytesExt" class="anchor"></a><h3 class="code-header in-band">impl<W: <a class="trait" href="https://doc.rust-lang.org/1.59.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.59.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.WriteBytesExt.html" title="trait byteorder::WriteBytesExt">WriteBytesExt</a> for W</h3></div><div class="docblock"><p>All types that implement <code>Write</code> get methods defined in <code>WriteBytesExt</code>
|
||
for free.</p>
|
||
</div></div><script type="text/javascript" src="../implementors/byteorder/trait.WriteBytesExt.js" async></script></section><section id="search" class="content hidden"></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="byteorder" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.59.0 (9d1b2106e 2022-02-23)" ></div>
|
||
</body></html> |