Expand description
An unsigned 24-bit integer type for Rust.
This crate provides a u24 type that represents unsigned 24-bit integers
in little-endian format. The type has the same size, alignment, and memory layout as a
little-endian encoded u32.
§Examples
Basic construction and usage:
use u24::u24;
// Create u24 values using the macro
let zero = u24!(0);
let small = u24!(42);
let large = u24!(0xFFFFFF); // Maximum value
// Convert from bytes
let from_bytes = u24::from_le_bytes([0x34, 0x12, 0xAB]);
assert_eq!(from_bytes.into_u32(), 0x00_AB1234);
// Convert from u32 with bounds checking
let checked = u24::checked_from_u32(0x123456).unwrap();
let too_big = u24::checked_from_u32(0x01_000000); // None
// Arithmetic operations
let sum = u24!(100) + u24!(200);
let product = u24!(16) * u24!(1024);Re-exports§
pub use unaligned::U24;
Modules§
- unaligned
- Unaligned 24-bit integers with configurable byte order.
Macros§
- u24
- Creates a
u24value from a literal or expression.
Structs§
- Parse
U24Err - An error which can be returned when parsing a
u24. - u24
- An unsigned little-endian encoded 24-bit integer.