futures-byteorder 0.1.2

A modern async byteorder library for the smol/futures-lite ecosystem
Documentation

🧮 futures-byteorder

Modern async byteorder library for smol/futures-lite

Crates.io Documentation MSRV: 1.87.0

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

[dependencies]
futures-byteorder = "0.1"

Reading

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

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

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.