#endianness #little-endian #big-endian #byte #binary #binary-data


Abstraction for reading and writing data with implicit byte order awareness

9 releases (5 breaking)

Uses old Rust 2015

0.6.0 Aug 3, 2021
0.5.0 Dec 2, 2019
0.4.1 Nov 26, 2019
0.4.0 Jan 15, 2019
0.1.0 Nov 22, 2018

#541 in Parser implementations

Download history 9214/week @ 2024-02-15 11510/week @ 2024-02-22 12479/week @ 2024-02-29 8113/week @ 2024-03-07 2827/week @ 2024-03-14 2810/week @ 2024-03-21 2647/week @ 2024-03-28 2374/week @ 2024-04-04 3350/week @ 2024-04-11 3366/week @ 2024-04-18 3229/week @ 2024-04-25 3997/week @ 2024-05-02 5463/week @ 2024-05-09 14877/week @ 2024-05-16 17723/week @ 2024-05-23 21921/week @ 2024-05-30

60,456 downloads per month
Used in 46 crates (15 directly)




Latest Version CI Status Minimum Rust Version 1.41.1 dependency status

A library for reading and writing data in some byte order.

Why yet another data parsing crate

While byteorder is well established in the Rust ecosystem, it relies on immaterial zero-constructor types for declaring the intended byte order. As such, it lacks a construct for reading and writing data in an endianness that is not originally known at compile time. For example, there are file formats in which the encoding may be either in little endian or in big endian order.

In addition, some users feel that adding the type parameter on each read/write method call is unnecessarily verbose and ugly.

Rather than building yet another new library, this crate aims to provide an alternative public API to byteorder, so that it becomes suitable for this particular case while preserving its familiarity and core capabilities.


An example follows. Please see the documentation for more information.

use byteordered::{ByteOrdered, Endianness};

let mut rd = ByteOrdered::le(get_data_source()?);
// read 1st byte
let b1 = rd.read_u8()?;
// choose to read the following data in Little Endian if it's 0,
// otherwise read in Big Endian
let endianness = Endianness::le_iff(b1 != 0);
let mut rd = rd.into_endianness(endianness);
let value: u32 = rd.read_u32()?;


Licensed under either of

at your option.

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.