{"id":16989601,"url":"https://github.com/didas-git/sbp","last_synced_at":"2025-07-24T17:15:44.632Z","repository":{"id":233186128,"uuid":"786242551","full_name":"Didas-git/sbp","owner":"Didas-git","description":null,"archived":false,"fork":false,"pushed_at":"2024-04-13T22:11:52.000Z","size":38,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-04-14T12:14:33.789Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Didas-git.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-04-13T21:10:27.000Z","updated_at":"2024-04-13T21:47:06.000Z","dependencies_parsed_at":null,"dependency_job_id":"aee7bbfc-9ebc-4b77-8aa1-163da4a5dcc4","html_url":"https://github.com/Didas-git/sbp","commit_stats":null,"previous_names":["didas-git/sbp"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fsbp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fsbp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fsbp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Didas-git%2Fsbp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Didas-git","download_url":"https://codeload.github.com/Didas-git/sbp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244898446,"owners_count":20528341,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-14T03:07:12.939Z","updated_at":"2025-03-22T03:10:20.527Z","avatar_url":"https://github.com/Didas-git.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SBP (Simple Binary Protocol)\n\nSBP as the name implies is a super simple to use an parse binary format.\n\nThe main compromises it makes are:\n- Simple to implement.\n- Fast to parse.\n\n## Protocol Description\n\nSBP is essentially a serialization protocol that seeks to provide a standardized way of encoding and decoding data in a fast form across multiple environments.\n\n## The Spec\n\n### Single Message Transmission (HTTP)\n\nFor protocols that send the payload all at once we can reduce the bandwidth and memory costs by just not having a length present and only having the necessary data.\n\n|                                         Version \u0026 Structure Type                                         | Optional identifier (Know structure only) |   Type   |      Data       |\n| :------------------------------------------------------------------------------------------------------: | :---------------------------------------: | :------: | :-------------: |\n| `1 byte`\u003cbr\u003e\u003cbr\u003eWhere:\u003cbr\u003eFirst 4 bits represent the version\u003cbr\u003eLast 4 bits represent the structure type |                 `1 byte`                  | `1 byte` | Everything else |\n\n### Chunked Transmission (TCP)\n\nFor transmission protocols that might send data chunked into pieces like it is the case for TCP the protocol adds 2 bytes of `length` information after the identifier (if it exists).\n\n|                                         Version \u0026 Structure Type                                         | Optional identifier (Know structure only) |  Length   |   Type   |        Data        |\n| :------------------------------------------------------------------------------------------------------: | :---------------------------------------: | :-------: | :------: | :----------------: |\n| `1 byte`\u003cbr\u003e\u003cbr\u003eWhere:\u003cbr\u003eFirst 4 bits represent the version\u003cbr\u003eLast 4 bits represent the structure type |                 `1 byte`                  | `2 bytes` | `1 byte` | `Length - 1 bytes` |\n \n\n## Structure Types\n\nCurrently the spec only has 2 structure types:\n\n- `Unknown` (`0x00`) - The data is sent with full type information and is up for the receiving end to properly parse the data.\n- `Known` (`0x01`) - The data is sent with the assumption you have a schema for the data with for the given identifier.\n\n\n## Data Types\n\n\u003e [!NOTE]\n\u003e All numeric data types are arranged in LE.\n\n### Basic Types\n\n|   Type    | Aliases                        | Identification Hex Byte | Details                                                                                        |\n| :-------: | ------------------------------ | :---------------------: | ---------------------------------------------------------------------------------------------- |\n|  `null`   | `void`                         |         `0x00`          | Always `0` (The value is optional, parsers can use the type to infer `null`)                   |\n|  `bool`   | `boolean`                      |         `0x01`          | [Boolean](https://en.wikipedia.org/wiki/Boolean_data_type) (either `0` or `1`)                 |\n|   `f16`   | `float16`, `binary16`          |         `0x11`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|   `f32`   | `float32`, `float`, `binary32` |         `0x12`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|   `f64`   | `float64`, `binary64`          |         `0x13`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|   `f80`   | `float80`                      |         `0x14`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|  `f128`   | `float128`, `binary128`        |         `0x15`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|   `u8`    | `uint8`, `byte`, `octet`       |         `0x20`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `u16`   | `uint16`, `ushort`             |         `0x21`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `u32`   | `uint32`, `uint`               |         `0x22`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `u64`   | `uint64`, `ulong`              |         `0x23`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|  `u128`   | `uint128`, `ucent`             |         `0x24`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `i8`    | `int8`, `sbyte`                |         `0x30`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `i16`   | `int16`, `short`, `small_int`  |         `0x31`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `i32`   | `int32`, `int`                 |         `0x32`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|   `i64`   | `int64`, `long`                |         `0x33`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n|  `i128`   | `int128`, `cent`               |         `0x34`          | [Integer](https://en.wikipedia.org/wiki/Integer_(computer_science)#Common_integral_data_types) |\n| `char(n)` | `character(n)`                 |         `0x40`          | [UTF-8](https://en.wikipedia.org/wiki/UTF-8) encoded string of length `n` (max: $2^{64} − 1$)  |\n|   `str`   | `string`                       |         `0x41`          | [UTF-8](https://en.wikipedia.org/wiki/UTF-8) encoded string of variable length                 |\n|   `d32`   | `decimal32`,                   |         `0x51`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|   `d64`   | `decimal64`,                   |         `0x52`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|  `d128`   | `decimal128`,                  |         `0x53`          | [IEEE 754](https://en.wikipedia.org/wiki/IEEE_754)                                             |\n|  `bint`   | `bigint`                       |         `0x70`          | Encoded as a string (for example the bigint `200` will take 3 bytes instead of 1)              |\n|  `buint`  | `biguint`                      |         `0x71`          | Same as `bint`                                                                                 |\n\n### Specialized Types\n\n|  Type   | Aliases          | Identification Hex Byte | Details                                                                      |\n| :-----: | ---------------- | :---------------------: | ---------------------------------------------------------------------------- |\n| `date`  | `datestamp`      |         `0xA0`          | [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)                           |\n| `time`  | `timestamp`      |         `0xA5`          | [Unix Time](https://en.wikipedia.org/wiki/Unix_time) in seconds (`i64`)      |\n| `mtime` | `ms_timestamp`   |         `0xA6`          | [Unix Time](https://en.wikipedia.org/wiki/Unix_time) in milliseconds (`i64`) |\n| `ntime` | `nano_timestamp` |         `0xA7`          | [Unix Time](https://en.wikipedia.org/wiki/Unix_time) in nanoseconds (`i128`) |\n\n## Structures\n\nCurrently structures are defined in json.\n\n\u003e [!IMPORTANT]\n\u003e Formal definition coming soon...\n\nTo see the current definition check out the [typescript types](./js/src/schema-definition.ts).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Fsbp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdidas-git%2Fsbp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdidas-git%2Fsbp/lists"}