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 daletl data. DaletPack is designed specifically to transfer as little data as possible, it compresses the declaration of tag types into the smallest possible volume. Nothing unnecessary is transferred.
2024-07-27 23:08:24 +03:00
All data must be compressed with [zstd ](https://datatracker.ietf.org/doc/html/rfc8878 ).
2024-07-27 17:44:34 +03:00
2024-07-27 23:08:24 +03:00
Root data format is array of tags (see [daletl specification ](./daletl.md )), each element reads sequentially. Type definition for root is not needed.
2024-07-27 19:11:11 +03:00
2024-07-27 23:08:24 +03:00
Mime type: `application/dalet-pack`
## Types
2024-07-27 17:44:34 +03:00
2024-08-01 15:51:59 +03:00
- **Integer** (2)
2024-07-27 23:08:24 +03:00
- **String** (5)
- **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
2024-08-01 15:51:59 +03:00
- a value of integer must be between 0 and 255
2024-07-27 23:08:24 +03:00
- 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
2024-07-27 23:08:24 +03:00
- maximum number of elements of a tag array object is (2^32)
2024-07-27 17:44:34 +03:00
## Formats
### Overview
| name | id | id-bits |
| ------------------------ | --- | ------- |
2024-08-01 15:51:59 +03:00
| int 4 | 0 | 0000 |
| int 8 | 1 | 0001 |
2024-07-27 17:44:34 +03:00
| str 3 | 2 | 0010 |
| str 4 | 3 | 0011 |
2024-07-27 19:11:11 +03:00
| str 8 | 4 | 0100 |
| str 16 | 5 | 0101 |
| str 32 | 6 | 0110 |
2024-07-27 23:08:24 +03:00
| tag array | 7 | 0111 |
| tag array end | no | 10 |
2024-07-27 19:11:11 +03:00
| tag (id) | 12 | 1100 |
| tag (id, body) | 13 | 1101 |
| tag (id, argument) | 14 | 1110 |
2024-07-27 17:44:34 +03:00
| tag (id, body, argument) | 15 | 1111 |
2024-07-27 18:35:50 +03:00
### Notation in diagrams
```txt
block of bits (max 8 bits):
+--------+
| |
+--------+
a variable number of bytes:
+========+
| |
+========+
variable number of objects stored in DaletPack format:
+~~~~~~~~~~~~~~~~~+
| |
+~~~~~~~~~~~~~~~~~+
2024-08-01 15:51:59 +03:00
X - unknown bit
2024-07-27 18:35:50 +03:00
```
### Integer format
```txt
2024-07-27 18:39:56 +03:00
+--------+------+
2024-08-01 15:51:59 +03:00
| 0000 | XXXX |
2024-07-27 18:39:56 +03:00
+--------+------+
2024-08-01 15:51:59 +03:00
+--------+----------+
| 0001 | XXXXXXXX |
+--------+----------+
2024-07-27 18:35:50 +03:00
```
### String format
```txt
2024-07-27 23:08:24 +03:00
str 3 (up to 8 bytes):
+--------+-----+=========+
| 0010 | XXX | utf-8 |
2024-08-01 15:51:59 +03:00
+--------+-----+=========+
2024-07-27 18:35:50 +03:00
2024-07-27 23:08:24 +03:00
str 4 (up to 16 bytes):
+--------+------+=========+
| 0011 | XXXX | utf-8 |
+--------+------+=========+
str 8 (up to 256 bytes):
+--------+----------+=========+
| 0100 | XXXXXXXX | utf-8 |
+--------+----------+=========+
str 16 (up to 2^16 bytes):
+--------+----------+----------+=========+
| 0101 | XXXXXXXX | XXXXXXXX | utf-8 |
+--------+----------+----------+=========+
str 32 (up to 2^32 bytes):
+--------+----------+----------+----------+----------+=========+
| 0110 | XXXXXXXX | XXXXXXXX | XXXXXXXX | XXXXXXXX | utf-8 |
+--------+----------+----------+----------+----------+=========+
2024-07-27 18:35:50 +03:00
```
2024-07-27 23:08:24 +03:00
### Tag array format
2024-07-27 18:35:50 +03:00
```txt
2024-07-27 23:08:24 +03:00
tag array:
+--------+~~~~~~~~~~~~+------+
| 0111 | elements | 10 |
+--------+~~~~~~~~~~~~+------+
2024-07-27 18:35:50 +03:00
```
### Tag format
```txt
2024-07-27 23:08:24 +03:00
id = XXXXX (5 bits) (can change before release)
2024-07-27 18:35:50 +03:00
tag (id):
2024-07-27 23:08:24 +03:00
+--------+----+
| 1100 | id |
+--------+----+
2024-07-27 18:35:50 +03:00
tag (id, body):
2024-07-27 23:08:24 +03:00
+--------+----+~~~~~~~~+
| 1101 | id | body |
+--------+----+~~~~~~~~+
2024-07-27 18:35:50 +03:00
2024-07-27 19:11:11 +03:00
tag (id, argument):
2024-07-27 23:08:24 +03:00
+--------+----+~~~~~~~~~~~~+
| 1110 | id | argument |
+--------+----+~~~~~~~~~~~~+
2024-07-27 19:11:11 +03:00
2024-07-27 18:35:50 +03:00
tag (id, body, argument):
2024-07-27 23:08:24 +03:00
+--------+----+~~~~~~~~+~~~~~~~~~~~~+
| 1111 | id | body | argument |
+--------+----+~~~~~~~~+~~~~~~~~~~~~+
2024-07-27 18:35:50 +03:00
```