Bits | Hex | Type |
---|---|---|
00000000 |
00 |
Integer |
00000001 |
01 |
Floating Point |
00000010 |
02 |
Array |
00000011 |
03 |
Record |
00000100 |
04 |
Blob |
00000101 |
05 |
Text |
00000111 |
07 |
Symbol |
This note describes a message format called Wota that was developed for use in Misty's local messaging system. It is very similar to Nota, but works at word granularity rather than byte granulaty. The arrangements Wota produces are less compact than Nota, but are faster to arrange and consume. In network transfers, compactness is highly prized. In local inter-process communication, copying arrangements from one memory space to another, compactness is less beneficial. On 64 bit systems, a Wota word is 64 bits with no straddling.
Wota stands for Word Object Transfer Arrangement.
Every Wota value starts with a preamble. The least significant byte (aka the red bits) contains a type. The interpetation of the most significant remaining 56 bits (aka the blue bits) depends on the type.
A blob is a string of bits. The remaining field contains the number of bits. The number of words that follow:
floor((number_of_bits + 63) / 64)
The first bit of the blob goes into the most significant bit of the first word. The final word is padded with 0
as necessary.
Example: A blob containing 25 bits: 111100001110001100100001
0000000000000000000000000000000000000000000000000001100100000100 # 0000000000001904 1111000011100011001000001000000000000000000000000000000000000000 # F0E3208000000000
The text is a string of UTF-32 characters packed 2 per word. The remaining field contains the number of characters. The number of words that follow:
floor((number_of_characters + 1) / 2)
The final word is padded with 0
as necessary.
Example: "cat"
0000000000000000000000000000000000000000000000000000001100000101 # 0000000000000305 0000000000000000000000000110001100000000000000000000000001100001 # 0000006300000061 0000000000000000000000000111010000000000000000000000000000000000 # 0000007400000000
An array is an ordered sequence of values. The remaining field contains the number of elements. Following the preamble are the elements of the array. Each element begins with one of the preambles. As with JSON, nesting is encouraged.
Example: ["cat", ""]
.
0000000000000000000000000000000000000000000000000000001000000010 # 0000000000000202 0000000000000000000000000000000000000000000000000000001100000101 # 0000000000000305 0000000000000000000000000110001100000000000000000000000001100001 # 0000006300000061 0000000000000000000000000111010000000000000000000000000000000000 # 0000007400000000 0000000000000000000000000000000000000000000000000000000000000101 # 0000000000000005
A record is a set of key:value pairs. The keys must be text. The values can be any Wota values. The remaining field contains the number of pairs.
Example: {"cat": [""]}
.
0000000000000000000000000000000000000000000000000000000100000011 # 0000000000000103 0000000000000000000000000000000000000000000000000000001100000101 # 0000000000000305 0000000000000000000000000110001100000000000000000000000001100001 # 0000006300000061 0000000000000000000000000111010000000000000000000000000000000000 # 0000007400000000 0000000000000000000000000000000000000000000000000000000100000010 # 0000000000000102 0000000000000000000000000000000000000000000000000000000000000101 # 0000000000000005
Numbers are represented as DEC64. To arrange an integer in Wota, simply shift the integer up 8 bits. The number is incorporated into the preamble.
Example: 7
0000000000000000000000000000000000000000000000000000011100000000 # 0000000000000700
To arrange a floating point number, place the number in the word following the floating point preamble. The remaining field is not used.
Care must be taken when decoding that the least significant byte of the number is not 10000000 # 80
.
Example: 4.25
0000000000000000000000000000000000000000000000000000000000000001 # 0000000000000001 0000000000000000000000000000000000000000000000011010100111111110 # 000000000001A9FE
Currently there are only five symbols. All other symbols are reserved. The remaining field contains the symbol.
Example: [null, false, true, private, system]
0000000000000000000000000000000000000000000000000000010100000010 # 0000000000000502
0000000000000000000000000000000000000000000000000000000000000111 # 0000000000000007
0000000000000000000000000000000000000000000000000000001000000111 # 0000000000000207
0000000000000000000000000000000000000000000000000000001100000111 # 0000000000000307
0000000000000000000000000000000000000000000000000000100000000111 # 0000000000000807
0000000000000000000000000000000000000000000000000000100100000111 # 0000000000000907