Skip to main content

Module bytes

Module bytes 

Source
Expand description

Little-endian field readers that return a typed error instead of panicking. Every on-disk decoder used to spell u32::from_le_bytes( b[..4].try_into().unwrap()); the slice was always pre-checked, but a runtime that opens third-party files should not carry an unwrap on its parse path at all (clippy::unwrap_used is denied workspace-wide). A wrong length here is a decoder bug surfaced as UnexpectedEof.

Functionsยง

array32
Copy exactly 32 bytes (a sha256 digest) into an array.
le_f32
Read an f32 from exactly 4 little-endian bytes (bit pattern only; the caller decides whether NaN/Inf are acceptable).
le_u32
Read a u32 from exactly 4 little-endian bytes.
le_u64
Read a u64 from exactly 8 little-endian bytes.