Expand description
§bytecord
Provides zero-copy access to byte data with guaranteed alignment and bounds checking. Designed for parsing binary formats, network protocols, and memory-mapped I/O.
§Features
- Alignment-aware operations (
align=1|2|4|8|16|...
) - Bounds-checked access
- Zero-copy views into data
- Supports both owned and borrowed buffers
§Examples
reading:
use bytecord::{ByteCord, ByteCordReader};
let data = vec![0u8; 1024];
let cord = ByteCord::new(data);
// Read with 4-byte alignment
let mut reader = cord.read_with_alignment(4);
let header = reader.next_n(16).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();
§Safety
All operations are bounds-checked. Unsafe code is strictly contained and documented.
Re-exports§
pub use builder::ByteCordBuilder;
pub use reader::ByteCordReader;
Modules§
- builder
- This module provies
ByteCordBuilder
. - reader
- This module provies
ByteCordReader
.
Structs§
- Byte
Cord - ByteCord.