pub fn read_uint40(data: &[u8]) -> Result<u64>
Expand description
Read a 40-bit (5-byte) unsigned integer from a byte slice (little-endian)
40-bit integers are used throughout TACT formats for file sizes and offsets. They allow representing values up to 1TB while saving space compared to 64-bit.
§Arguments
data
- Byte slice containing at least 5 bytes
§Returns
- The 40-bit value as a u64
§Errors
- Returns error if data contains less than 5 bytes
§Example
use tact_parser::utils::read_uint40;
let data = [0x12, 0x34, 0x56, 0x78, 0x9A];
let value = read_uint40(&data).unwrap();
assert_eq!(value, 0x9A78563412);