568 lines
73 KiB
HTML
568 lines
73 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="API documentation for the Rust `ReadBytesExt` trait in crate `byteorder`.">
|
||
<meta name="keywords" content="rust, rustlang, rust-lang, ReadBytesExt">
|
||
|
||
<title>byteorder::ReadBytesExt - Rust</title>
|
||
|
||
<link rel="stylesheet" type="text/css" href="../normalize.css">
|
||
<link rel="stylesheet" type="text/css" href="../rustdoc.css">
|
||
<link rel="stylesheet" type="text/css" href="../main.css">
|
||
|
||
|
||
|
||
|
||
</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">
|
||
|
||
<p class='location'>Trait ReadBytesExt</p><div class="block items"><ul><li><a href="#provided-methods">Provided Methods</a></li><li><a href="#implementors">Implementors</a></li></ul></div><p class='location'><a href='index.html'>byteorder</a></p><script>window.sidebarCurrent = {name: 'ReadBytesExt', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script>
|
||
</nav>
|
||
|
||
<nav class="sub">
|
||
<form class="search-form js-only">
|
||
<div class="search-container">
|
||
<input class="search-input" name="search"
|
||
autocomplete="off"
|
||
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
|
||
type="search">
|
||
</div>
|
||
</form>
|
||
</nav>
|
||
|
||
<section id='main' class="content">
|
||
<h1 class='fqn'><span class='in-band'>Trait <a href='index.html'>byteorder</a>::<wbr><a class="trait" href=''>ReadBytesExt</a></span><span class='out-of-band'><span id='render-detail'>
|
||
<a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">
|
||
[<span class='inner'>−</span>]
|
||
</a>
|
||
</span><a class='srclink' href='../src/byteorder/io.rs.html#25-887' title='goto source code'>[src]</a></span></h1>
|
||
<pre class='rust trait'>pub trait ReadBytesExt: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> {
|
||
fn <a href='#method.read_u8' class='fnname'>read_u8</a>(&mut self) -> <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.u8.html">u8</a>> { ... }
|
||
fn <a href='#method.read_i8' class='fnname'>read_i8</a>(&mut self) -> <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.i8.html">i8</a>> { ... }
|
||
fn <a href='#method.read_u16' class='fnname'>read_u16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u16.html">u16</a>> { ... }
|
||
fn <a href='#method.read_i16' class='fnname'>read_i16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i16.html">i16</a>> { ... }
|
||
fn <a href='#method.read_u24' class='fnname'>read_u24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u32.html">u32</a>> { ... }
|
||
fn <a href='#method.read_i24' class='fnname'>read_i24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i32.html">i32</a>> { ... }
|
||
fn <a href='#method.read_u32' class='fnname'>read_u32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u32.html">u32</a>> { ... }
|
||
fn <a href='#method.read_i32' class='fnname'>read_i32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i32.html">i32</a>> { ... }
|
||
fn <a href='#method.read_u64' class='fnname'>read_u64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u64.html">u64</a>> { ... }
|
||
fn <a href='#method.read_i64' class='fnname'>read_i64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i64.html">i64</a>> { ... }
|
||
fn <a href='#method.read_uint' class='fnname'>read_uint</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, 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.u64.html">u64</a>> { ... }
|
||
fn <a href='#method.read_int' class='fnname'>read_int</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, 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.i64.html">i64</a>> { ... }
|
||
fn <a href='#method.read_f32' class='fnname'>read_f32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.f32.html">f32</a>> { ... }
|
||
fn <a href='#method.read_f64' class='fnname'>read_f64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.f64.html">f64</a>> { ... }
|
||
fn <a href='#method.read_u16_into' class='fnname'>read_u16_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
fn <a href='#method.read_u32_into' class='fnname'>read_u32_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
fn <a href='#method.read_u64_into' class='fnname'>read_u64_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
fn <a href='#method.read_i16_into' class='fnname'>read_i16_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
fn <a href='#method.read_i32_into' class='fnname'>read_i32_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
fn <a href='#method.read_i64_into' class='fnname'>read_i64_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
unsafe fn <a href='#method.read_f32_into_unchecked' class='fnname'>read_f32_into_unchecked</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
unsafe fn <a href='#method.read_f64_into_unchecked' class='fnname'>read_f64_into_unchecked</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>> { ... }
|
||
}</pre><div class='docblock'><p>Extends <code>Read</code> with methods for reading 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 <code>BigEndian</code> or <code>LittleEndian</code> types defined in this crate.</p>
|
||
|
||
<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
|
||
<p>Read unsigned 16 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</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>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">517</span>, <span class="ident">rdr</span>.<span class="ident">read_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">768</span>, <span class="ident">rdr</span>.<span class="ident">read_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div>
|
||
<h2 id='provided-methods'>Provided Methods</h2>
|
||
<div class='methods'>
|
||
<h3 id='method.read_u8' class='method'><span id='read_u8.v' class='invisible'><code>fn <a href='#method.read_u8' class='fnname'>read_u8</a>(&mut self) -> <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.u8.html">u8</a>></code></span></h3><div class='docblock'><p>Reads an unsigned 8 bit integer from the underlying reader.</p>
|
||
|
||
<p>Note that since this reads 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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
|
||
<p>Read unsigned 8 bit integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">2</span>, <span class="number">5</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">2</span>, <span class="ident">rdr</span>.<span class="ident">read_u8</span>().<span class="ident">unwrap</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">5</span>, <span class="ident">rdr</span>.<span class="ident">read_u8</span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_i8' class='method'><span id='read_i8.v' class='invisible'><code>fn <a href='#method.read_i8' class='fnname'>read_i8</a>(&mut self) -> <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.i8.html">i8</a>></code></span></h3><div class='docblock'><p>Reads a signed 8 bit integer from the underlying reader.</p>
|
||
|
||
<p>Note that since this reads 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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
|
||
<p>Read unsigned 8 bit integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x02</span>, <span class="number">0xfb</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">2</span>, <span class="ident">rdr</span>.<span class="ident">read_i8</span>().<span class="ident">unwrap</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">5</span>, <span class="ident">rdr</span>.<span class="ident">read_i8</span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_u16' class='method'><span id='read_u16.v' class='invisible'><code>fn <a href='#method.read_u16' class='fnname'>read_u16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u16.html">u16</a>></code></span></h3><div class='docblock'><p>Reads an unsigned 16 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
|
||
<p>Read unsigned 16 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</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>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">517</span>, <span class="ident">rdr</span>.<span class="ident">read_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">768</span>, <span class="ident">rdr</span>.<span class="ident">read_u16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_i16' class='method'><span id='read_i16.v' class='invisible'><code>fn <a href='#method.read_i16' class='fnname'>read_i16</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i16.html">i16</a>></code></span></h3><div class='docblock'><p>Reads a signed 16 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
|
||
<p>Read signed 16 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x00</span>, <span class="number">0xc1</span>, <span class="number">0xff</span>, <span class="number">0x7c</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">193</span>, <span class="ident">rdr</span>.<span class="ident">read_i16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">132</span>, <span class="ident">rdr</span>.<span class="ident">read_i16</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_u24' class='method'><span id='read_u24.v' class='invisible'><code>fn <a href='#method.read_u24' class='fnname'>read_u24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u32.html">u32</a>></code></span></h3><div class='docblock'><p>Reads an unsigned 24 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1>
|
||
<p>Read unsigned 24 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x00</span>, <span class="number">0x01</span>, <span class="number">0x0b</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">267</span>, <span class="ident">rdr</span>.<span class="ident">read_u24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_i24' class='method'><span id='read_i24.v' class='invisible'><code>fn <a href='#method.read_i24' class='fnname'>read_i24</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i32.html">i32</a>></code></span></h3><div class='docblock'><p>Reads a signed 24 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1>
|
||
<p>Read signed 24 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0xff</span>, <span class="number">0x7a</span>, <span class="number">0x33</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">34253</span>, <span class="ident">rdr</span>.<span class="ident">read_i24</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_u32' class='method'><span id='read_u32.v' class='invisible'><code>fn <a href='#method.read_u32' class='fnname'>read_u32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u32.html">u32</a>></code></span></h3><div class='docblock'><p>Reads an unsigned 32 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1>
|
||
<p>Read unsigned 32 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x00</span>, <span class="number">0x00</span>, <span class="number">0x01</span>, <span class="number">0x0b</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">267</span>, <span class="ident">rdr</span>.<span class="ident">read_u32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_i32' class='method'><span id='read_i32.v' class='invisible'><code>fn <a href='#method.read_i32' class='fnname'>read_i32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i32.html">i32</a>></code></span></h3><div class='docblock'><p>Reads a signed 32 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1>
|
||
<p>Read signed 32 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0xff</span>, <span class="number">0xff</span>, <span class="number">0x7a</span>, <span class="number">0x33</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">34253</span>, <span class="ident">rdr</span>.<span class="ident">read_i32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_u64' class='method'><span id='read_u64.v' class='invisible'><code>fn <a href='#method.read_u64' class='fnname'>read_u64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.u64.html">u64</a>></code></span></h3><div class='docblock'><p>Reads an unsigned 64 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1>
|
||
<p>Read an unsigned 64 bit big-endian integer from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x00</span>, <span class="number">0x03</span>, <span class="number">0x43</span>, <span class="number">0x95</span>, <span class="number">0x4d</span>, <span class="number">0x60</span>, <span class="number">0x86</span>, <span class="number">0x83</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">918733457491587</span>, <span class="ident">rdr</span>.<span class="ident">read_u64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_i64' class='method'><span id='read_i64.v' class='invisible'><code>fn <a href='#method.read_i64' class='fnname'>read_i64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.i64.html">i64</a>></code></span></h3><div class='docblock'><p>Reads a signed 64 bit integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1>
|
||
<p>Read a signed 64 bit big-endian integer from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x80</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">i64</span>::<span class="ident">min_value</span>(), <span class="ident">rdr</span>.<span class="ident">read_i64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_uint' class='method'><span id='read_uint.v' class='invisible'><code>fn <a href='#method.read_uint' class='fnname'>read_uint</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, 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.u64.html">u64</a>></code></span></h3><div class='docblock'><p>Reads an unsigned n-bytes integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-11' class='section-header'><a href='#examples-11'>Examples</a></h1>
|
||
<p>Read an unsigned n-byte big-endian integer from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0x80</span>, <span class="number">0x74</span>, <span class="number">0xfa</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">8418554</span>, <span class="ident">rdr</span>.<span class="ident">read_uint</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">3</span>).<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_int' class='method'><span id='read_int.v' class='invisible'><code>fn <a href='#method.read_int' class='fnname'>read_int</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, 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.i64.html">i64</a>></code></span></h3><div class='docblock'><p>Reads a signed n-bytes integer from the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1>
|
||
<p>Read an unsigned n-byte big-endian integer from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0xc1</span>, <span class="number">0xff</span>, <span class="number">0x7c</span>]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">4063364</span>, <span class="ident">rdr</span>.<span class="ident">read_int</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="number">3</span>).<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_f32' class='method'><span id='read_f32.v' class='invisible'><code>fn <a href='#method.read_f32' class='fnname'>read_f32</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.f32.html">f32</a>></code></span></h3><div class='docblock'><p>Reads a IEEE754 single-precision (4 bytes) floating point number from
|
||
the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-13' class='section-header'><a href='#examples-13'>Examples</a></h1>
|
||
<p>Read a big-endian single-precision floating point number from a <code>Read</code>:</p>
|
||
|
||
<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">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0x40</span>, <span class="number">0x49</span>, <span class="number">0x0f</span>, <span class="number">0xdb</span>,
|
||
]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f32</span>::<span class="ident">consts</span>::<span class="ident">PI</span>, <span class="ident">rdr</span>.<span class="ident">read_f32</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_f64' class='method'><span id='read_f64.v' class='invisible'><code>fn <a href='#method.read_f64' class='fnname'>read_f64</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self) -> <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.f64.html">f64</a>></code></span></h3><div class='docblock'><p>Reads a IEEE754 double-precision (8 bytes) floating point number from
|
||
the underlying reader.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1>
|
||
<p>Read a big-endian double-precision floating point number from a <code>Read</code>:</p>
|
||
|
||
<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">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0x40</span>, <span class="number">0x09</span>, <span class="number">0x21</span>, <span class="number">0xfb</span>, <span class="number">0x54</span>, <span class="number">0x44</span>, <span class="number">0x2d</span>, <span class="number">0x18</span>,
|
||
]);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span>, <span class="ident">rdr</span>.<span class="ident">read_f64</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>().<span class="ident">unwrap</span>());</pre>
|
||
</div><h3 id='method.read_u16_into' class='method'><span id='read_u16_into.v' class='invisible'><code>fn <a href='#method.read_u16_into' class='fnname'>read_u16_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of unsigned 16 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-15' class='section-header'><a href='#examples-15'>Examples</a></h1>
|
||
<p>Read a sequence of unsigned 16 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</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>]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_u16_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_u32_into' class='method'><span id='read_u32_into.v' class='invisible'><code>fn <a href='#method.read_u32_into' class='fnname'>read_u32_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of unsigned 32 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</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.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1>
|
||
<p>Read a sequence of unsigned 32 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">0</span>]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_u32_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_u64_into' class='method'><span id='read_u64_into.v' class='invisible'><code>fn <a href='#method.read_u64_into' class='fnname'>read_u64_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of unsigned 64 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='errors-16' class='section-header'><a href='#errors-16'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-17' class='section-header'><a href='#examples-17'>Examples</a></h1>
|
||
<p>Read a sequence of unsigned 64 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="number">5</span>,
|
||
<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">0</span>,
|
||
]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_u64_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_i16_into' class='method'><span id='read_i16_into.v' class='invisible'><code>fn <a href='#method.read_i16_into' class='fnname'>read_i16_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of signed 16 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='errors-17' class='section-header'><a href='#errors-17'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-18' class='section-header'><a href='#examples-18'>Examples</a></h1>
|
||
<p>Read a sequence of signed 16 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</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>]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_i16_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_i32_into' class='method'><span id='read_i32_into.v' class='invisible'><code>fn <a href='#method.read_i32_into' class='fnname'>read_i32_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of signed 32 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='errors-18' class='section-header'><a href='#errors-18'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-19' class='section-header'><a href='#examples-19'>Examples</a></h1>
|
||
<p>Read a sequence of signed 32 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">0</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="number">5</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">0</span>]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_i32_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_i64_into' class='method'><span id='read_i64_into.v' class='invisible'><code>fn <a href='#method.read_i64_into' class='fnname'>read_i64_into</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(&mut self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of signed 64 bit integers from the underlying
|
||
reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='errors-19' class='section-header'><a href='#errors-19'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-20' class='section-header'><a href='#examples-20'>Examples</a></h1>
|
||
<p>Read a sequence of signed 64 bit big-endian integers from a <code>Read</code>:</p>
|
||
|
||
<pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">2</span>, <span class="number">5</span>,
|
||
<span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">0</span>, <span class="number">3</span>, <span class="number">0</span>,
|
||
]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
|
||
<span class="ident">rdr</span>.<span class="ident">read_i64_into</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="number">517</span>, <span class="number">768</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_f32_into_unchecked' class='method'><span id='read_f32_into_unchecked.v' class='invisible'><code>unsafe fn <a href='#method.read_f32_into_unchecked' class='fnname'>read_f32_into_unchecked</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of IEEE754 single-precision (4 bytes) floating
|
||
point numbers from the underlying reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='safety' class='section-header'><a href='#safety'>Safety</a></h1>
|
||
<p>This method is unsafe because there are no guarantees made about the
|
||
floating point values. In particular, this method does not check for
|
||
signaling NaNs, which may result in undefined behavior.</p>
|
||
|
||
<h1 id='errors-20' class='section-header'><a href='#errors-20'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-21' class='section-header'><a href='#examples-21'>Examples</a></h1>
|
||
<p>Read a sequence of big-endian single-precision floating point number
|
||
from a <code>Read</code>:</p>
|
||
|
||
<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">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0x40</span>, <span class="number">0x49</span>, <span class="number">0x0f</span>, <span class="number">0xdb</span>,
|
||
<span class="number">0x3f</span>, <span class="number">0x80</span>, <span class="number">0x00</span>, <span class="number">0x00</span>,
|
||
]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">2</span>];
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">rdr</span>.<span class="ident">read_f32_into_unchecked</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
}
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="ident">f32</span>::<span class="ident">consts</span>::<span class="ident">PI</span>, <span class="number">1.0</span>], <span class="ident">dst</span>);</pre>
|
||
</div><h3 id='method.read_f64_into_unchecked' class='method'><span id='read_f64_into_unchecked.v' class='invisible'><code>unsafe fn <a href='#method.read_f64_into_unchecked' class='fnname'>read_f64_into_unchecked</a><T: <a class="trait" href="../byteorder/trait.ByteOrder.html" title="trait byteorder::ByteOrder">ByteOrder</a>>(<br> &mut self, <br> dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</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.tuple.html">()</a>></code></span></h3><div class='docblock'><p>Reads a sequence of IEEE754 double-precision (8 bytes) floating
|
||
point numbers from the underlying reader.</p>
|
||
|
||
<p>The given buffer is either filled completely or an error is returned.
|
||
If an error is returned, the contents of <code>dst</code> are unspecified.</p>
|
||
|
||
<h1 id='safety-1' class='section-header'><a href='#safety-1'>Safety</a></h1>
|
||
<p>This method is unsafe because there are no guarantees made about the
|
||
floating point values. In particular, this method does not check for
|
||
signaling NaNs, which may result in undefined behavior.</p>
|
||
|
||
<h1 id='errors-21' class='section-header'><a href='#errors-21'>Errors</a></h1>
|
||
<p>This method returns the same errors as <a href="https://doc.rust-lang.org/std/io/trait.Read.html#method.read_exact"><code>Read::read_exact</code></a>.</p>
|
||
|
||
<h1 id='examples-22' class='section-header'><a href='#examples-22'>Examples</a></h1>
|
||
<p>Read a sequence of big-endian single-precision floating point number
|
||
from a <code>Read</code>:</p>
|
||
|
||
<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">std</span>::<span class="ident">io</span>::<span class="ident">Cursor</span>;
|
||
|
||
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">BigEndian</span>, <span class="ident">ReadBytesExt</span>};
|
||
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">rdr</span> <span class="op">=</span> <span class="ident">Cursor</span>::<span class="ident">new</span>(<span class="macro">vec</span><span class="macro">!</span>[
|
||
<span class="number">0x40</span>, <span class="number">0x09</span>, <span class="number">0x21</span>, <span class="number">0xfb</span>, <span class="number">0x54</span>, <span class="number">0x44</span>, <span class="number">0x2d</span>, <span class="number">0x18</span>,
|
||
<span class="number">0x3f</span>, <span class="number">0xF0</span>, <span class="number">0x00</span>, <span class="number">0x00</span>, <span class="number">0x00</span>, <span class="number">0x00</span>, <span class="number">0x00</span>, <span class="number">0x00</span>,
|
||
]);
|
||
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">dst</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">2</span>];
|
||
<span class="kw">unsafe</span> {
|
||
<span class="ident">rdr</span>.<span class="ident">read_f64_into_unchecked</span>::<span class="op"><</span><span class="ident">BigEndian</span><span class="op">></span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">dst</span>).<span class="ident">unwrap</span>();
|
||
}
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>([<span class="ident">f64</span>::<span class="ident">consts</span>::<span class="ident">PI</span>, <span class="number">1.0</span>], <span class="ident">dst</span>);</pre>
|
||
</div></div>
|
||
<h2 id='implementors'>Implementors</h2>
|
||
<ul class='item-list' id='implementors-list'>
|
||
<li><code>impl<R: <a class="trait" href="https://doc.rust-lang.org/nightly/std/io/trait.Read.html" title="trait std::io::Read">Read</a> + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>> ReadBytesExt for R</code></li>
|
||
</ul><script type="text/javascript" async
|
||
src="../implementors/byteorder/trait.ReadBytesExt.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>?</dt>
|
||
<dd>Show this help dialog</dd>
|
||
<dt>S</dt>
|
||
<dd>Focus the search field</dd>
|
||
<dt>⇤</dt>
|
||
<dd>Move up in search results</dd>
|
||
<dt>⇥</dt>
|
||
<dd>Move down in search results</dd>
|
||
<dt>⏎</dt>
|
||
<dd>Go to active search result</dd>
|
||
<dt>+</dt>
|
||
<dd>Collapse/expand 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>
|
||
</div>
|
||
</div>
|
||
</aside>
|
||
|
||
|
||
|
||
<script>
|
||
window.rootPath = "../";
|
||
window.currentCrate = "byteorder";
|
||
</script>
|
||
<script src="../main.js"></script>
|
||
<script defer src="../search-index.js"></script>
|
||
</body>
|
||
</html> |