{"id":14990824,"url":"https://github.com/r4gus/uuid-zig","last_synced_at":"2025-06-27T14:05:32.557Z","repository":{"id":118776248,"uuid":"559364360","full_name":"r4gus/uuid-zig","owner":"r4gus","description":"A UUID library written in Zig","archived":false,"fork":false,"pushed_at":"2025-03-20T09:16:19.000Z","size":2062,"stargazers_count":24,"open_issues_count":0,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-12T03:28:47.197Z","etag":null,"topics":["c-library","guid","library","rfc4122","uuid","uuid-v4","uuid-v7","uuidv4","uuidv7","zig","zig-lang","ziglang"],"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/r4gus.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,"zenodo":null}},"created_at":"2022-10-29T22:05:18.000Z","updated_at":"2025-03-20T09:15:30.000Z","dependencies_parsed_at":null,"dependency_job_id":"77d3466e-63a6-4085-b161-77deb22abfd4","html_url":"https://github.com/r4gus/uuid-zig","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/r4gus/uuid-zig","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fuuid-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fuuid-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fuuid-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fuuid-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/r4gus","download_url":"https://codeload.github.com/r4gus/uuid-zig/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/r4gus%2Fuuid-zig/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262269903,"owners_count":23285159,"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":["c-library","guid","library","rfc4122","uuid","uuid-v4","uuid-v7","uuidv4","uuidv7","zig","zig-lang","ziglang"],"created_at":"2024-09-24T14:20:55.012Z","updated_at":"2025-06-27T14:05:32.534Z","avatar_url":"https://github.com/r4gus.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# UUID Zig\n\nUniversally Unique IDentifiers (UUIDs) are 128 bit long IDs that do not require a central\nregistration process.\n\nVersions:\n\n| Zig version | uuid-zig version |\n|:-----------:|:----------------:|\n| 13.0        | 2.0, 2.1         |\n| 14.0        | 3.0              |\n\nTo add the `uuid-zig` package to your `build.zig.zon` run:\n\n```\n# Replace \u003cVERSION TAG\u003e with the version you want to use\nzig fetch --save https://github.com/r4gus/uuid-zig/archive/refs/tags/\u003cVERSION TAG\u003e.tar.gz\n\n// e.g., zig fetch --save https://github.com/r4gus/uuid-zig/archive/refs/tags/0.3.0.tar.gz\n```\n\n## Getting started\n\nTo generate a version 4 (random) UUID you can use:\n\n```zig\nconst uuid = @import(\"uuid\");\n\nconst id = uuid.v4.new();\n```\n\nYou can serialize a UUID into a URN:\n\n```zig\nconst uuid = @import(\"uuid\");\n\nconst id = uuid.v7.new();\n\nconst urn = uuid.urn.serialize(id);\n```\n\nYou can also parse URNs (UUID strings):\n\n```zig\nconst uuid = @import(\"uuid\");\n\nconst id = try uuid.urn.deserialize(\"6ba7b811-9dad-11d1-80b4-00c04fd430c8\");\n```\n\n## Which UUID version should I use?\n\nConsider version 4 (`v4`) UUIDs if you just need unique identifiers and version 7 (`v7`)\nif you want to use UUIDs as database keys or need to sort them.\n\n### Supported versions\n\n* `v4` - UUIDs using random data.\n* `v7` - UUIDs using a Epoch timestamp in combination with random data.\n\n## Encoding\n\nThis library encodes UUIDs in big-endian format, e.g. `00112233-4455-6677-8899-aabbccddeeff`\nis encoded as `00 11 22 33 44 55 66 77 88 99 aa bb cc dd ee ff` where `00` is the least and\n`ff` is the most significant byte (see [RFC4122 4.1.2 Layout and Byte Order](https://datatracker.ietf.org/doc/html/rfc4122#section-4.1.2)).\n\n## C Library\n\nRun `zig build -Doptimize=ReleaseFast` to build the C-Library. You will find the library in `zig-out/lib` and the header in `zig-out/include`.\n\nYou can find a C-example in the examples folder.\n\n## Benchmark\n\nTo run a simple benchmark execute:\n\n```\nzig build bench -- 10000000 v7\n```\n\nExample: ThinkPad X1 Yoga 3rd with an i7-8550U\n\n```\nv4: 10000000 UUIDs in 595.063ms\nv7: 10000000 UUIDs in 892.564ms\n```\n\nExample: Macbook Pro with M3 Pro\n\n```\nv4: 10000000 UUIDs in 1.666s\nv7: 10000000 UUIDs in 546.736ms\n```\n\n## References\n\n* [RFC4122: A Universally Unique IDentifier (UUID) URN Namespace](https://datatracker.ietf.org/doc/html/rfc4122)\n* [New UUID Formats: draft-peabody-dispatch-new-uuid-format-04](https://datatracker.ietf.org/doc/html/draft-peabody-dispatch-new-uuid-format)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4gus%2Fuuid-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fr4gus%2Fuuid-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fr4gus%2Fuuid-zig/lists"}