Rust library for reading/writing numbers in big-endian and little-endian.
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Reynard User 05b0a9a9b3
Some checks failed
ci / test (push) Has been cancelled
ci / test-1 (push) Has been cancelled
ci / test-2 (push) Has been cancelled
ci / test-3 (push) Has been cancelled
ci / test-4 (push) Has been cancelled
ci / test-5 (push) Has been cancelled
ci / test-6 (push) Has been cancelled
ci / test-7 (push) Has been cancelled
ci / test-8 (push) Has been cancelled
ci / test-9 (push) Has been cancelled
ci / test-10 (push) Has been cancelled
ci / miri (push) Has been cancelled
ci / rustfmt (push) Has been cancelled
chore: sync dependencies (monorepo)
2026-04-07 18:06:20 +02:00
.github github: add FUNDING 2024-09-25 16:46:19 -04:00
benches bench: add read/write into benchmarks for u16 and i64 2023-10-05 20:41:27 -04:00
src chore: sync dependencies (monorepo) 2026-04-07 18:06:20 +02:00
.gitignore initial commit 2015-02-03 18:30:01 -05:00
Cargo.toml chore: sync dependencies (monorepo) 2026-04-06 15:20:58 +02:00
COPYING dual licensed under MIT and UNLICENSE 2015-04-15 18:30:30 -04:00
LICENSE-MIT dual licensed under MIT and UNLICENSE 2015-04-15 18:30:30 -04:00
README.md cargo: a few small fixups 2023-10-05 20:44:53 -04:00
rustfmt.toml style: use rustfmt 2020-02-07 23:16:05 -05:00
UNLICENSE initial commit 2015-02-03 18:30:01 -05:00

byteorder

This crate provides convenience methods for encoding and decoding numbers in either big-endian or little-endian order.

Build status crates.io

Dual-licensed under MIT or the UNLICENSE.

Documentation

https://docs.rs/byteorder

Installation

This crate works with Cargo and is on crates.io. Add it to your Cargo.toml like so:

[dependencies]
byteorder = "1"

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

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:

[dependencies]
byteorder = { version = "1", default-features = false }

Minimum Rust version policy

This crate's minimum supported rustc version is 1.60.0.

The current policy is that the minimum Rust version required to use this crate can be increased in minor version updates. For example, if crate 1.0 requires Rust 1.20.0, then crate 1.0.z for all values of z will also require Rust 1.20.0 or newer. However, crate 1.y for y > 0 may require a newer minimum version of Rust.

In general, this crate will be conservative with respect to the minimum supported version of Rust.

Alternatives

Note that as of Rust 1.32, the standard numeric types provide built-in methods like to_le_bytes and from_le_bytes, which support some of the same use cases.