futures-byteorder 1.0.1

A modern async byteorder library for the smol/futures-lite ecosystem
Documentation
<!-- markdownlint-disable no-inline-html first-line-heading no-emphasis-as-heading -->

<div align="center">

# `🧮 futures-byteorder`

**Modern async byteorder library for smol/futures-lite**

[![Crates.io](https://img.shields.io/crates/v/futures-byteorder.svg)](https://crates.io/crates/futures-byteorder)
[![Documentation](https://docs.rs/cargo-deny/badge.svg)](https://docs.rs/futures-byteorder)
[![MSRV: 1.87.0](https://img.shields.io/badge/Rust-1.87.0-blue?color=fc8d62&logo=rust)](https://blog.rust-lang.org/2025/05/15/Rust-1.87.0/)
[![builds.sr.ht Status](https://builds.sr.ht/~cupertino/Cupertino/futures-byteorder/branch/main/.build.yml.svg)](https://builds.sr.ht/~cupertino/Cupertino/futures-byteorder/branch/main/.build.yml?)

</div>

This crate provides utilities for reading and writing numbers in big-endian and little-endian byte
order for async I/O streams. It's designed as a lightweight alternative to `byteorder` with
first-class async support and zero proc-macro dependencies

## Quick start

```toml
[dependencies]
futures-byteorder = "0.1"
```

### Reading

```rust
use futures_byteorder::{AsyncReadBytes, BE};
use futures_lite::io::Cursor;

let data = vec![0x12, 0x34, 0x56, 0x78];
let mut reader = AsyncReadBytes::new(&mut Cursor::new(data));

// Read a big-endian u16
let value = reader.read_u16::<BE>().await?;
assert_eq!(value, 0x1234);

// Read using native endianness
let value = reader.read_u16_ne().await?;
```

### Writing

```rust
use futures_byteorder::{AsyncWriteBytes, LE};
use futures_lite::io::Cursor;

let mut buffer = Vec::new();
let mut writer = AsyncWriteBytes::new(&mut Cursor::new(&mut buffer));

writer.write_u32::<LE>(0x12345678).await?; // Write a little-endian u32
writer.write_u16_ne(0xABCD).await?; // Write using native endianness
```

## Endianness types

- `BigEndian` (`BE`) - Network byte order
- `LittleEndian` (`LE`) - x86 byte order
- `NativeEndian` (`NE`) - Platform native
- `NetworkEndian` - Alias for `BE`

## Supported types

All primitive numeric types: `u8`-`u128`, `i8`-`i128`, `f32`, `f64`

## Why futures-byteorder?

The original `byteorder` crate is excellent, but predates async/await. This crate provides:

- Native async support with `futures-lite`
- Designed for the smol ecosystem
- Basically zero dependencies
- Modern, clean API built for async from the ground up

## License

Licensed under either of

- Apache License, Version 2.0, ([LICENSE-APACHE]LICENSE-APACHE or
  <https://www.apache.org/licenses/LICENSE-2.0>)
- MIT license ([LICENSE-MIT]LICENSE-MIT or <https://opensource.org/licenses/MIT>)

at your option.

### Contribution

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.