{"id":21193473,"url":"https://github.com/zigcc/zig-msgpack","last_synced_at":"2025-07-10T03:32:37.385Z","repository":{"id":217346362,"uuid":"740010263","full_name":"zigcc/zig-msgpack","owner":"zigcc","description":"zig messagpack implementation / msgpack.org[zig]","archived":false,"fork":false,"pushed_at":"2024-07-19T15:00:24.000Z","size":105,"stargazers_count":19,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-07-19T17:53:37.090Z","etag":null,"topics":["msgpack","msgpack-rpc","zig","zig-package"],"latest_commit_sha":null,"homepage":"https://ziglang.cc/zig-msgpack/","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/zigcc.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":"2024-01-07T08:35:23.000Z","updated_at":"2024-07-19T14:58:59.000Z","dependencies_parsed_at":"2024-05-04T12:27:43.895Z","dependency_job_id":"f2955122-438d-455a-a307-6ac6aa02e697","html_url":"https://github.com/zigcc/zig-msgpack","commit_stats":null,"previous_names":["zigcc/zig-msgpack"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigcc%2Fzig-msgpack","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigcc%2Fzig-msgpack/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigcc%2Fzig-msgpack/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zigcc%2Fzig-msgpack/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zigcc","download_url":"https://codeload.github.com/zigcc/zig-msgpack/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225615166,"owners_count":17496946,"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":["msgpack","msgpack-rpc","zig","zig-package"],"created_at":"2024-11-20T19:14:30.774Z","updated_at":"2025-07-10T03:32:37.348Z","avatar_url":"https://github.com/zigcc.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# zig-msgpack\n\n[![CI](https://github.com/zigcc/zig-msgpack/actions/workflows/ci.yml/badge.svg)](https://github.com/zigcc/zig-msgpack/actions/workflows/ci.yml)\n\nA MessagePack implementation for the Zig programming language. This library provides a simple and efficient way to serialize and deserialize data using the MessagePack format.\n\nAn article introducing it: [Zig Msgpack](https://blog.nvimer.org/2025/05/03/zig-msgpack/)\n\n## Features\n\n- **Full MessagePack Support:** Implements all MessagePack types (except for the timestamp extension).\n- **Efficient:** Designed for high performance with minimal memory overhead.\n- **Type-Safe:** Leverages Zig's type system to ensure safety during serialization and deserialization.\n- **Simple API:** Offers a straightforward and easy-to-use API for encoding and decoding.\n\n## Installation\n\n\u003e For Zig 0.13 and older versions, please use version `0.0.6` of this library.\n\nFor Zig `0.14.0` and `nightly`, follow these steps:\n\n1.  **Add as a dependency:**\n    Add the library to your `build.zig.zon` file. You can fetch a specific commit or branch.\n\n    ```sh\n    zig fetch --save https://github.com/zigcc/zig-msgpack/archive/{COMMIT_OR_BRANCH}.tar.gz\n    ```\n\n2.  **Configure your `build.zig`:**\n    Add the `zig-msgpack` module to your executable.\n\n    ```zig\n    const std = @import(\"std\");\n\n    pub fn build(b: *std.Build) void {\n        const target = b.standardTargetOptions(.{});\n        const optimize = b.standardOptimizeOption(.{});\n\n        const exe = b.addExecutable(.{\n            .name = \"my-app\",\n            .root_source_file = .{ .path = \"src/main.zig\" },\n            .target = target,\n            .optimize = optimize,\n        });\n\n        const msgpack_dep = b.dependency(\"zig_msgpack\", .{\n            .target = target,\n            .optimize = optimize,\n        });\n\n        exe.root_module.addImport(\"msgpack\", msgpack_dep.module(\"msgpack\"));\n\n        b.installArtifact(exe);\n    }\n    ```\n\n## Usage\n\nHere is a simple example of how to encode and decode a `Payload`:\n\n```zig\nconst std = @import(\"std\");\nconst msgpack = @import(\"msgpack\");\nconst allocator = std.testing.allocator;\n\npub fn main() !void {\n    var buffer: [1024]u8 = undefined;\n    var stream = std.io.fixedBufferStream(\u0026buffer);\n\n    var packer = msgpack.Pack(\n        *std.io.FixedBufferStream([]u8),\n        *std.io.FixedBufferStream([]u8),\n        std.io.FixedBufferStream([]u8).WriteError,\n        std.io.FixedBufferStream([]u8).ReadError,\n        std.io.FixedBufferStream([]u8).write,\n        std.io.FixedBufferStream([]u8).read,\n    ).init(\u0026stream, \u0026stream);\n\n    // Create a map payload\n    var map = msgpack.Payload.mapPayload(allocator);\n    defer map.free(allocator);\n\n    try map.mapPut(\"message\", try msgpack.Payload.strToPayload(\"Hello, MessagePack!\", allocator));\n    try map.mapPut(\"version\", msgpack.Payload.uintToPayload(1));\n\n    // Encode\n    try packer.write(map);\n\n    // Reset stream for reading\n    stream.pos = 0;\n\n    // Decode\n    const decoded_payload = try packer.read(allocator);\n    defer decoded_payload.free(allocator);\n\n    // Use the decoded data\n    const message = (try decoded_payload.mapGet(\"message\")).?.str.value();\n    const version = (try decoded_payload.mapGet(\"version\")).?.uint;\n\n    std.debug.print(\"Message: {s}, Version: {d}\n\", .{ message, version });\n}\n```\n\n## API Overview\n\n-   **`msgpack.Pack`**: The main struct for packing and unpacking MessagePack data. It is initialized with read and write contexts.\n-   **`msgpack.Payload`**: A union that represents any MessagePack type. It provides methods for creating and interacting with different data types (e.g., `mapPayload`, `strToPayload`, `mapGet`).\n\n## Testing\n\nTo run the unit tests for this library, use the following command:\n\n```sh\nzig build test\n```\n\n## Contributing\n\nContributions are welcome! Please feel free to open an issue or submit a pull request.\n\n## Related Projects\n\n-   [getty-msgpack](https://git.mzte.de/LordMZTE/getty-msgpack)\n-   [znvim](https://github.com/jinzhongjia/znvim)\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigcc%2Fzig-msgpack","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzigcc%2Fzig-msgpack","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigcc%2Fzig-msgpack/lists"}