1 This crate provides convenience methods for encoding and decoding
2 numbers in either big-endian or little-endian order.
4 [![Build status](https://api.travis-ci.org/BurntSushi/byteorder.svg)](https://travis-ci.org/BurntSushi/byteorder)
5 [![](http://meritbadge.herokuapp.com/byteorder)](https://crates.io/crates/byteorder)
7 Dual-licensed under MIT or the [UNLICENSE](http://unlicense.org).
12 https://docs.rs/byteorder
17 This crate works with Cargo and is on
18 [crates.io](https://crates.io/crates/byteorder). Add it to your `Cargo.toml`
26 If you want to augment existing `Read` and `Write` traits, then import the
27 extension methods like so:
30 extern crate byteorder;
32 use byteorder::{ReadBytesExt, WriteBytesExt, BigEndian, LittleEndian};
39 use byteorder::{BigEndian, ReadBytesExt};
41 let mut rdr = Cursor::new(vec![2, 5, 3, 0]);
42 // Note that we use type parameters to indicate which kind of byte order
44 assert_eq!(517, rdr.read_u16::<BigEndian>().unwrap());
45 assert_eq!(768, rdr.read_u16::<BigEndian>().unwrap());
50 This crate has a feature, `std`, that is enabled by default. To use this crate
51 in a `no_std` context, add the following to your `Cargo.toml`:
55 byteorder = { version = "1", default-features = false }
61 Note that as of Rust 1.32, the standard numeric types provide built-in methods
62 like `to_le_bytes` and `from_le_bytes`, which support some of the same use