260 lines
50 KiB
HTML
260 lines
50 KiB
HTML
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Extends `Write` with methods for writing numbers. (For `std::io`.)"><title>WriteBytesExt in byteorder - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-42caa33d.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="byteorder" data-themes="" data-resource-suffix="" data-rustdoc-version="1.84.0 (9fc6b4312 2025-01-07)" data-channel="1.84.0" data-search-js="search-92e6798f.js" data-settings-js="settings-0f613d39.js" ><script src="../static.files/storage-59e33391.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-5f194d8c.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-893ab5e7.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-6580c154.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.svg"></head><body class="rustdoc 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" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../byteorder/index.html">byteorder</a><span class="version">1.5.0</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Write<wbr>Bytes<wbr>Ext</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#examples" title="Examples">Examples</a></li></ul><h3><a href="#provided-methods">Provided Methods</a></h3><ul class="block"><li><a href="#method.write_f32" title="write_f32">write_f32</a></li><li><a href="#method.write_f64" title="write_f64">write_f64</a></li><li><a href="#method.write_i128" title="write_i128">write_i128</a></li><li><a href="#method.write_i16" title="write_i16">write_i16</a></li><li><a href="#method.write_i24" title="write_i24">write_i24</a></li><li><a href="#method.write_i32" title="write_i32">write_i32</a></li><li><a href="#method.write_i48" title="write_i48">write_i48</a></li><li><a href="#method.write_i64" title="write_i64">write_i64</a></li><li><a href="#method.write_i8" title="write_i8">write_i8</a></li><li><a href="#method.write_int" title="write_int">write_int</a></li><li><a href="#method.write_int128" title="write_int128">write_int128</a></li><li><a href="#method.write_u128" title="write_u128">write_u128</a></li><li><a href="#method.write_u16" title="write_u16">write_u16</a></li><li><a href="#method.write_u24" title="write_u24">write_u24</a></li><li><a href="#method.write_u32" title="write_u32">write_u32</a></li><li><a href="#method.write_u48" title="write_u48">write_u48</a></li><li><a href="#method.write_u64" title="write_u64">write_u64</a></li><li><a href="#method.write_u8" title="write_u8">write_u8</a></li><li><a href="#method.write_uint" title="write_uint">write_uint</a></li><li><a href="#method.write_uint128" title="write_uint128">write_uint128</a></li></ul><h3><a href="#dyn-compatibility">Dyn Compatibility</a></h3><h3><a href="#implementors">Implementors</a></h3></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate byteorder</a></h2></div></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><span class="rustdoc-breadcrumbs"><a href="index.html">byteorder</a></span><h1>Trait <span class="trait">WriteBytesExt</span><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/byteorder/io.rs.html#1073-1575">Source</a> </span></div><pre class="rust item-decl"><code>pub trait WriteBytesExt: <a class="trait" href="https://doc.rust-lang.org/1.84.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> {
|
|
<details class="toggle type-contents-toggle"><summary class="hideme"><span>Show 20 methods</span></summary> // Provided methods
|
|
fn <a href="#method.write_u8" class="fn">write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i8" class="fn">write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u16" class="fn">write_u16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i16" class="fn">write_i16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u24" class="fn">write_u24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i24" class="fn">write_i24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u32" class="fn">write_u32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i32" class="fn">write_i32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u48" class="fn">write_u48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i48" class="fn">write_i48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u64" class="fn">write_u64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i64" class="fn">write_i64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_u128" class="fn">write_u128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_i128" class="fn">write_i128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_uint" class="fn">write_uint</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_int" class="fn">write_int</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_uint128" class="fn">write_uint128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(
|
|
&mut self,
|
|
n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u128.html">u128</a>,
|
|
nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>,
|
|
) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_int128" class="fn">write_int128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(
|
|
&mut self,
|
|
n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i128.html">i128</a>,
|
|
nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>,
|
|
) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_f32" class="fn">write_f32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
<span class="item-spacer"></span> fn <a href="#method.write_f64" class="fn">write_f64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>> { ... }
|
|
</details>}</code></pre><details class="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 class="doc-anchor" href="#examples">§</a>Examples</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::<BigEndian>(<span class="number">517</span>).unwrap();
|
|
wtr.write_u16::<BigEndian>(<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="section-header">Provided Methods<a href="#provided-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="method.write_u8" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1098-1100">Source</a><h4 class="code-header">fn <a href="#method.write_u8" class="fn">write_u8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u8.html">u8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 class="doc-anchor" href="#errors">§</a>Errors</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 class="doc-anchor" href="#examples-1">§</a>Examples</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"\x02\x05"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i8" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1126-1128">Source</a><h4 class="code-header">fn <a href="#method.write_i8" class="fn">write_i8</a>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i8.html">i8</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 class="doc-anchor" href="#errors-1">§</a>Errors</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 class="doc-anchor" href="#examples-2">§</a>Examples</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"\x02\xfb"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u16" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1151-1155">Source</a><h4 class="code-header">fn <a href="#method.write_u16" class="fn">write_u16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u16.html">u16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 16 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-2"><a class="doc-anchor" href="#errors-2">§</a>Errors</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 class="doc-anchor" href="#examples-3">§</a>Examples</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::<BigEndian>(<span class="number">517</span>).unwrap();
|
|
wtr.write_u16::<BigEndian>(<span class="number">768</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x02\x05\x03\x00"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i16" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1178-1182">Source</a><h4 class="code-header">fn <a href="#method.write_i16" class="fn">write_i16</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i16.html">i16</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 16 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-3"><a class="doc-anchor" href="#errors-3">§</a>Errors</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 class="doc-anchor" href="#examples-4">§</a>Examples</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::<BigEndian>(<span class="number">193</span>).unwrap();
|
|
wtr.write_i16::<BigEndian>(-<span class="number">132</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x00\xc1\xff\x7c"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u24" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1205-1209">Source</a><h4 class="code-header">fn <a href="#method.write_u24" class="fn">write_u24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 24 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-4"><a class="doc-anchor" href="#errors-4">§</a>Errors</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 class="doc-anchor" href="#examples-5">§</a>Examples</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::<BigEndian>(<span class="number">267</span>).unwrap();
|
|
wtr.write_u24::<BigEndian>(<span class="number">120111</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x00\x01\x0b\x01\xd5\x2f"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i24" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1232-1236">Source</a><h4 class="code-header">fn <a href="#method.write_i24" class="fn">write_i24</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 24 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-5"><a class="doc-anchor" href="#errors-5">§</a>Errors</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 class="doc-anchor" href="#examples-6">§</a>Examples</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::<BigEndian>(-<span class="number">34253</span>).unwrap();
|
|
wtr.write_i24::<BigEndian>(<span class="number">120111</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\xff\x7a\x33\x01\xd5\x2f"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u32" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1259-1263">Source</a><h4 class="code-header">fn <a href="#method.write_u32" class="fn">write_u32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u32.html">u32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 32 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-6"><a class="doc-anchor" href="#errors-6">§</a>Errors</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 class="doc-anchor" href="#examples-7">§</a>Examples</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::<BigEndian>(<span class="number">267</span>).unwrap();
|
|
wtr.write_u32::<BigEndian>(<span class="number">1205419366</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x00\x00\x01\x0b\x47\xd9\x3d\x66"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i32" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1286-1290">Source</a><h4 class="code-header">fn <a href="#method.write_i32" class="fn">write_i32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i32.html">i32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 32 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-7"><a class="doc-anchor" href="#errors-7">§</a>Errors</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 class="doc-anchor" href="#examples-8">§</a>Examples</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::<BigEndian>(-<span class="number">34253</span>).unwrap();
|
|
wtr.write_i32::<BigEndian>(<span class="number">1205419366</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\xff\xff\x7a\x33\x47\xd9\x3d\x66"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u48" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1313-1317">Source</a><h4 class="code-header">fn <a href="#method.write_u48" class="fn">write_u48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 48 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-8"><a class="doc-anchor" href="#errors-8">§</a>Errors</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 class="doc-anchor" href="#examples-9">§</a>Examples</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::<BigEndian>(<span class="number">52360336390828</span>).unwrap();
|
|
wtr.write_u48::<BigEndian>(<span class="number">541</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x2f\x9f\x17\x40\x3a\xac\x00\x00\x00\x00\x02\x1d"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i48" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1340-1344">Source</a><h4 class="code-header">fn <a href="#method.write_i48" class="fn">write_i48</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 48 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-9"><a class="doc-anchor" href="#errors-9">§</a>Errors</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 class="doc-anchor" href="#examples-10">§</a>Examples</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::<BigEndian>(-<span class="number">108363435763825</span>).unwrap();
|
|
wtr.write_i48::<BigEndian>(<span class="number">77</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x9d\x71\xab\xe7\x97\x8f\x00\x00\x00\x00\x00\x4d"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u64" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1367-1371">Source</a><h4 class="code-header">fn <a href="#method.write_u64" class="fn">write_u64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 64 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-10"><a class="doc-anchor" href="#errors-10">§</a>Errors</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 class="doc-anchor" href="#examples-11">§</a>Examples</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::<BigEndian>(<span class="number">918733457491587</span>).unwrap();
|
|
wtr.write_u64::<BigEndian>(<span class="number">143</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x00\x03\x43\x95\x4d\x60\x86\x83\x00\x00\x00\x00\x00\x00\x00\x8f"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i64" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1394-1398">Source</a><h4 class="code-header">fn <a href="#method.write_i64" class="fn">write_i64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 64 bit integer to the underlying writer.</p>
|
|
<h5 id="errors-11"><a class="doc-anchor" href="#errors-11">§</a>Errors</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 class="doc-anchor" href="#examples-12">§</a>Examples</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::<BigEndian>(i64::min_value()).unwrap();
|
|
wtr.write_i64::<BigEndian>(i64::max_value()).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x80\x00\x00\x00\x00\x00\x00\x00\x7f\xff\xff\xff\xff\xff\xff\xff"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_u128" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1402-1406">Source</a><h4 class="code-header">fn <a href="#method.write_u128" class="fn">write_u128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u128.html">u128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned 128 bit integer to the underlying writer.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_i128" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1410-1414">Source</a><h4 class="code-header">fn <a href="#method.write_i128" class="fn">write_i128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i128.html">i128</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed 128 bit integer to the underlying writer.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_uint" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1442-1450">Source</a><h4 class="code-header">fn <a href="#method.write_uint" class="fn">write_uint</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes an unsigned n-bytes integer to the underlying writer.</p>
|
|
<h5 id="errors-12"><a class="doc-anchor" href="#errors-12">§</a>Errors</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 class="doc-anchor" href="#panics">§</a>Panics</h5>
|
|
<p>If the given integer is not representable in the given number of bytes,
|
|
this method panics. If <code>nbytes > 8</code>, this method panics.</p>
|
|
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</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::<BigEndian>(<span class="number">312550384361</span>, <span class="number">5</span>).unwrap();
|
|
wtr.write_uint::<BigEndian>(<span class="number">43</span>, <span class="number">5</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x48\xc5\x74\x62\xe9\x00\x00\x00\x00\x2b"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_int" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1478-1486">Source</a><h4 class="code-header">fn <a href="#method.write_int" class="fn">write_int</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></h4></section></summary><div class="docblock"><p>Writes a signed n-bytes integer to the underlying writer.</p>
|
|
<h5 id="errors-13"><a class="doc-anchor" href="#errors-13">§</a>Errors</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 class="doc-anchor" href="#panics-1">§</a>Panics</h5>
|
|
<p>If the given integer is not representable in the given number of bytes,
|
|
this method panics. If <code>nbytes > 8</code>, this method panics.</p>
|
|
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</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::<BigEndian>(-<span class="number">3548172039376767</span>, <span class="number">7</span>).unwrap();
|
|
wtr.write_int::<BigEndian>(<span class="number">43</span>, <span class="number">7</span>).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\xf3\x64\xf4\xd1\xfd\xb0\x81\x00\x00\x00\x00\x00\x00\x2b"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_uint128" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1493-1501">Source</a><h4 class="code-header">fn <a href="#method.write_uint128" class="fn">write_uint128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.u128.html">u128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 > 16</code>, this method panics.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_int128" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1508-1516">Source</a><h4 class="code-header">fn <a href="#method.write_int128" class="fn">write_int128</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.i128.html">i128</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.usize.html">usize</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 > 16</code>, this method panics.</p>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_f32" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1541-1545">Source</a><h4 class="code-header">fn <a href="#method.write_f32" class="fn">write_f32</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f32.html">f32</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 class="doc-anchor" href="#errors-14">§</a>Errors</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 class="doc-anchor" href="#examples-15">§</a>Examples</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::<BigEndian>(f32::consts::PI).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x40\x49\x0f\xdb"</span>);</code></pre></div>
|
|
</div></details><details class="toggle method-toggle" open><summary><section id="method.write_f64" class="method"><a class="src rightside" href="../src/byteorder/io.rs.html#1570-1574">Source</a><h4 class="code-header">fn <a href="#method.write_f64" class="fn">write_f64</a><T: <a class="trait" href="trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, n: <a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.f64.html">f64</a>) -> <a class="type" href="https://doc.rust-lang.org/1.84.0/std/io/error/type.Result.html" title="type std::io::error::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/1.84.0/std/primitive.unit.html">()</a>></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 class="doc-anchor" href="#errors-15">§</a>Errors</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 class="doc-anchor" href="#examples-16">§</a>Examples</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::<BigEndian>(f64::consts::PI).unwrap();
|
|
<span class="macro">assert_eq!</span>(wtr, <span class="string">b"\x40\x09\x21\xfb\x54\x44\x2d\x18"</span>);</code></pre></div>
|
|
</div></details></div><h2 id="dyn-compatibility" class="section-header">Dyn Compatibility<a href="#dyn-compatibility" class="anchor">§</a></h2><div class="dyn-compatibility-info"><p>This trait is <b>not</b> <a href="https://doc.rust-lang.org/1.84.0/reference/items/traits.html#object-safety">dyn compatible</a>.</p><p><i>In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.</i></p></div><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"><section id="impl-WriteBytesExt-for-W" class="impl"><a class="src rightside" href="../src/byteorder/io.rs.html#1579">Source</a><a href="#impl-WriteBytesExt-for-W" class="anchor">§</a><h3 class="code-header">impl<W: <a class="trait" href="https://doc.rust-lang.org/1.84.0/std/io/trait.Write.html" title="trait std::io::Write">Write</a> + ?<a class="trait" href="https://doc.rust-lang.org/1.84.0/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> <a class="trait" href="trait.WriteBytesExt.html" title="trait byteorder::WriteBytesExt">WriteBytesExt</a> for W</h3></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="../trait.impl/byteorder/io/trait.WriteBytesExt.js" async></script></section></div></main></body></html> |