This release features major breaking changes trying to make library more consistent.
Format Changes
-
Numbers in format strings mean static arrays. Thus
2candccare not the same any more.data.unpack!`2i` // tuple(int[2]) data.unpack!`ii` // tuple(int, int)
-
Added
*as syntax for dynamic arrays. Details of serializing dynamic arrays are described inBinaryWriterchanges. E.g. dynamic array of typeintis*i. -
Arrays passed to pack with format string being single type are written as static arrays (without length).
pack!`<*h`([2,3]) // [2, 0, 0, 0, 2, 0, 3, 0] pack!`<h`([2,3]) // [2, 0, 3, 0]
Writer and Reader
BinaryWriter
- Dynamic arrays and strings are serialized as array length (always 4-byte uint) followed by array contents. Trying to write array with length bigger than
uint.maxresults inException. - Static arrays are serialized as-is, without terminator and length.
- Strings can be written with null terminator with
writeString - Dynamic arrays can be written without length using
writeArray
BinaryReader
- Behavior changed to match
BinaryWriterbehavior.
More internal breakages
formatCharOfis renamed toformatStringOfand no longer returnschars. It also adds type prefixes for dynamic and static arrays. For static arrays, array length is passed (e.g.formatStringOf!(char[5])is5c). Dynamic arrays are prefixed with*.- Invalid type passed to
formatStringOfresults in static assert failure.