Import with #import "std/binary".

BinaryReadFailure :: enum { None = 0; NegativeOffset = 1; Misaligned = 2; ShortField = 3; }
Float32FromBits :: (bits: u32) -> float64

The value of an IEEE 754 single from its bits.

Float64FromBits :: (bits: u64) -> float64

The value of an IEEE 754 double from its bits.

TryReadU16LE :: (bytes: string, at: s32) -> Result(u32, BinaryReadFailure)
TryReadU32LE :: (bytes: string, at: s32) -> Result(u32, BinaryReadFailure)
TryReadS32LE :: (bytes: string, at: s32) -> Result(s32, BinaryReadFailure)
TryReadF32LE :: (bytes: string, at: s32) -> Result(float64, BinaryReadFailure)
ReadU16LE :: (bytes: string, at: s32) -> u32

Plain readers for layouts the caller has validated: the field's bytes at AT, at any alignment. The caller keeps AT and the field inside BYTES, as in C; untrusted boundaries use the TryRead forms above, which name malformed input.

ReadU32LE :: (bytes: string, at: s32) -> u32
ReadS32LE :: (bytes: string, at: s32) -> s32
ReadF32LE :: (bytes: string, at: s32) -> float64

Source ↗ · All modules