{"id":13626607,"url":"https://github.com/Arwalk/zig-protobuf","last_synced_at":"2025-04-16T14:34:12.655Z","repository":{"id":46647784,"uuid":"363194009","full_name":"Arwalk/zig-protobuf","owner":"Arwalk","description":"a protobuf 3 implementation for zig.","archived":false,"fork":false,"pushed_at":"2024-11-02T13:08:21.000Z","size":745,"stargazers_count":233,"open_issues_count":20,"forks_count":27,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-11-05T07:34:23.519Z","etag":null,"topics":["protobuf","zig","zig-package"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/Arwalk.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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":"2021-04-30T16:11:03.000Z","updated_at":"2024-11-03T20:57:18.000Z","dependencies_parsed_at":"2024-01-01T13:53:46.294Z","dependency_job_id":"88e076c5-114a-46d4-8b73-468b917f9718","html_url":"https://github.com/Arwalk/zig-protobuf","commit_stats":{"total_commits":174,"total_committers":15,"mean_commits":11.6,"dds":0.6379310344827587,"last_synced_commit":"1240df8142aca47d782c5de5e8f6a31c97ffc328"},"previous_names":[],"tags_count":9,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arwalk%2Fzig-protobuf","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arwalk%2Fzig-protobuf/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arwalk%2Fzig-protobuf/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Arwalk%2Fzig-protobuf/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Arwalk","download_url":"https://codeload.github.com/Arwalk/zig-protobuf/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":223716631,"owners_count":17191080,"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":["protobuf","zig","zig-package"],"created_at":"2024-08-01T21:02:24.765Z","updated_at":"2025-04-16T14:34:12.648Z","avatar_url":"https://github.com/Arwalk.png","language":"Zig","funding_links":["https://ko-fi.com/N4N7VMS4F"],"categories":["Zig","Applications","Language Essentials"],"sub_categories":["File Format Processing"],"readme":"# zig-protobuf\n\n-------\n\n## Welcome!\n\nThis is an implementation of google Protocol Buffers version 3 in Zig.\n\nProtocol Buffers is a serialization protocol so systems, from any programming language or platform, can exchange data reliably.\n\nProtobuf's strength lies in a generic codec paired with user-defined \"messages\" that will define the true nature of the data encoded.\n\nMessages are usually mapped to a native language's structure/class definition thanks to a language-specific generator associated with an implementation.\n\nZig's compile-time evaluation becomes extremely strong and useful in this context: because the structure (a message) has to be known beforehand, the generic codec can leverage informations, at compile time, of the message and it's nature. This allows optimizations that are hard to get as easily in any other language, as Zig can mix compile-time informations with runtime-only data to optimize the encoding and decoding code paths.\n\n## State of the implementation\n\nThis repository, so far, only aims at implementing [protocol buffers version 3](https://developers.google.com/protocol-buffers/docs/proto3#simple).\n\nThe latest version of the zig compiler used for this project is 0.14.0.\n\nThis project is currently able to handle all scalar types for encoding, decoding, and generation through the plugin.\n\n## Branches\n\nThere are 2 branches you can use for your development.\n\n* `master` is the branch with current developments, working with the latest stable release of zig.\n* `zig-master` is a branch that merges the developments in master, but works with the latest-ish master version of zig. \n\n## How to use\n\n1. Add `protobuf` to your `build.zig.zon`.  \n    ```sh\n    zig fetch --save \"git+https://github.com/Arwalk/zig-protobuf#v2.0.0\"\n    ```\n1. Use the `protobuf` module. In your `build.zig`'s build function, add the dependency as module before\n`b.installArtifact(exe)`.\n    ```zig\n    pub fn build(b: *std.Build) !void {\n        // first create a build for the dependency\n        const protobuf_dep = b.dependency(\"protobuf\", .{\n            .target = target,\n            .optimize = optimize,\n        });\n\n        // and lastly use the dependency as a module\n        exe.root_module.addImport(\"protobuf\", protobuf_dep.module(\"protobuf\"));\n    }\n    ```\n\n## Generating .zig files out of .proto definitions\n\nYou can do this programatically as a compilation step for your application. The following snippet shows how to create a `zig build gen-proto` command for your project.\n\n```zig\nconst protobuf = @import(\"protobuf\");\n\npub fn build(b: *std.Build) !void {\n    // first create a build for the dependency\n    const protobuf_dep = b.dependency(\"protobuf\", .{\n        .target = target,\n        .optimize = optimize,\n    });\n    \n    ...\n\n    const gen_proto = b.step(\"gen-proto\", \"generates zig files from protocol buffer definitions\");\n\n    const protoc_step = protobuf.RunProtocStep.create(b, protobuf_dep.builder, target, .{\n        // out directory for the generated zig files\n        .destination_directory = b.path(\"src/proto\"),\n        .source_files = \u0026.{\n            \"protocol/all.proto\",\n        },\n        .include_directories = \u0026.{},\n    });\n\n    gen_proto.dependOn(\u0026protoc_step.step);\n}\n```\n\nIf you're really bored, you can buy me a coffe here.\n\n[![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/N4N7VMS4F)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArwalk%2Fzig-protobuf","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FArwalk%2Fzig-protobuf","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FArwalk%2Fzig-protobuf/lists"}