dalet/specification/daletpack.md

121 lines
2.5 KiB
Markdown
Raw Normal View History

2024-07-27 17:44:34 +03:00
# DaletPack specification for Dalet v1.0-preview
DaletPack is an binary data format for Dalet, that is used for minimizing the size of transmitted data. DaletPack is designed specifically to transfer as little data as possible, it compresses the declaration of tag types into the optimal possible volume.
2024-08-01 15:57:20 +03:00
All apps that supports Dalet must use this format when transmitting data between hosts.
2024-07-27 17:44:34 +03:00
All data must be compressed with [zstd](https://datatracker.ietf.org/doc/html/rfc8878).
2024-07-27 17:44:34 +03:00
Page data format is array of tags (see [daletl specification](./daletl.md)), each element reads sequentially. Type definition for page is not needed.
Mime type: `application/dalet-pack`
## Types
2024-07-27 17:44:34 +03:00
- **Integer**
- **String** (3)
- **Tag array**
- **Tags** (4)
- **Tag (id)**
- **Tag (id, body)**
- **Tag (id, argument)**
- **Tag (id, body, argument)**
2024-07-27 17:44:34 +03:00
## Limitations
- a value of integer must be between 0 and 255
- maximum byte size of a String object is (2^32)
2024-07-27 17:44:34 +03:00
- string must be encoded in UTF-8
- maximum number of elements of a tag array object is (2^32)
2024-07-27 17:44:34 +03:00
## Formats
### Overview
| name | id |
| ------------------------ | --- |
| str end | 0 |
| str | 1 |
| int | 2 |
| tag array | 3 |
| tag array end | 4 |
| tag (id) | 5 |
| tag (id, body) | 6 |
| tag (id, argument) | 7 |
| tag (id, body, argument) | 8 |
2024-07-27 18:35:50 +03:00
### Notation in diagrams
```txt
byte:
2024-07-27 18:35:50 +03:00
+--------+
| |
+--------+
a variable number of bytes:
+========+
| |
+========+
variable number of objects stored in DaletPack format:
+~~~~~~~~~~~~~~~~~+
| |
+~~~~~~~~~~~~~~~~~+
X - unknown bit
2024-07-27 18:35:50 +03:00
```
### Str format
2024-07-27 18:35:50 +03:00
```txt
str:
+--------+=========+--------+
| 1 | utf-8 | 0 |
+--------+=========+--------+
2024-07-27 18:35:50 +03:00
```
### Int format
2024-07-27 18:35:50 +03:00
```txt
+--------+----------+
| 1 | XXXXXXXX |
+--------+----------+
2024-07-27 18:35:50 +03:00
```
### Tag array format
2024-07-27 18:35:50 +03:00
```txt
tag array:
+--------+~~~~~~~~~~~~+------+
| 3 | elements | 4 |
+--------+~~~~~~~~~~~~+------+
2024-07-27 18:35:50 +03:00
```
### Tag format
```txt
id = XXXXX (5 bits) (can change before release)
2024-07-27 18:35:50 +03:00
tag (id):
+--------+----+
| 5 | id |
+--------+----+
2024-07-27 18:35:50 +03:00
tag (id, body):
+--------+----+~~~~~~~~+
| 6 | id | body |
+--------+----+~~~~~~~~+
2024-07-27 18:35:50 +03:00
tag (id, argument):
+--------+----+~~~~~~~~~~~~+
| 7 | id | argument |
+--------+----+~~~~~~~~~~~~+
2024-07-27 18:35:50 +03:00
tag (id, body, argument):
+--------+----+~~~~~~~~+~~~~~~~~~~~~+
| 8 | id | body | argument |
+--------+----+~~~~~~~~+~~~~~~~~~~~~+
2024-07-27 18:35:50 +03:00
```