mentat/byteorder/trait.ByteOrder.html
2018-08-22 17:04:13 +00:00

910 lines
No EOL
142 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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 `ByteOrder` trait in crate `byteorder`.">
<meta name="keywords" content="rust, rustlang, rust-lang, ByteOrder">
<title>byteorder::ByteOrder - Rust</title>
<link rel="stylesheet" type="text/css" href="../normalize.css">
<link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle">
<link rel="stylesheet" type="text/css" href="../dark.css">
<link rel="stylesheet" type="text/css" href="../main.css" id="themeStyle">
<script src="../storage.js"></script>
</head>
<body class="rustdoc trait">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<div class="sidebar-menu">&#9776;</div>
<p class='location'>Trait ByteOrder</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.read_u16">read_u16</a><a href="#tymethod.read_u32">read_u32</a><a href="#tymethod.read_u64">read_u64</a><a href="#tymethod.read_uint">read_uint</a><a href="#tymethod.write_u16">write_u16</a><a href="#tymethod.write_u32">write_u32</a><a href="#tymethod.write_u64">write_u64</a><a href="#tymethod.write_uint">write_uint</a><a href="#tymethod.read_u16_into">read_u16_into</a><a href="#tymethod.read_u32_into">read_u32_into</a><a href="#tymethod.read_u64_into">read_u64_into</a><a href="#tymethod.write_u16_into">write_u16_into</a><a href="#tymethod.write_u32_into">write_u32_into</a><a href="#tymethod.write_u64_into">write_u64_into</a><a href="#tymethod.from_slice_u16">from_slice_u16</a><a href="#tymethod.from_slice_u32">from_slice_u32</a><a href="#tymethod.from_slice_u64">from_slice_u64</a><a href="#tymethod.from_slice_f32">from_slice_f32</a><a href="#tymethod.from_slice_f64">from_slice_f64</a></div><a class="sidebar-title" href="#provided-methods">Provided Methods</a><div class="sidebar-links"><a href="#method.read_u24">read_u24</a><a href="#method.read_u48">read_u48</a><a href="#method.write_u24">write_u24</a><a href="#method.write_u48">write_u48</a><a href="#method.read_i16">read_i16</a><a href="#method.read_i24">read_i24</a><a href="#method.read_i32">read_i32</a><a href="#method.read_i48">read_i48</a><a href="#method.read_i64">read_i64</a><a href="#method.read_int">read_int</a><a href="#method.read_f32">read_f32</a><a href="#method.read_f64">read_f64</a><a href="#method.write_i16">write_i16</a><a href="#method.write_i24">write_i24</a><a href="#method.write_i32">write_i32</a><a href="#method.write_i48">write_i48</a><a href="#method.write_i64">write_i64</a><a href="#method.write_int">write_int</a><a href="#method.write_f32">write_f32</a><a href="#method.write_f64">write_f64</a><a href="#method.read_i16_into">read_i16_into</a><a href="#method.read_i32_into">read_i32_into</a><a href="#method.read_i64_into">read_i64_into</a><a href="#method.read_f32_into_unchecked">read_f32_into_unchecked</a><a href="#method.read_f64_into_unchecked">read_f64_into_unchecked</a><a href="#method.write_i16_into">write_i16_into</a><a href="#method.write_i32_into">write_i32_into</a><a href="#method.write_i64_into">write_i64_into</a><a href="#method.write_f32_into">write_f32_into</a><a href="#method.write_f64_into">write_f64_into</a><a href="#method.from_slice_i16">from_slice_i16</a><a href="#method.from_slice_i32">from_slice_i32</a><a href="#method.from_slice_i64">from_slice_i64</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='index.html'>byteorder</a></p><script>window.sidebarCurrent = {name: 'ByteOrder', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script></div>
</nav>
<div class="theme-picker">
<button id="theme-picker" aria-label="Pick another theme!">
<img src="../brush.svg" width="18" alt="Pick another theme!">
</button>
<div id="theme-choices"></div>
</div>
<script src="../theme.js"></script>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<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=''>ByteOrder</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'>&#x2212;</span>]
</a>
</span><a class='srclink' href='../src/byteorder/lib.rs.html#210-1705' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait ByteOrder: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Copy.html" title="trait core::marker::Copy">Copy</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/default/trait.Default.html" title="trait core::default::Default">Default</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/hash/trait.Hash.html" title="trait core::hash::Hash">Hash</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Ord.html" title="trait core::cmp::Ord">Ord</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> + <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialOrd.html" title="trait core::cmp::PartialOrd">PartialOrd</a> + Sealed {
fn <a href='#tymethod.read_u16' class='fnname'>read_u16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>;
<div class='item-spacer'></div> fn <a href='#tymethod.read_u32' class='fnname'>read_u32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>;
<div class='item-spacer'></div> fn <a href='#tymethod.read_u64' class='fnname'>read_u64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>;
<div class='item-spacer'></div> fn <a href='#tymethod.read_uint' class='fnname'>read_uint</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>;
<div class='item-spacer'></div> fn <a href='#tymethod.write_u16' class='fnname'>write_u16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_u32' class='fnname'>write_u32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_u64' class='fnname'>write_u64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_uint' class='fnname'>write_uint</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.read_u16_into' class='fnname'>read_u16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.read_u32_into' class='fnname'>read_u32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.read_u64_into' class='fnname'>read_u64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_u16_into' class='fnname'>write_u16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_u32_into' class='fnname'>write_u32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.write_u64_into' class='fnname'>write_u64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>);
<div class='item-spacer'></div> fn <a href='#tymethod.from_slice_u16' class='fnname'>from_slice_u16</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.from_slice_u32' class='fnname'>from_slice_u32</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.from_slice_u64' class='fnname'>from_slice_u64</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.from_slice_f32' class='fnname'>from_slice_f32</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
<div class='item-spacer'></div> fn <a href='#tymethod.from_slice_f64' class='fnname'>from_slice_f64</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>);
fn <a href='#method.read_u24' class='fnname'>read_u24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_u48' class='fnname'>read_u48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.write_u24' class='fnname'>write_u24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_u48' class='fnname'>write_u48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i16' class='fnname'>read_i16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i24' class='fnname'>read_i24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i32' class='fnname'>read_i32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i48' class='fnname'>read_i48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i64' class='fnname'>read_i64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_int' class='fnname'>read_int</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_f32' class='fnname'>read_f32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.read_f64' class='fnname'>read_f64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a> { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i16' class='fnname'>write_i16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i24' class='fnname'>write_i24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i32' class='fnname'>write_i32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i48' class='fnname'>write_i48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i64' class='fnname'>write_i64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_int' class='fnname'>write_int</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_f32' class='fnname'>write_f32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_f64' class='fnname'>write_f64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i16_into' class='fnname'>read_i16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i32_into' class='fnname'>read_i32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_i64_into' class='fnname'>read_i64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_f32_into_unchecked' class='fnname'>read_f32_into_unchecked</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.read_f64_into_unchecked' class='fnname'>read_f64_into_unchecked</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i16_into' class='fnname'>write_i16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i32_into' class='fnname'>write_i32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_i64_into' class='fnname'>write_i64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_f32_into' class='fnname'>write_f32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.write_f64_into' class='fnname'>write_f64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) { ... }
<div class='item-spacer'></div> fn <a href='#method.from_slice_i16' class='fnname'>from_slice_i16</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.from_slice_i32' class='fnname'>from_slice_i32</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
<div class='item-spacer'></div> fn <a href='#method.from_slice_i64' class='fnname'>from_slice_i64</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>) { ... }
}</pre><div class='docblock'><p><code>ByteOrder</code> describes types that can serialize integers as bytes.</p>
<p>Note that <code>Self</code> does not appear anywhere in this trait's definition!
Therefore, in order to use it, you'll need to use syntax like
<code>T::read_u16(&amp;[0, 1])</code> where <code>T</code> implements <code>ByteOrder</code>.</p>
<p>This crate provides two types that implement <code>ByteOrder</code>: <a href="enum.BigEndian.html"><code>BigEndian</code></a>
and <a href="enum.LittleEndian.html"><code>LittleEndian</code></a>.
This trait is sealed and cannot be implemented for callers to avoid
breaking backwards compatibility when adding new derived traits.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<p>Write and read <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
<p>Write and read <code>i16</code> numbers in big endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
<span class="ident">BigEndian</span>::<span class="ident">write_i16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">50_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">50_000</span>, <span class="ident">BigEndian</span>::<span class="ident">read_i16</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div>
<h2 id='required-methods' class='small-section-header'>
Required Methods<a href='#required-methods' class='anchor'></a>
</h2>
<div class='methods'>
<h3 id='tymethod.read_u16' class='method'><span id='read_u16.v' class='invisible'><code>fn <a href='#tymethod.read_u16' class='fnname'>read_u16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics" class="section-header"><a href="#panics">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 2</code>.</p>
</div><h3 id='tymethod.read_u32' class='method'><span id='read_u32.v' class='invisible'><code>fn <a href='#tymethod.read_u32' class='fnname'>read_u32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-1" class="section-header"><a href="#panics-1">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<p>Write and read <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='tymethod.read_u64' class='method'><span id='read_u64.v' class='invisible'><code>fn <a href='#tymethod.read_u64' class='fnname'>read_u64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-2" class="section-header"><a href="#panics-2">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<p>Write and read <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='tymethod.read_uint' class='method'><span id='read_uint.v' class='invisible'><code>fn <a href='#tymethod.read_uint' class='fnname'>read_uint</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-3" class="section-header"><a href="#panics-3">Panics</a></h1>
<p>Panics when <code>nbytes &lt; 1</code> or <code>nbytes &gt; 8</code> or
<code>buf.len() &lt; nbytes</code></p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<p>Write and read an n-byte number in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_uint</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>, <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_uint</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>, <span class="number">3</span>));</pre>
</div><h3 id='tymethod.write_u16' class='method'><span id='write_u16.v' class='invisible'><code>fn <a href='#tymethod.write_u16' class='fnname'>write_u16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u16.html">u16</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned 16 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-4" class="section-header"><a href="#panics-4">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 2</code>.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<p>Write and read <code>u16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u16</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='tymethod.write_u32' class='method'><span id='write_u32.v' class='invisible'><code>fn <a href='#tymethod.write_u32' class='fnname'>write_u32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned 32 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-5" class="section-header"><a href="#panics-5">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-5" class="section-header"><a href="#examples-5">Examples</a></h1>
<p>Write and read <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='tymethod.write_u64' class='method'><span id='write_u64.v' class='invisible'><code>fn <a href='#tymethod.write_u64' class='fnname'>write_u64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned 64 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-6" class="section-header"><a href="#panics-6">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-6" class="section-header"><a href="#examples-6">Examples</a></h1>
<p>Write and read <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='tymethod.write_uint' class='method'><span id='write_uint.v' class='invisible'><code>fn <a href='#tymethod.write_uint' class='fnname'>write_uint</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned integer <code>n</code> to <code>buf</code> using only <code>nbytes</code>.</p>
<h1 id="panics-7" class="section-header"><a href="#panics-7">Panics</a></h1>
<p>If <code>n</code> is not representable in <code>nbytes</code>, or if <code>nbytes</code> is <code>&gt; 8</code>, then
this method panics.</p>
<h1 id="examples-7" class="section-header"><a href="#examples-7">Examples</a></h1>
<p>Write and read an n-byte number in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_uint</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>, <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_uint</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>, <span class="number">3</span>));</pre>
</div><h3 id='tymethod.read_u16_into' class='method'><span id='read_u16_into.v' class='invisible'><code>fn <a href='#tymethod.read_u16_into' class='fnname'>read_u16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads unsigned 16 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-8" class="section-header"><a href="#panics-8">Panics</a></h1>
<p>Panics when <code>src.len() != 2*dst.len()</code>.</p>
<h1 id="examples-8" class="section-header"><a href="#examples-8">Examples</a></h1>
<p>Write and read <code>u16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u16_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u16_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.read_u32_into' class='method'><span id='read_u32_into.v' class='invisible'><code>fn <a href='#tymethod.read_u32_into' class='fnname'>read_u32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads unsigned 32 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-9" class="section-header"><a href="#panics-9">Panics</a></h1>
<p>Panics when <code>src.len() != 4*dst.len()</code>.</p>
<h1 id="examples-9" class="section-header"><a href="#examples-9">Examples</a></h1>
<p>Write and read <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u32_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.read_u64_into' class='method'><span id='read_u64_into.v' class='invisible'><code>fn <a href='#tymethod.read_u64_into' class='fnname'>read_u64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads unsigned 64 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-10" class="section-header"><a href="#panics-10">Panics</a></h1>
<p>Panics when <code>src.len() != 8*dst.len()</code>.</p>
<h1 id="examples-10" class="section-header"><a href="#examples-10">Examples</a></h1>
<p>Write and read <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u64_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.write_u16_into' class='method'><span id='write_u16_into.v' class='invisible'><code>fn <a href='#tymethod.write_u16_into' class='fnname'>write_u16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes unsigned 16 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-11" class="section-header"><a href="#panics-11">Panics</a></h1>
<p>Panics when <code>dst.len() != 2*src.len()</code>.</p>
<h1 id="examples-11" class="section-header"><a href="#examples-11">Examples</a></h1>
<p>Write and read <code>u16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u16_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u16_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.write_u32_into' class='method'><span id='write_u32_into.v' class='invisible'><code>fn <a href='#tymethod.write_u32_into' class='fnname'>write_u32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes unsigned 32 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-12" class="section-header"><a href="#panics-12">Panics</a></h1>
<p>Panics when <code>dst.len() != 4*src.len()</code>.</p>
<h1 id="examples-12" class="section-header"><a href="#examples-12">Examples</a></h1>
<p>Write and read <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u32_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.write_u64_into' class='method'><span id='write_u64_into.v' class='invisible'><code>fn <a href='#tymethod.write_u64_into' class='fnname'>write_u64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes unsigned 64 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-13" class="section-header"><a href="#panics-13">Panics</a></h1>
<p>Panics when <code>dst.len() != 8*src.len()</code>.</p>
<h1 id="examples-13" class="section-header"><a href="#examples-13">Examples</a></h1>
<p>Write and read <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_u64_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='tymethod.from_slice_u16' class='method'><span id='from_slice_u16.v' class='invisible'><code>fn <a href='#tymethod.from_slice_u16' class='fnname'>from_slice_u16</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of unsigned 16 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-14" class="section-header"><a href="#examples-14">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_u16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5u16</span>.<span class="ident">to_be</span>(), <span class="number">65000u16</span>.<span class="ident">to_be</span>()]);</pre>
</div><h3 id='tymethod.from_slice_u32' class='method'><span id='from_slice_u32.v' class='invisible'><code>fn <a href='#tymethod.from_slice_u32' class='fnname'>from_slice_u32</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of unsigned 32 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-15" class="section-header"><a href="#examples-15">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_u32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5u32</span>.<span class="ident">to_be</span>(), <span class="number">65000u32</span>.<span class="ident">to_be</span>()]);</pre>
</div><h3 id='tymethod.from_slice_u64' class='method'><span id='from_slice_u64.v' class='invisible'><code>fn <a href='#tymethod.from_slice_u64' class='fnname'>from_slice_u64</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of unsigned 64 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-16" class="section-header"><a href="#examples-16">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_u64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5u64</span>.<span class="ident">to_be</span>(), <span class="number">65000u64</span>.<span class="ident">to_be</span>()]);</pre>
</div><h3 id='tymethod.from_slice_f32' class='method'><span id='from_slice_f32.v' class='invisible'><code>fn <a href='#tymethod.from_slice_f32' class='fnname'>from_slice_f32</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of IEEE754 single-precision (4 bytes) floating
point numbers to a particular endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
</div><h3 id='tymethod.from_slice_f64' class='method'><span id='from_slice_f64.v' class='invisible'><code>fn <a href='#tymethod.from_slice_f64' class='fnname'>from_slice_f64</a>(numbers: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of IEEE754 double-precision (8 bytes) floating
point numbers to a particular endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
</div></div>
<h2 id='provided-methods' class='small-section-header'>
Provided Methods<a href='#provided-methods' class='anchor'></a>
</h2>
<div class='methods'>
<h3 id='method.read_u24' class='method'><span id='read_u24.v' class='invisible'><code>fn <a href='#method.read_u24' class='fnname'>read_u24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>, stored in u32.</p>
<h1 id="panics-14" class="section-header"><a href="#panics-14">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 3</code>.</p>
<h1 id="examples-17" class="section-header"><a href="#examples-17">Examples</a></h1>
<p>Write and read 24 bit <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u24</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u24</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.read_u48' class='method'><span id='read_u48.v' class='invisible'><code>fn <a href='#method.read_u48' class='fnname'>read_u48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 48 bit integer from <code>buf</code>, stored in u64.</p>
<h1 id="panics-15" class="section-header"><a href="#panics-15">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 6</code>.</p>
<h1 id="examples-18" class="section-header"><a href="#examples-18">Examples</a></h1>
<p>Write and read 48 bit <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">6</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u48</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u48</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_u24' class='method'><span id='write_u24.v' class='invisible'><code>fn <a href='#method.write_u24' class='fnname'>write_u24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u32.html">u32</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned 24 bit integer <code>n</code> to <code>buf</code>, stored in u32.</p>
<h1 id="panics-16" class="section-header"><a href="#panics-16">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 3</code>.</p>
<h1 id="examples-19" class="section-header"><a href="#examples-19">Examples</a></h1>
<p>Write and read 24 bit <code>u32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u24</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u24</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_u48' class='method'><span id='write_u48.v' class='invisible'><code>fn <a href='#method.write_u48' class='fnname'>write_u48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u64.html">u64</a>)</code></span></h3><div class='docblock'><p>Writes an unsigned 48 bit integer <code>n</code> to <code>buf</code>, stored in u64.</p>
<h1 id="panics-17" class="section-header"><a href="#panics-17">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 6</code>.</p>
<h1 id="examples-20" class="section-header"><a href="#examples-20">Examples</a></h1>
<p>Write and read 48 bit <code>u64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">6</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_u48</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="number">1_000_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">1_000_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_u48</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-18" class="section-header"><a href="#panics-18">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 2</code>.</p>
<h1 id="examples-21" class="section-header"><a href="#examples-21">Examples</a></h1>
<p>Write and read <code>i16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i16</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>, stored in i32.</p>
<h1 id="panics-19" class="section-header"><a href="#panics-19">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 3</code>.</p>
<h1 id="examples-22" class="section-header"><a href="#examples-22">Examples</a></h1>
<p>Write and read 24 bit <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i24</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i24</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-20" class="section-header"><a href="#panics-20">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-23" class="section-header"><a href="#examples-23">Examples</a></h1>
<p>Write and read <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.read_i48' class='method'><span id='read_i48.v' class='invisible'><code>fn <a href='#method.read_i48' class='fnname'>read_i48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 48 bit integer from <code>buf</code>, stored in i64.</p>
<h1 id="panics-21" class="section-header"><a href="#panics-21">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 6</code>.</p>
<h1 id="examples-24" class="section-header"><a href="#examples-24">Examples</a></h1>
<p>Write and read 48 bit <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">6</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i48</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i48</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-22" class="section-header"><a href="#panics-22">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-25" class="section-header"><a href="#examples-25">Examples</a></h1>
<p>Write and read <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -&gt; <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 <code>buf</code>.</p>
<h1 id="panics-23" class="section-header"><a href="#panics-23">Panics</a></h1>
<p>Panics when <code>nbytes &lt; 1</code> or <code>nbytes &gt; 8</code> or
<code>buf.len() &lt; nbytes</code></p>
<h1 id="examples-26" class="section-header"><a href="#examples-26">Examples</a></h1>
<p>Write and read n-length signed numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_int</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000</span>, <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_int</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>, <span class="number">3</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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.</p>
<h1 id="panics-24" class="section-header"><a href="#panics-24">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-27" class="section-header"><a href="#examples-27">Examples</a></h1>
<p>Write and read <code>f32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="number">2.71828</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="ident">e</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">e</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_f32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>) -&gt; <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.</p>
<h1 id="panics-25" class="section-header"><a href="#panics-25">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-28" class="section-header"><a href="#examples-28">Examples</a></h1>
<p>Write and read <code>f64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="ident">phi</span> <span class="op">=</span> <span class="number">1.6180339887</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="ident">phi</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">phi</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_f64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_i16' class='method'><span id='write_i16.v' class='invisible'><code>fn <a href='#method.write_i16' class='fnname'>write_i16</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i16.html">i16</a>)</code></span></h3><div class='docblock'><p>Writes a signed 16 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-26" class="section-header"><a href="#panics-26">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 2</code>.</p>
<h1 id="examples-29" class="section-header"><a href="#examples-29">Examples</a></h1>
<p>Write and read <code>i16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i16</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_i24' class='method'><span id='write_i24.v' class='invisible'><code>fn <a href='#method.write_i24' class='fnname'>write_i24</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span></h3><div class='docblock'><p>Writes a signed 24 bit integer <code>n</code> to <code>buf</code>, stored in i32.</p>
<h1 id="panics-27" class="section-header"><a href="#panics-27">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 3</code>.</p>
<h1 id="examples-30" class="section-header"><a href="#examples-30">Examples</a></h1>
<p>Write and read 24 bit <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i24</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i24</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_i32' class='method'><span id='write_i32.v' class='invisible'><code>fn <a href='#method.write_i32' class='fnname'>write_i32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i32.html">i32</a>)</code></span></h3><div class='docblock'><p>Writes a signed 32 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-28" class="section-header"><a href="#panics-28">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-31" class="section-header"><a href="#examples-31">Examples</a></h1>
<p>Write and read <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_i48' class='method'><span id='write_i48.v' class='invisible'><code>fn <a href='#method.write_i48' class='fnname'>write_i48</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>)</code></span></h3><div class='docblock'><p>Writes a signed 48 bit integer <code>n</code> to <code>buf</code>, stored in i64.</p>
<h1 id="panics-29" class="section-header"><a href="#panics-29">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 6</code>.</p>
<h1 id="examples-32" class="section-header"><a href="#examples-32">Examples</a></h1>
<p>Write and read 48 bit <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">6</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i48</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i48</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_i64' class='method'><span id='write_i64.v' class='invisible'><code>fn <a href='#method.write_i64' class='fnname'>write_i64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>)</code></span></h3><div class='docblock'><p>Writes a signed 64 bit integer <code>n</code> to <code>buf</code>.</p>
<h1 id="panics-30" class="section-header"><a href="#panics-30">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-33" class="section-header"><a href="#examples-33">Examples</a></h1>
<p>Write and read <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000_000_000</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000_000_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_i64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_int' class='method'><span id='write_int.v' class='invisible'><code>fn <a href='#method.write_int' class='fnname'>write_int</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.i64.html">i64</a>, nbytes: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>)</code></span></h3><div class='docblock'><p>Writes a signed integer <code>n</code> to <code>buf</code> using only <code>nbytes</code>.</p>
<h1 id="panics-31" class="section-header"><a href="#panics-31">Panics</a></h1>
<p>If <code>n</code> is not representable in <code>nbytes</code>, or if <code>nbytes</code> is <code>&gt; 8</code>, then
this method panics.</p>
<h1 id="examples-34" class="section-header"><a href="#examples-34">Examples</a></h1>
<p>Write and read an n-byte number in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">3</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_int</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="op">-</span><span class="number">1_000</span>, <span class="number">3</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">-</span><span class="number">1_000</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_int</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>, <span class="number">3</span>));</pre>
</div><h3 id='method.write_f32' class='method'><span id='write_f32.v' class='invisible'><code>fn <a href='#method.write_f32' class='fnname'>write_f32</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f32.html">f32</a>)</code></span></h3><div class='docblock'><p>Writes a IEEE754 single-precision (4 bytes) floating point number.</p>
<h1 id="panics-32" class="section-header"><a href="#panics-32">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 4</code>.</p>
<h1 id="examples-35" class="section-header"><a href="#examples-35">Examples</a></h1>
<p>Write and read <code>f32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="ident">e</span> <span class="op">=</span> <span class="number">2.71828</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="ident">e</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">e</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_f32</span>(<span class="kw-2">&amp;</span><span class="ident">buf</span>));</pre>
</div><h3 id='method.write_f64' class='method'><span id='write_f64.v' class='invisible'><code>fn <a href='#method.write_f64' class='fnname'>write_f64</a>(buf: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.f64.html">f64</a>)</code></span></h3><div class='docblock'><p>Writes a IEEE754 double-precision (8 bytes) floating point number.</p>
<h1 id="panics-33" class="section-header"><a href="#panics-33">Panics</a></h1>
<p>Panics when <code>buf.len() &lt; 8</code>.</p>
<h1 id="examples-36" class="section-header"><a href="#examples-36">Examples</a></h1>
<p>Write and read <code>f64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="ident">phi</span> <span class="op">=</span> <span class="number">1.6180339887</span>;
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">buf</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">buf</span>, <span class="ident">phi</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">phi</span>, <span class="ident">LittleEndian</span>::<span class="ident">read_f64</span>(<span class="kw-2">&amp;</span><span class="ident">buf</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>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads signed 16 bit integers from <code>src</code> to <code>dst</code>.</p>
<h1 id="panics-34" class="section-header"><a href="#panics-34">Panics</a></h1>
<p>Panics when <code>buf.len() != 2*dst.len()</code>.</p>
<h1 id="examples-37" class="section-header"><a href="#examples-37">Examples</a></h1>
<p>Write and read <code>i16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i16_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i16_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</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>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads signed 32 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-35" class="section-header"><a href="#panics-35">Panics</a></h1>
<p>Panics when <code>src.len() != 4*dst.len()</code>.</p>
<h1 id="examples-38" class="section-header"><a href="#examples-38">Examples</a></h1>
<p>Write and read <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i32_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</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>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads signed 64 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-36" class="section-header"><a href="#panics-36">Panics</a></h1>
<p>Panics when <code>src.len() != 8*dst.len()</code>.</p>
<h1 id="examples-39" class="section-header"><a href="#examples-39">Examples</a></h1>
<p>Write and read <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i64_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.read_f32_into_unchecked' class='method'><span id='read_f32_into_unchecked.v' class='invisible'><code>fn <a href='#method.read_f32_into_unchecked' class='fnname'>read_f32_into_unchecked</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads IEEE754 single-precision (4 bytes) floating point numbers from
<code>src</code> into <code>dst</code>.</p>
<h1 id="panics-37" class="section-header"><a href="#panics-37">Panics</a></h1>
<p>Panics when <code>src.len() != 4*dst.len()</code>.</p>
<h1 id="examples-40" class="section-header"><a href="#examples-40">Examples</a></h1>
<p>Write and read <code>f32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1.0</span>, <span class="number">2.0</span>, <span class="number">31.312e311</span>, <span class="op">-</span><span class="number">11.32e91</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_f32_into_unchecked</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.read_f64_into_unchecked' class='method'><span id='read_f64_into_unchecked.v' class='invisible'><code>fn <a href='#method.read_f64_into_unchecked' class='fnname'>read_f64_into_unchecked</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Reads IEEE754 single-precision (4 bytes) floating point numbers from
<code>src</code> into <code>dst</code>.</p>
<h1 id="panics-38" class="section-header"><a href="#panics-38">Panics</a></h1>
<p>Panics when <code>src.len() != 8*dst.len()</code>.</p>
<h1 id="examples-41" class="section-header"><a href="#examples-41">Examples</a></h1>
<p>Write and read <code>f64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1.0</span>, <span class="number">2.0</span>, <span class="number">31.312e311</span>, <span class="op">-</span><span class="number">11.32e91</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_f64_into_unchecked</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.write_i16_into' class='method'><span id='write_i16_into.v' class='invisible'><code>fn <a href='#method.write_i16_into' class='fnname'>write_i16_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes signed 16 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-39" class="section-header"><a href="#panics-39">Panics</a></h1>
<p>Panics when <code>buf.len() != 2*src.len()</code>.</p>
<h1 id="examples-42" class="section-header"><a href="#examples-42">Examples</a></h1>
<p>Write and read <code>i16</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">8</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i16_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i16_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.write_i32_into' class='method'><span id='write_i32_into.v' class='invisible'><code>fn <a href='#method.write_i32_into' class='fnname'>write_i32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes signed 32 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-40" class="section-header"><a href="#panics-40">Panics</a></h1>
<p>Panics when <code>dst.len() != 4*src.len()</code>.</p>
<h1 id="examples-43" class="section-header"><a href="#examples-43">Examples</a></h1>
<p>Write and read <code>i32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i32_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.write_i64_into' class='method'><span id='write_i64_into.v' class='invisible'><code>fn <a href='#method.write_i64_into' class='fnname'>write_i64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes signed 64 bit integers from <code>src</code> into <code>dst</code>.</p>
<h1 id="panics-41" class="section-header"><a href="#panics-41">Panics</a></h1>
<p>Panics when <code>dst.len() != 8*src.len()</code>.</p>
<h1 id="examples-44" class="section-header"><a href="#examples-44">Examples</a></h1>
<p>Write and read <code>i64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1</span>, <span class="number">2</span>, <span class="number">0xf00f</span>, <span class="number">0xffee</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_i64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">4</span>];
<span class="ident">LittleEndian</span>::<span class="ident">read_i64_into</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.write_f32_into' class='method'><span id='write_f32_into.v' class='invisible'><code>fn <a href='#method.write_f32_into' class='fnname'>write_f32_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes IEEE754 single-precision (4 bytes) floating point numbers from
<code>src</code> into <code>dst</code>.</p>
<h1 id="panics-42" class="section-header"><a href="#panics-42">Panics</a></h1>
<p>Panics when <code>src.len() != 4*dst.len()</code>.</p>
<h1 id="examples-45" class="section-header"><a href="#examples-45">Examples</a></h1>
<p>Write and read <code>f32</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">16</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1.0</span>, <span class="number">2.0</span>, <span class="number">31.312e311</span>, <span class="op">-</span><span class="number">11.32e91</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f32_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">4</span>];
<span class="kw">unsafe</span> {
<span class="ident">LittleEndian</span>::<span class="ident">read_f32_into_unchecked</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.write_f64_into' class='method'><span id='write_f64_into.v' class='invisible'><code>fn <a href='#method.write_f64_into' class='fnname'>write_f64_into</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;[</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>, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;mut [</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.u8.html">u8</a><a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">]</a>)</code></span></h3><div class='docblock'><p>Writes IEEE754 double-precision (8 bytes) floating point numbers from
<code>src</code> into <code>dst</code>.</p>
<h1 id="panics-43" class="section-header"><a href="#panics-43">Panics</a></h1>
<p>Panics when <code>src.len() != 8*dst.len()</code>.</p>
<h1 id="examples-46" class="section-header"><a href="#examples-46">Examples</a></h1>
<p>Write and read <code>f64</code> numbers in little endian order:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">LittleEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">bytes</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">32</span>];
<span class="kw">let</span> <span class="ident">numbers_given</span> <span class="op">=</span> [<span class="number">1.0</span>, <span class="number">2.0</span>, <span class="number">31.312e311</span>, <span class="op">-</span><span class="number">11.32e91</span>];
<span class="ident">LittleEndian</span>::<span class="ident">write_f64_into</span>(<span class="kw-2">&amp;</span><span class="ident">numbers_given</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">bytes</span>);
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers_got</span> <span class="op">=</span> [<span class="number">0.0</span>; <span class="number">4</span>];
<span class="kw">unsafe</span> {
<span class="ident">LittleEndian</span>::<span class="ident">read_f64_into_unchecked</span>(<span class="kw-2">&amp;</span><span class="ident">bytes</span>, <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers_got</span>);
}
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers_given</span>, <span class="ident">numbers_got</span>);</pre>
</div><h3 id='method.from_slice_i16' class='method'><span id='from_slice_i16.v' class='invisible'><code>fn <a href='#method.from_slice_i16' class='fnname'>from_slice_i16</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of signed 16 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-47" class="section-header"><a href="#examples-47">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_i16</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5i16</span>.<span class="ident">to_be</span>(), <span class="number">65000i16</span>.<span class="ident">to_be</span>()]);</pre>
</div><h3 id='method.from_slice_i32' class='method'><span id='from_slice_i32.v' class='invisible'><code>fn <a href='#method.from_slice_i32' class='fnname'>from_slice_i32</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of signed 32 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-48" class="section-header"><a href="#examples-48">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_i32</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5i32</span>.<span class="ident">to_be</span>(), <span class="number">65000i32</span>.<span class="ident">to_be</span>()]);</pre>
</div><h3 id='method.from_slice_i64' class='method'><span id='from_slice_i64.v' class='invisible'><code>fn <a href='#method.from_slice_i64' class='fnname'>from_slice_i64</a>(src: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.slice.html">&amp;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>)</code></span></h3><div class='docblock'><p>Converts the given slice of signed 64 bit integers to a particular
endianness.</p>
<p>If the endianness matches the endianness of the host platform, then
this is a no-op.</p>
<h1 id="examples-49" class="section-header"><a href="#examples-49">Examples</a></h1>
<p>Convert the host platform's endianness to big-endian:</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">byteorder</span>::{<span class="ident">ByteOrder</span>, <span class="ident">BigEndian</span>};
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">numbers</span> <span class="op">=</span> [<span class="number">5</span>, <span class="number">65000</span>];
<span class="ident">BigEndian</span>::<span class="ident">from_slice_i64</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">numbers</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">numbers</span>, [<span class="number">5i64</span>.<span class="ident">to_be</span>(), <span class="number">65000i64</span>.<span class="ident">to_be</span>()]);</pre>
</div></div>
<h2 id='implementors' class='small-section-header'>
Implementors<a href='#implementors' class='anchor'></a>
</h2>
<ul class='item-list' id='implementors-list'>
<li><div class='out-of-band'><a class='srclink' href='../src/byteorder/lib.rs.html#1882-2095' title='goto source code'>[src]</a></div><code>impl ByteOrder for <a class="enum" href="../byteorder/enum.BigEndian.html" title="enum byteorder::BigEndian">BigEndian</a></code></li>
<li><div class='out-of-band'><a class='srclink' href='../src/byteorder/lib.rs.html#2097-2302' title='goto source code'>[src]</a></div><code>impl ByteOrder for <a class="enum" href="../byteorder/enum.LittleEndian.html" title="enum byteorder::LittleEndian">LittleEndian</a></code></li>
</ul><script type="text/javascript" async
src="../implementors/byteorder/trait.ByteOrder.js">
</script></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt><kbd>?</kbd></dt>
<dd>Show this help dialog</dd>
<dt><kbd>S</kbd></dt>
<dd>Focus the search field</dd>
<dt><kbd></kbd></dt>
<dd>Move up in search results</dd>
<dt><kbd></kbd></dt>
<dd>Move down in search results</dd>
<dt><kbd></kbd></dt>
<dd>Switch tab</dd>
<dt><kbd>&#9166;</kbd></dt>
<dd>Go to active search result</dd>
<dt><kbd>+</kbd></dt>
<dd>Expand all sections</dd>
<dt><kbd>-</kbd></dt>
<dd>Collapse all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "byteorder";
</script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>