{"id":18892397,"url":"https://github.com/hf/cupcake","last_synced_at":"2026-02-08T01:31:55.081Z","repository":{"id":143824589,"uuid":"113586367","full_name":"hf/cupcake","owner":"hf","description":"A simple message container and implementation.","archived":false,"fork":false,"pushed_at":"2017-12-08T15:07:16.000Z","size":2,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-07-20T05:53:28.526Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":null,"has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-12-08T15:06:23.000Z","updated_at":"2025-04-29T11:38:36.000Z","dependencies_parsed_at":null,"dependency_job_id":"9c49092f-138a-4ac1-9ff8-7b65b70ccbbf","html_url":"https://github.com/hf/cupcake","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hf/cupcake","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fcupcake","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fcupcake/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fcupcake/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fcupcake/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hf","download_url":"https://codeload.github.com/hf/cupcake/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hf%2Fcupcake/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29216084,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-08T00:10:47.190Z","status":"ssl_error","status_checked_at":"2026-02-08T00:10:43.589Z","response_time":63,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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-11-08T08:01:56.225Z","updated_at":"2026-02-08T01:31:55.067Z","avatar_url":"https://github.com/hf.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"Cupcake\n=======\n\nCupcake is a simple binary message format, and an implementation in Rust. \n\n## Motivation\n\nThere are a lot of ways to serialize a message. You can concatenate bytes. You\ncan use JSON (no!). You can use protocol buffers; or the latest fad flat\nbuffers. You can use MessagePack, BSON, CBOR... The list goes on...\n\nHowever, all of these formats have their uses, mostly in business-level code.\nThey become difficult to use as a container for more generic messages. They\nusually have some form of \"parsing\" or non-trivial computational overhead in\naccessing parts of the message. Not all are good with binary data (JSON!).\n\nCupcake aims to solve these issues and be a container format of sorts. You\nshould put your JSON in a Cupcake, but a Cupcake is not a JSON!\n\n## Spec\n\nYes. In a README. That simple.\n\n### Version 1\n\n#### Definitions\n\n - byte: 8 bits, smallest addressable value\n - magic: cupcake magic bytes, `0xF9 0xC9`\n - version: cupcake version, a single byte, fixed value `0x01`\n - tag: user defined tag value, a single byte\n - slice: a string of bytes, up to 255 bytes long\n - slices: a group of slices, up to 255 slices per message\n - slice-size: a single byte, describing the size of a slice\n - extension: a string of bytes, up to 4294967296 (2^32) bytes long\n - extension-size: a string of 4 bytes, describing the size of the extension\n\n#### Layout\n\nA Cupcake message is laid out like so:\n\n```\n0:                            [0xF9] \n1:                            [0xC9] \n2:                            [0x01] \n3:                            [tag] \n4:                            [slices] \n5:                            [extension-size-3] \n6:                            [extension-size-2]\n7:                            [extension-size-1]\n8:                            [extension-size-0]\n9:                            { [slice-size:0] ... [slice-size:255] }\n9 + slices:                   { slice:0 } ... { slice:255 }\n9 + slices + sum(slice-size): { extension }\n```\n\nWhere `[name]` corresponds to a single byte; `{ name }` corresponds to a\nsequence of bytes.\n\n#### Validation\n\nA Cupcake message (`msg` of length `n`) is valid if and only if: \n\n 1. `n \u003e= 9`\n 2. `0xF9 == msg[0]`\n 3. `0xC9 == msg[1]`\n 4. `0x01 == msg[2]`\n 5. `let total_slice_size = sum(msg[9 + i]) where i in (0 upto msg[4])`\n 6. `let extension_size = (msg[5] \u003c\u003c (8*3)) | (msg[6] \u003c\u003c (8*2)) | (msg[7] \u003c\u003c (8*1)) | (msg[8] \u003c\u003c (8*0))`\n 7. `n == 9 + total_slice_size + extension_size`\n\n#### Access\n\nA Cupcake message (`msg` of length `n`) can be accessed only if valid, with the\nfollowing formulas:\n\n**Access the i-th slice**\n\nAssumes that `i \u003c slices`.\n\n```\nslice_i_offset := 9 + msg[4] + (sum(msg[9 + j]) where j in (0 upto i))\nslice_i_length := msg[9 + i]\n```\n\n**Access the extension data**\n\n```\nextension_offset := 9 + msg[4] + (sum(msg[9 + i]) where i in (0 upto msg[4]))\nextension_length := (msg[5] \u003c\u003c (8*3)) | (msg[6] \u003c\u003c (8*2)) | (msg[7] \u003c\u003c (8*1)) | (msg[8] \u003c\u003c (8*0))\n```\n\n## License\n\nThis distribution is Copyright \u0026copy; 2017 Stojan Dimitrovski. It is licensed\nunder the MIT license. You can find the full text under `LICENSE`.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fcupcake","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhf%2Fcupcake","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhf%2Fcupcake/lists"}