bytecord

Crates.iobytecord
lib.rsbytecord
version0.0.2
created_at2025-04-15 01:10:43.412998+00
updated_at2025-04-16 17:25:42.410983+00
descriptionA byte reading-building utility library
homepagehttps://github.com/iizudev/bytecord
repositoryhttps://github.com/iizudev/bytecord
max_upload_size
id1633805
size76,198
(iizudev)

documentation

README

bytecord icon

A lightweight utility library for reading and building binary data with alignment.


Usage

Add this library to your project by:

cargo add bytecord

Example

reading:

use bytecord::ByteCord;

let data = vec![0u8; 1024];
let cord = ByteCord::new(data);

// Read with 4-byte alignment
let mut reader = cord.read_with_alignment(4);
let a = cord.next_be_u32().unwrap();
let b = cord.next_n(a).unwrap();

building:

use bytecord::ByteCordBuilder;

// a new builer with alignment of 1 byte (meaning no alignment)
let mut data = ByteCordBuilder::new(1);
data.append_le_u32(1111);
data.append_u8(1);
data.append_le_i64(-3919);
let slice = data.into_boxed_slice();

License

This project is dual-licensed under:

Commit count: 18

cargo fmt