|
|
<!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="API documentation for the Rust `WriteBytesExt` trait in crate `byteorder`."><meta name="keywords" content="rust, rustlang, rust-lang, WriteBytesExt"><title>byteorder::WriteBytesExt - Rust</title><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="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../byteorder/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Trait WriteBytesExt</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#provided-methods">Provided Methods</a><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><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>byteorder</a></p><script>window.sidebarCurrent = {name: 'WriteBytesExt', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><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><a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class='fqn'><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#1083-1589' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='index.html'>byteorder</a>::<wbr><a class="trait" href=''>WriteBytesExt</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait WriteBytesExt: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> {
|
|
|
fn <a href='#method.write_u8' class='fnname'>write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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/nightly/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>, <br> nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br> ) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>, <br> nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a><br> ) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/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="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>> { ... }
|
|
|
}</pre></div><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>
|
|
|
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
|
|
|
<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">
|
|
|
<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="macro">!</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="macro">!</span>(<span class="ident">wtr</span>, <span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">5</span>, <span class="number">3</span>, <span class="number">0</span>]);</pre></div>
|
|
|
</div>
|
|
|
<h2 id='provided-methods' class='small-section-header'>Provided methods<a href='#provided-methods' class='anchor'></a></h2><div class='methods'><h3 id='method.write_u8' class='method'><code id='write_u8.v'>fn <a href='#method.write_u8' class='fnname'>write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><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>
|
|
|
<h1 id="errors" class="section-header"><a href="#errors">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
|
|
|
<p>Write unsigned 8 bit integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">byteorder</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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\x05"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_i8' class='method'><code id='write_i8.v'>fn <a href='#method.write_i8' class='fnname'>write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><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>
|
|
|
<h1 id="errors-1" class="section-header"><a href="#errors-1">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
|
|
|
<p>Write signed 8 bit integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<span class="kw">use</span> <span class="ident">byteorder</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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\xfb"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_u16' class='method'><code id='write_u16.v'>fn <a href='#method.write_u16' class='fnname'>write_u16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 16 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-2" class="section-header"><a href="#errors-2">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
|
|
|
<p>Write unsigned 16 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x02\x05\x03\x00"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_i16' class='method'><code id='write_i16.v'>fn <a href='#method.write_i16' class='fnname'>write_i16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 16 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-3" class="section-header"><a href="#errors-3">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
|
|
|
<p>Write signed 16 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\xc1\xff\x7c"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_u24' class='method'><code id='write_u24.v'>fn <a href='#method.write_u24' class='fnname'>write_u24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 24 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-4" class="section-header"><a href="#errors-4">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
|
|
|
<p>Write unsigned 24 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\x01\x0b\x01\xd5\x2f"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_i24' class='method'><code id='write_i24.v'>fn <a href='#method.write_i24' class='fnname'>write_i24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 24 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-5" class="section-header"><a href="#errors-5">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
|
|
|
<p>Write signed 24 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\xff\x7a\x33\x01\xd5\x2f"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_u32' class='method'><code id='write_u32.v'>fn <a href='#method.write_u32' class='fnname'>write_u32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 32 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-6" class="section-header"><a href="#errors-6">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
|
|
|
<p>Write unsigned 32 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x00\x00\x01\x0b\x47\xd9\x3d\x66"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_i32' class='method'><code id='write_i32.v'>fn <a href='#method.write_i32' class='fnname'>write_i32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 32 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-7" class="section-header"><a href="#errors-7">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
|
|
|
<p>Write signed 32 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\xff\xff\x7a\x33\x47\xd9\x3d\x66"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_u48' class='method'><code id='write_u48.v'>fn <a href='#method.write_u48' class='fnname'>write_u48</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 48 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-8" class="section-header"><a href="#errors-8">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
|
|
|
<p>Write unsigned 48 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x2f\x9f\x17\x40\x3a\xac\x00\x00\x00\x00\x02\x1d"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_i48' class='method'><code id='write_i48.v'>fn <a href='#method.write_i48' class='fnname'>write_i48</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 48 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-9" class="section-header"><a href="#errors-9">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
|
|
|
<p>Write signed 48 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x9d\x71\xab\xe7\x97\x8f\x00\x00\x00\x00\x00\x4d"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_u64' class='method'><code id='write_u64.v'>fn <a href='#method.write_u64' class='fnname'>write_u64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 64 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-10" class="section-header"><a href="#errors-10">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
|
|
|
<p>Write unsigned 64 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</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>);</pre></div>
|
|
|
</div><h3 id='method.write_i64' class='method'><code id='write_i64.v'>fn <a href='#method.write_i64' class='fnname'>write_i64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 64 bit integer to the underlying writer.</p>
|
|
|
<h1 id="errors-11" class="section-header"><a href="#errors-11">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
|
|
|
<p>Write signed 64 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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</span>::<span class="ident">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</span>::<span class="ident">max_value</span>()).<span class="ident">unwrap</span>();
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</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>);</pre></div>
|
|
|
</div><h3 id='method.write_u128' class='method'><code id='write_u128.v'>fn <a href='#method.write_u128' class='fnname'>write_u128</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned 128 bit integer to the underlying writer.</p>
|
|
|
</div><h3 id='method.write_i128' class='method'><code id='write_i128.v'>fn <a href='#method.write_i128' class='fnname'>write_i128</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed 128 bit integer to the underlying writer.</p>
|
|
|
</div><h3 id='method.write_uint' class='method'><code id='write_uint.v'>fn <a href='#method.write_uint' class='fnname'>write_uint</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes an unsigned n-bytes integer to the underlying writer.</p>
|
|
|
<h1 id="errors-12" class="section-header"><a href="#errors-12">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
|
|
|
<p>Write unsigned 40 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x48\xc5\x74\x62\xe9\x00\x00\x00\x00\x2b"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_int' class='method'><code id='write_int.v'>fn <a href='#method.write_int' class='fnname'>write_int</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a signed n-bytes integer to the underlying writer.</p>
|
|
|
<h1 id="errors-13" class="section-header"><a href="#errors-13">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
|
|
|
<p>Write signed 56 bit big-endian integers to a <code>Write</code>:</p>
|
|
|
|
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
|
|
<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</span>::<span class="ident">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="macro">!</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>);</pre></div>
|
|
|
</div><h3 id='method.write_uint128' class='method'><code id='write_uint128.v'>fn <a href='#method.write_uint128' class='fnname'>write_uint128</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u128.html">u128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><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><h3 id='method.write_int128' class='method'><code id='write_int128.v'>fn <a href='#method.write_int128' class='fnname'>write_int128</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i128.html">i128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><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><h3 id='method.write_f32' class='method'><code id='write_f32.v'>fn <a href='#method.write_f32' class='fnname'>write_f32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a IEEE754 single-precision (4 bytes) floating point number to
|
|
|
the underlying writer.</p>
|
|
|
<h1 id="errors-14" class="section-header"><a href="#errors-14">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
|
|
|
<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">
|
|
|
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">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</span>::<span class="ident">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</span>::<span class="ident">consts</span>::<span class="ident">PI</span>).<span class="ident">unwrap</span>();
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x40\x49\x0f\xdb"</span>);</pre></div>
|
|
|
</div><h3 id='method.write_f64' class='method'><code id='write_f64.v'>fn <a href='#method.write_f64' class='fnname'>write_f64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.unit.html">()</a>></code></h3><div class='docblock'><p>Writes a IEEE754 double-precision (8 bytes) floating point number to
|
|
|
the underlying writer.</p>
|
|
|
<h1 id="errors-15" class="section-header"><a href="#errors-15">Errors</a></h1>
|
|
|
<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>
|
|
|
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
|
|
|
<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">
|
|
|
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">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</span>::<span class="ident">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</span>::<span class="ident">consts</span>::<span class="ident">PI</span>).<span class="ident">unwrap</span>();
|
|
|
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">wtr</span>, <span class="string">b"\x40\x09\x21\xfb\x54\x44\x2d\x18"</span>);</pre></div>
|
|
|
</div></div><span class='loading-content'>Loading content...</span>
|
|
|
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'><h3 id='impl-WriteBytesExt' class='impl'><code class='in-band'>impl<W: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> WriteBytesExt for W</code><a href='#impl-WriteBytesExt' class='anchor'></a><a class='srclink' href='../src/byteorder/io.rs.html#1593' title='goto source code'>[src]</a></h3><div class='docblock'><p>All types that implement <code>Write</code> get methods defined in <code>WriteBytesExt</code>
|
|
|
for free.</p>
|
|
|
</div><div class='impl-items'></div></div><span class='loading-content'>Loading content...</span><script type="text/javascript">window.inlined_types=new Set([]);</script><script type="text/javascript" async
|
|
|
src="../implementors/byteorder/trait.WriteBytesExt.js">
|
|
|
</script></section><section id="search" class="content hidden"></section><section class="footer"></section><aside id="help" class="hidden"><div><h1 class="hidden">Help</h1><div class="shortcuts"><h2>Keyboard Shortcuts</h2><dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd><dt><kbd>↓</kbd></dt><dd>Move down in search results</dd><dt><kbd>↹</kbd></dt><dd>Switch tab</dd><dt><kbd>⏎</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse all sections</dd></dl></div><div class="infos"><h2>Search Tricks</h2><p>Prefix searches with a type followed by a colon (e.g., <code>fn:</code>) to restrict the search to a given type.</p><p>Accepted types are: <code>fn</code>, <code>mod</code>, <code>struct</code>, <code>enum</code>, <code>trait</code>, <code>type</code>, <code>macro</code>, and <code>const</code>.</p><p>Search functions by type signature (e.g., <code>vec -> usize</code> or <code>* -> vec</code>)</p><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "byteorder";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |