Header Block
About 480 words
- Type ID:
0 - Type: Array
Header is the first block of the file. It records the file's identity, the specification version, and a statistics snapshot from the most recent full save. Readers rely on it to confirm that this is a UInk file.
Levels
Core. All readers and writers must support it.
Structure
Header is a fixed-length array array(7):
| Index | Field | Type | MessagePack encoding | Payload length |
|---|---|---|---|---|
| 0 | type | uint16 | uint16 | 2 bytes |
| 1 | version | uint16 | uint16 | 2 bytes |
| 2 | guid | string(36) | str8 | 36 bytes |
| 3 | deviceNum | uint32 | uint32 | 4 bytes |
| 4 | workspaceNum | uint32 | uint32 | 4 bytes |
| 5 | pageNum | uint32 | uint32 | 4 bytes |
| 6 | time | uint64 | uint64 | 8 bytes |
- Array header= 7 elements97fixarray1 byte · offset 0
- 0
type= 0cd0000uint163 bytes · offset 1–3 - 1
version= 11cd000buint163 bytes · offset 4–6 - 2
guid= 36 charactersd9245fe30f46-be92-49b6-b921-a60706febf10str838 bytes · offset 7–44 - 3
deviceNum= 2ce00000002uint325 bytes · offset 45–49 - 4
workspaceNum= 1ce00000001uint325 bytes · offset 50–54 - 5
pageNum= 12ce0000000cuint325 bytes · offset 55–59 - 6
time= 1700000000cf000000006553f100uint649 bytes · offset 60–68
- Type marker: sets the encoding and length (
cduint16,ceuint32,cfuint64,d9str8) - str8 length byte:
0x24= 36 - The value or text itself
The public sample core-pages.uink has the same structure in its first 69 bytes; only the values differ.
Fields
| Field | Description |
|---|---|
type | Always 0 |
version | Specification version number; 11 for 1.1. See Versions and Changes |
guid | UUID generated when the file is first created, in the format xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx |
deviceNum | Number of Devices at the most recent full save; 1 when the implicit singleton is used |
workspaceNum | Number of Workspaces at the most recent full save; 1 when the implicit singleton is used |
pageNum | Sum of the page counts of all Workspaces at the most recent full save; a page spanning several Devices or layers counts once, and blank pages count too |
time | Unix UTC timestamp, in seconds, of when the most recent full save completed |
Rules
- HDR-1 Writers must write
array(7)exactly as in the table above: the field order, numeric widths and the str8 encoding ofguidmust not change, and the MessagePack smallest integer encoding must not be used in place of the fixed widths. - HDR-2 Readers must verify the array length,
type = 0, theversionrange (VER-3) and the 36-character UUID format. Numeric fields may accept other encodings that convert losslessly, per TYPE-5. - HDR-3
guididentifies one logical file. Incremental writes, full saves, moving and renaming must not change it; "Save As" to a new logical file must generate a new UUID (VER-7). - HDR-4 The statistics fields are a snapshot. Incremental writes must not modify the Header (SAVE-20); a full save recalculates all statistics fields.
- HDR-5 Readers recompute state from the objects actually read. They must not reject a file because the snapshot disagrees with the actual content, and must not preallocate memory based on the counts in the snapshot.
Example
[0, 11, "5fe30f46-be92-49b6-b921-a60706febf10", 2, 1, 12, 1700000000]Fallback
When the Header is invalid (any HDR-2 check fails), readers must refuse to parse the file as UInk. There is no fallback.