{"id":13804545,"url":"https://github.com/msoucy/dproto","last_synced_at":"2026-01-21T02:01:52.749Z","repository":{"id":7537434,"uuid":"8889498","full_name":"msoucy/dproto","owner":"msoucy","description":"D Protocol Buffer mixins to create structures at compile time","archived":false,"fork":false,"pushed_at":"2020-05-02T23:36:33.000Z","size":274,"stargazers_count":37,"open_issues_count":26,"forks_count":16,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-07T07:19:34.367Z","etag":null,"topics":["d","dub","protocol-buffers"],"latest_commit_sha":null,"homepage":null,"language":"D","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/msoucy.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}},"created_at":"2013-03-19T21:18:29.000Z","updated_at":"2024-07-27T20:39:00.000Z","dependencies_parsed_at":"2022-07-09T20:17:10.649Z","dependency_job_id":null,"html_url":"https://github.com/msoucy/dproto","commit_stats":null,"previous_names":[],"tags_count":21,"template":false,"template_full_name":null,"purl":"pkg:github/msoucy/dproto","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoucy%2Fdproto","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoucy%2Fdproto/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoucy%2Fdproto/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoucy%2Fdproto/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/msoucy","download_url":"https://codeload.github.com/msoucy/dproto/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/msoucy%2Fdproto/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28622472,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-20T23:49:58.628Z","status":"online","status_checked_at":"2026-01-21T02:00:08.227Z","response_time":86,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["d","dub","protocol-buffers"],"created_at":"2024-08-04T01:00:49.848Z","updated_at":"2026-01-21T02:01:52.714Z","avatar_url":"https://github.com/msoucy.png","language":"D","funding_links":[],"categories":["Data serialization"],"sub_categories":["Binary Serilization"],"readme":"# D Protocol Buffers\n\n----\n\n[![Build Status](https://travis-ci.org/msoucy/dproto.svg?branch=master)](https://travis-ci.org/msoucy/dproto)\n[![Coverage Status](https://coveralls.io/repos/msoucy/dproto/badge.svg?branch=master)](https://coveralls.io/r/msoucy/dproto)\n[![DUB](https://img.shields.io/dub/dt/dproto/latest.svg)](http://code.dlang.org/packages/dproto)\n[![DUB license](https://img.shields.io/dub/l/dproto.svg)](http://code.dlang.org/packages/dproto)\n\nProtocol buffers are a language-agnostic way of specifying message structures to allow communication and serialization.\n\n`dproto` is designed to enable mixing protocol buffer files into your D code at compile time.\n\nInspiration and a good portion of the original parser is adapted from [square/protoparser](http://github.com/square/protoparser)\n\n----\n\n# Options\n\n`dproto` supports altering behavior via `protobuf` options:\n\n| Option                | Meaning                                                | Example                                      | Default |\n|-----------------------|--------------------------------------------------------|----------------------------------------------|---------|\n| `dproto_reserved_fmt` | The format for renaming reserved D keywords as fields. | `\"%s_\"` will convert `version` to `version_` | `\"%s_\"` |\n\n----\n\n# Examples\n\n[Further info](https://developers.google.com/protocol-buffers/docs/overview)\n\nExamples can be found in `import/dproto/dproto.d` and in `examples/`.\n\n## Simple Example\n\n```d\nimport std.stdio;\nimport dproto.dproto;\n\nmixin ProtocolBufferFromString!\"\n\tmessage Person {\n\t  required string name = 1;\n\t  required int32 id = 2;\n\t  optional string email = 3;\n\n\t  enum PhoneType {\n\t\tMOBILE = 0;\n\t\tHOME = 1;\n\t\tWORK = 2;\n\t  }\n\n\t  message PhoneNumber {\n\t\trequired string number = 1;\n\t\toptional PhoneType type = 2 [default = HOME];\n\t  }\n\n\t  repeated PhoneNumber phone = 4;\n\t}\n\";\n\n\nint main()\n{\n\tPerson person;\n\tperson.name = \"John Doe\";\n\tperson.id = 1234;\n\tperson.email = \"jdoe@example.com\";\n\n\tubyte[] serializedObject = person.serialize();\n\n\tPerson person2 = Person(serializedObject);\n\twriteln(\"Name: \", person2.name);\n\twriteln(\"E-mail: \", person2.email);\n\treturn 0;\n}\n```\n\n## More Complex Example\n\n```d\nimport dproto.dproto;\n\nmixin ProtocolBufferFromString!\"\n\tenum PhoneType {\n\t  MOBILE = 0;\n\t  HOME = 0;\n\t  WORK = 2;\n\t}\n\n\tmessage Person {\n\t  required string name = 1;\n\t  required int32 id = 2;\n\t  optional string email = 3;\n\n\t  message PhoneNumber {\n\t\trequired string number = 1;\n\t\toptional PhoneType type = 2 [default = HOME];\n\t  }\n\n\t  repeated PhoneNumber phone = 4;\n\t}\n\n\tmessage AddressBook {\n\t  repeated Person person = 1;\n\t}\n\";\n\n\nint main()\n{\n\tPerson t;\n\tt.name = \"Max Musterman\";\n\tt.id = 3;\n\tt.email = \"test@example.com\";\n\n\tPerson.PhoneNumber pn1;\n\tpn1.number = \"0123456789\";\n\tpn1.type = PhoneType.WORK;\n\n\tPerson.PhoneNumber pn2;\n\tpn2.number = \"0123456789\";\n\n\tt.phone = [pn1, pn2];\n\tAddressBook addressbook;\n\taddressbook.person ~= t;\n\taddressbook.person ~= t;\n\n\tubyte[] serializedObject = addressbook.serialize();\n\n\tAddressBook addressbook2 = AddressBook(serializedObject);\n\tassert(addressbook2.person.length == 2);\n\tforeach(t2; addressbook2.person)\n\t{\n\t\tassert(t2.name == \"Max Musterman\");\n\t\tassert(t2.id == 3);\n\t\tassert(t2.email == \"test@example.com\");\n\t\tassert(t2.email !is null);\n\t\tassert(t2.phone[0].number == \"0123456789\");\n\t\tassert(t2.phone[0].type == PhoneType.WORK);\n\t\tassert(t2.phone[1].number == \"0123456789\");\n\t\tassert(t2.phone[1].type == PhoneType.HOME);\n\t\tassert(t2.phone[1].type == PhoneType.MOBILE);\n\t\tassert(t2.phone.length == 2);\n\t}\n\tversion(DigitalMars)\n\t{\n\t\tassert(addressbook2.person[0] == addressbook.person[1]);\n\t}\n\treturn 0;\n}\n```\n\n\n## Services\n\nGenerate interfaces for service definitions.\n\n```d\nimport dproto.dproto;\n\nmixin ProtocolBufferInterface!\"\n\tmessage ServiceRequest {\n\t\tstring request = 1;\n\t}\n\tmessage ServiceResponse {\n\t\tstring response = 1;\n\t}\n\tservice TestService {\n\t\trpc TestMethod (ServiceRequest) returns (ServiceResponse);\n\t}\n\";\n\nclass ServiceImplementation : TestService {\n\tServiceResponse TestMethod(ServiceRequest input) {\n\t\tServiceResponse output;\n\t\toutput.response = \"received: \" ~ input.request;\n\t\treturn output;\n\t}\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsoucy%2Fdproto","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmsoucy%2Fdproto","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmsoucy%2Fdproto/lists"}