author Valentin Gosu <>
Tue, 27 Sep 2016 10:26:00 +0200
changeset 315429 d3a0e25cebb306ee52992d15cffbc47248309f91
parent 313944 0ee12557d6e630d90e07fdecf88016fde7e68ea7
child 328948 d577cf31d3dcb3cb353dba652c2a14d90d2e7882
permissions -rw-r--r--
Bug 1231565 - (Part 3) Make alt-data responses report the correct content length r=michal MozReview-Commit-ID: DvQP7NB4SqW

This crate provides convenience methods for encoding and decoding numbers in
either big-endian or little-endian order. This is meant to replace the old
methods defined on the standard library `Reader` and `Writer` traits.

[![Build status](](

Dual-licensed under MIT or the [UNLICENSE](

### Documentation


The documentation includes examples.

### Installation

This crate works with Cargo and is on
[]( The package is regularly
updated.  Add it to your `Cargo.toml` like so:

byteorder = "0.5"

If you want to augment existing `Read` and `Write` traits, then import the
extension methods like so:

extern crate byteorder;

use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};

For example:

use std::io::Cursor;
use byteorder::{BigEndian, ReadBytesExt};

let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
// Note that we use type parameters to indicate which kind of byte order
// we want!
assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());

### `no_std` crates

This crate has a feature, `std`, that is enabled by default. To use this crate
in a `no_std` context, add the following to your `Cargo.toml`:

byteorder = { version = "0.5", default-features = false }