blob: df2b2089963976fff169169207969f66116090c3 [file] [log] [blame]
<!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" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="sidebar-items.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="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../byteorder/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../byteorder/index.html"><div class="logo-container"><img class="rust-logo" src="../rust-logo.svg" alt="logo"></div></a><h2 class="location"><a href="#">WriteBytesExt</a></h2><div class="sidebar-elems"><section><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.write_f32">write_f32</a></li><li><a href="#method.write_f64">write_f64</a></li><li><a href="#method.write_i128">write_i128</a></li><li><a href="#method.write_i16">write_i16</a></li><li><a href="#method.write_i24">write_i24</a></li><li><a href="#method.write_i32">write_i32</a></li><li><a href="#method.write_i48">write_i48</a></li><li><a href="#method.write_i64">write_i64</a></li><li><a href="#method.write_i8">write_i8</a></li><li><a href="#method.write_int">write_int</a></li><li><a href="#method.write_int128">write_int128</a></li><li><a href="#method.write_u128">write_u128</a></li><li><a href="#method.write_u16">write_u16</a></li><li><a href="#method.write_u24">write_u24</a></li><li><a href="#method.write_u32">write_u32</a></li><li><a href="#method.write_u48">write_u48</a></li><li><a href="#method.write_u64">write_u64</a></li><li><a href="#method.write_u8">write_u8</a></li><li><a href="#method.write_uint">write_uint</a></li><li><a href="#method.write_uint128">write_uint128</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In byteorder</a></h2></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">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></h1><span class="out-of-band"><a class="srclink" href="../src/byteorder/io.rs.html#1073-1575">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><div class="item-decl"><pre class="rust trait"><code>pub trait WriteBytesExt: Write {
<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>(&amp;mut self, n: u8) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i8" class="fnname">write_i8</a>(&amp;mut self, n: i8) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u16" class="fnname">write_u16</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u16) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i16" class="fnname">write_i16</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i16) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u24" class="fnname">write_u24</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u32) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i24" class="fnname">write_i24</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i32) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u32" class="fnname">write_u32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u32) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i32" class="fnname">write_i32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i32) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u48" class="fnname">write_u48</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i48" class="fnname">write_i48</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u64" class="fnname">write_u64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i64" class="fnname">write_i64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_u128" class="fnname">write_u128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u128) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_i128" class="fnname">write_i128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i128) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_uint" class="fnname">write_uint</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64, nbytes: usize) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_int" class="fnname">write_int</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64, nbytes: usize) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_uint128" class="fnname">write_uint128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;n: u128,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;nbytes: usize<br>&nbsp;&nbsp;&nbsp;&nbsp;) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_int128" class="fnname">write_int128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i128, nbytes: usize) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_f32" class="fnname">write_f32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: f32) -&gt; Result&lt;()&gt; { ... }
<span class="item-spacer"></span> fn <a href="#method.write_f64" class="fnname">write_f64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: f64) -&gt; Result&lt;()&gt; { ... }
</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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = <span class="macro">vec!</span>[];
wtr.write_u16::&lt;BigEndian&gt;(<span class="number">517</span>).unwrap();
wtr.write_u16::&lt;BigEndian&gt;(<span class="number">768</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <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 method-toggle" open><summary><section id="method.write_u8" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1098-1100">source</a><h4 class="code-header">fn <a href="#method.write_u8" class="fnname">write_u8</a>(&amp;mut self, n: u8) -&gt; Result&lt;()&gt;</h4></section></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"><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"><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>byteorder::WriteBytesExt;
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u8(<span class="number">2</span>).unwrap();
wtr.write_u8(<span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x02\x05&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i8" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1126-1128">source</a><h4 class="code-header">fn <a href="#method.write_i8" class="fnname">write_i8</a>(&amp;mut self, n: i8) -&gt; Result&lt;()&gt;</h4></section></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"><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"><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>byteorder::WriteBytesExt;
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i8(<span class="number">2</span>).unwrap();
wtr.write_i8(-<span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x02\xfb&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u16" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1151-1155">source</a><h4 class="code-header">fn <a href="#method.write_u16" class="fnname">write_u16</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u16) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 16 bit integer to the underlying writer.</p>
<h5 id="errors-2"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u16::&lt;BigEndian&gt;(<span class="number">517</span>).unwrap();
wtr.write_u16::&lt;BigEndian&gt;(<span class="number">768</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x02\x05\x03\x00&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i16" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1178-1182">source</a><h4 class="code-header">fn <a href="#method.write_i16" class="fnname">write_i16</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i16) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 16 bit integer to the underlying writer.</p>
<h5 id="errors-3"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i16::&lt;BigEndian&gt;(<span class="number">193</span>).unwrap();
wtr.write_i16::&lt;BigEndian&gt;(-<span class="number">132</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x00\xc1\xff\x7c&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u24" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1205-1209">source</a><h4 class="code-header">fn <a href="#method.write_u24" class="fnname">write_u24</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u32) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 24 bit integer to the underlying writer.</p>
<h5 id="errors-4"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u24::&lt;BigEndian&gt;(<span class="number">267</span>).unwrap();
wtr.write_u24::&lt;BigEndian&gt;(<span class="number">120111</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x00\x01\x0b\x01\xd5\x2f&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i24" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1232-1236">source</a><h4 class="code-header">fn <a href="#method.write_i24" class="fnname">write_i24</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i32) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 24 bit integer to the underlying writer.</p>
<h5 id="errors-5"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i24::&lt;BigEndian&gt;(-<span class="number">34253</span>).unwrap();
wtr.write_i24::&lt;BigEndian&gt;(<span class="number">120111</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\xff\x7a\x33\x01\xd5\x2f&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u32" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1259-1263">source</a><h4 class="code-header">fn <a href="#method.write_u32" class="fnname">write_u32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u32) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 32 bit integer to the underlying writer.</p>
<h5 id="errors-6"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u32::&lt;BigEndian&gt;(<span class="number">267</span>).unwrap();
wtr.write_u32::&lt;BigEndian&gt;(<span class="number">1205419366</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x00\x00\x01\x0b\x47\xd9\x3d\x66&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i32" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1286-1290">source</a><h4 class="code-header">fn <a href="#method.write_i32" class="fnname">write_i32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i32) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 32 bit integer to the underlying writer.</p>
<h5 id="errors-7"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i32::&lt;BigEndian&gt;(-<span class="number">34253</span>).unwrap();
wtr.write_i32::&lt;BigEndian&gt;(<span class="number">1205419366</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\xff\xff\x7a\x33\x47\xd9\x3d\x66&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u48" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1313-1317">source</a><h4 class="code-header">fn <a href="#method.write_u48" class="fnname">write_u48</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 48 bit integer to the underlying writer.</p>
<h5 id="errors-8"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u48::&lt;BigEndian&gt;(<span class="number">52360336390828</span>).unwrap();
wtr.write_u48::&lt;BigEndian&gt;(<span class="number">541</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x2f\x9f\x17\x40\x3a\xac\x00\x00\x00\x00\x02\x1d&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i48" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1340-1344">source</a><h4 class="code-header">fn <a href="#method.write_i48" class="fnname">write_i48</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 48 bit integer to the underlying writer.</p>
<h5 id="errors-9"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i48::&lt;BigEndian&gt;(-<span class="number">108363435763825</span>).unwrap();
wtr.write_i48::&lt;BigEndian&gt;(<span class="number">77</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x9d\x71\xab\xe7\x97\x8f\x00\x00\x00\x00\x00\x4d&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u64" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1367-1371">source</a><h4 class="code-header">fn <a href="#method.write_u64" class="fnname">write_u64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 64 bit integer to the underlying writer.</p>
<h5 id="errors-10"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_u64::&lt;BigEndian&gt;(<span class="number">918733457491587</span>).unwrap();
wtr.write_u64::&lt;BigEndian&gt;(<span class="number">143</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x00\x03\x43\x95\x4d\x60\x86\x83\x00\x00\x00\x00\x00\x00\x00\x8f&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i64" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1394-1398">source</a><h4 class="code-header">fn <a href="#method.write_i64" class="fnname">write_i64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 64 bit integer to the underlying writer.</p>
<h5 id="errors-11"><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"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_i64::&lt;BigEndian&gt;(i64::min_value()).unwrap();
wtr.write_i64::&lt;BigEndian&gt;(i64::max_value()).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x80\x00\x00\x00\x00\x00\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_u128" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1402-1406">source</a><h4 class="code-header">fn <a href="#method.write_u128" class="fnname">write_u128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u128) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned 128 bit integer to the underlying writer.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_i128" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1410-1414">source</a><h4 class="code-header">fn <a href="#method.write_i128" class="fnname">write_i128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i128) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed 128 bit integer to the underlying writer.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_uint" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1442-1450">source</a><h4 class="code-header">fn <a href="#method.write_uint" class="fnname">write_uint</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u64, nbytes: usize) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes an unsigned n-bytes integer to the underlying writer.</p>
<h5 id="errors-12"><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"><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 &gt; 8</code>, this method panics.</p>
<h5 id="examples-13"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_uint::&lt;BigEndian&gt;(<span class="number">312550384361</span>, <span class="number">5</span>).unwrap();
wtr.write_uint::&lt;BigEndian&gt;(<span class="number">43</span>, <span class="number">5</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x48\xc5\x74\x62\xe9\x00\x00\x00\x00\x2b&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_int" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1478-1486">source</a><h4 class="code-header">fn <a href="#method.write_int" class="fnname">write_int</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i64, nbytes: usize) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a signed n-bytes integer to the underlying writer.</p>
<h5 id="errors-13"><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"><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 &gt; 8</code>, this method panics.</p>
<h5 id="examples-14"><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>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_int::&lt;BigEndian&gt;(-<span class="number">3548172039376767</span>, <span class="number">7</span>).unwrap();
wtr.write_int::&lt;BigEndian&gt;(<span class="number">43</span>, <span class="number">7</span>).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\xf3\x64\xf4\xd1\xfd\xb0\x81\x00\x00\x00\x00\x00\x00\x2b&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_uint128" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1493-1501">source</a><h4 class="code-header">fn <a href="#method.write_uint128" class="fnname">write_uint128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: u128, nbytes: usize) -&gt; Result&lt;()&gt;</h4></section></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 &gt; 16</code>, this method panics.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_int128" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1508-1516">source</a><h4 class="code-header">fn <a href="#method.write_int128" class="fnname">write_int128</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: i128, nbytes: usize) -&gt; Result&lt;()&gt;</h4></section></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 &gt; 16</code>, this method panics.</p>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_f32" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1541-1545">source</a><h4 class="code-header">fn <a href="#method.write_f32" class="fnname">write_f32</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: f32) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a IEEE754 single-precision (4 bytes) floating point number to
the underlying writer.</p>
<h5 id="errors-14"><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"><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>std::f32;
<span class="kw">use </span>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_f32::&lt;BigEndian&gt;(f32::consts::PI).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x40\x49\x0f\xdb&quot;</span>);</code></pre></div>
</div></details><details class="rustdoc-toggle method-toggle" open><summary><section id="method.write_f64" class="method has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1570-1574">source</a><h4 class="code-header">fn <a href="#method.write_f64" class="fnname">write_f64</a>&lt;T:&nbsp;<a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>&gt;(&amp;mut self, n: f64) -&gt; Result&lt;()&gt;</h4></section></summary><div class="docblock"><p>Writes a IEEE754 double-precision (8 bytes) floating point number to
the underlying writer.</p>
<h5 id="errors-15"><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"><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>std::f64;
<span class="kw">use </span>byteorder::{BigEndian, WriteBytesExt};
<span class="kw">let </span><span class="kw-2">mut </span>wtr = Vec::new();
wtr.write_f64::&lt;BigEndian&gt;(f64::consts::PI).unwrap();
<span class="macro">assert_eq!</span>(wtr, <span class="string">b&quot;\x40\x09\x21\xfb\x54\x44\x2d\x18&quot;</span>);</code></pre></div>
</div></details></div><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div id="implementors-list"><section id="impl-WriteBytesExt-for-W" class="impl has-srclink"><a class="srclink rightside" href="../src/byteorder/io.rs.html#1579">source</a><a href="#impl-WriteBytesExt-for-W" class="anchor"></a><h3 class="code-header">impl&lt;W:&nbsp;Write + ?Sized&gt; <a class="trait" href="trait.WriteBytesExt.html" title="trait byteorder::WriteBytesExt">WriteBytesExt</a> for W</h3></section><div class="docblock"><p>All types that implement <code>Write</code> get methods defined in <code>WriteBytesExt</code>
for free.</p>
</div></div><script src="../implementors/byteorder/io/trait.WriteBytesExt.js" async></script></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.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>