{"id":21324127,"url":"https://github.com/mcejp/struktur","last_synced_at":"2026-01-03T00:13:25.693Z","repository":{"id":132598853,"uuid":"556232881","full_name":"mcejp/struktur","owner":"mcejp","description":"Cross-language data structures","archived":false,"fork":false,"pushed_at":"2022-10-23T12:02:33.000Z","size":3,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-09T01:29:41.363Z","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/mcejp.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":"2022-10-23T11:31:03.000Z","updated_at":"2022-10-23T11:31:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"ae9d5866-6ed9-4f27-845c-db96e66eb56d","html_url":"https://github.com/mcejp/struktur","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Fstruktur","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Fstruktur/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Fstruktur/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mcejp%2Fstruktur/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mcejp","download_url":"https://codeload.github.com/mcejp/struktur/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243802719,"owners_count":20350289,"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-11-21T20:28:46.631Z","updated_at":"2026-01-03T00:13:25.658Z","avatar_url":"https://github.com/mcejp.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# struktur\n\nThe real code is yet to be added -- how it works is that a generic language is first used to declare data structures:\n\n```scheme\n(struct Palette-RGB565\n  (palette-id   uint8)\n  (flags        uint8)\n  (colors       (array uint16 (length-prefix uint8)))\n  )\n\n(struct Checkerboard\n  (palette      Palette-RGB565)\n  (values       (array (array bool)))\n  )\n```\n\nIn a second step, C/C++ code is generated with native structure defintions and de/serialization code.\n\n```c++\nstruct Palette_RGB565 {\n    uint8_t palette_id;\n    uint8_t flags;\n    uint16_t colors[];\n};\n\nvoid Deserialize_Palette_RGB565(Palette_RGB565\u0026 output, std::span\u003cuint8_t const\u003e raw_bytes);\nvoid Serialize_Palette_RGB565(std::span\u003cuint8_t\u003e buffer, Palette_RGB565 const\u0026 input);\n```\n\nThanks to [Hy](https://hylang.org), the user-written definitions can also be directly imported as Python modules.\n\n```python\nimport hy, pathlib\nfrom my_structs import Palette_RGB565\n\npathlib.Path(\"palette.bin\").write_bytes(\n    Palette_RGB565(palette_id=23, flags=0xC0, colors=[0x0000, 0x5555, 0xAAAA, 0xFFFF]).tobytes()\n)\n```\n\nThe motivation for this project is to reduce repeated work when interoperating between Python and C++.\n\n#### Q: When would this be more appropriate than Protobuf/FlatBuffers/Cap'n Proto?\n\nA: When you need absolute minimum overhead.\nYou have full control over the \"wire layout\" and for fixed-size structures, they can be just `fread` directly into memory.\nThis is useful on tightly constrained platforms.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcejp%2Fstruktur","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmcejp%2Fstruktur","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmcejp%2Fstruktur/lists"}