dalet/specification/daletpack.md

98 lines
2 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
2024-09-24 22:35:23 +03:00
Notation:
`(id, [body_type], [argument_type]) [hex_id]`
2024-08-17 22:59:41 +03:00
- Tags with body
2024-09-24 22:35:23 +03:00
- (id, text) [**a0**]
- (id, tag) [**a1**]
- (id, tags) [**a2**]
2024-08-17 22:59:41 +03:00
- Tags with argument
2024-09-24 22:35:23 +03:00
- (id, text) [**b0**]
- (id, number) [**b1**]
2024-08-17 22:59:41 +03:00
- Complex tags
2024-09-24 22:35:23 +03:00
- (id, text, text) [**c0**]
- (id, tag, text) [**c1**]
- (id, tags, text) [**c2**]
- (id, text, number) [**c3**]
- (id, tag, number) [**c4**]
- (id, tags, number) [**c5**]
2024-07-27 17:44:34 +03:00
## Limitations
2024-08-07 12:11:12 +03:00
- a value of number must be between 0 and 255 and be integer
- maximum byte size of a text is (2^32)
- text 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
2024-08-17 22:59:41 +03:00
## Binary representation
2024-07-27 17:44:34 +03:00
2024-08-17 22:59:41 +03:00
### Special symbols
2024-07-27 17:44:34 +03:00
2024-08-17 22:59:41 +03:00
| name | hex_id |
| ------------------------ | ------- |
| text end | 00 |
| tags end | 01 |
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
### Format
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
#### Notation
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
Byte - `+----+`
2024-09-01 10:47:06 +03:00
2024-08-17 22:59:41 +03:00
Variable length of bytes - `+====+`
2024-09-01 10:47:06 +03:00
2024-08-17 22:59:41 +03:00
Variable number of data objects - `+~~~~+`
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
#### Overview
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
##### Tag data
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
Look into types.
`type_name (...data) [hex_id]`
becomes
2024-07-27 18:35:50 +03:00
```txt
2024-08-17 22:59:41 +03:00
+--------+~~~~~~~~~+
| hex_id | ...data |
+--------+~~~~~~~~~+
2024-07-27 18:35:50 +03:00
```
2024-08-17 22:59:41 +03:00
##### Number data
2024-07-27 18:35:50 +03:00
```txt
2024-08-17 22:59:41 +03:00
+---------------+
| 8-bit integer |
+---------------+
```
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
##### Text data
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
```txt
+=============+----+
| utf-8 bytes | 00 |
+=============+----+
```
2024-07-27 18:35:50 +03:00
2024-08-17 22:59:41 +03:00
##### Tags data
2024-08-17 22:59:41 +03:00
```txt
+~~~~~~+----+
| tags | 01 |
+~~~~~~+----+
2024-07-27 18:35:50 +03:00
```