Skip to content

HMath.Interchange.Binary

Module index · Numerical conventions

Description

HMath array wire format version 1. All structural integers are little endian, independent of the explicit payload endian. Header fields: 8-byte magic HMARRAY\0, u16 version, u8 dtypeendianrank/flags, u64 offset and backing length, u32 metadata length, rank*(u64 shape,i64 byte stride), UTF-8 length-prefixed metadata, backing bytes, u32 CRC-32/ISO-HDLC of everything preceding the checksum. Unknown versions, flags and trailing bytes fail. CRC detects accidental corruption, not malicious modification.

On this page

API Purpose
encodeBinary Given limits then Array, encode HMath wire-format v1 including shapestridesoffsetmetadatabacking storage and CRC-32.
decodeBinary Given limits then bytes, validate HMath v1 magicheaderflags/CRC and exact framing, returning an Array.
crc32 Standard CRC-32, compatible with ZIP and zlib, with a fixed 256-entry table.
runDecoder Strict, exact decoder: trailing bytes are an error rather than ignored.

Documentation

encodeBinary

encodeBinary :: Limits -> Array -> Either InterchangeError ByteString Source #

Given limits then Array, encode HMath wire-format v1 including shapestridesoffsetmetadatabacking storage and CRC-32. Invalid metadata/layout or exceeded aggregate byte budget fails.

decodeBinary

decodeBinary :: Limits -> ByteString -> Either InterchangeError Array Source #

Given limits then bytes, validate HMath v1 magicheaderflags/CRC and exact framing, returning an Array. Truncation, corruption, unsupported metadata or exceeded budgets return InterchangeError.

crc32

crc32 :: ByteString -> Word32 Source #

Standard CRC-32, compatible with ZIP and zlib, with a fixed 256-entry table.

runDecoder

runDecoder :: Get a -> ByteString -> Either InterchangeError a Source #

Strict, exact decoder: trailing bytes are an error rather than ignored.