{"id":22833109,"url":"https://github.com/lithdew/bincode-zig","last_synced_at":"2025-06-15T06:38:11.934Z","repository":{"id":107949375,"uuid":"509018905","full_name":"lithdew/bincode-zig","owner":"lithdew","description":"A Zig implementation of the Bincode binary format specification.","archived":false,"fork":false,"pushed_at":"2024-06-27T16:24:22.000Z","size":19,"stargazers_count":8,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2025-04-23T22:03:59.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/lithdew.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-06-30T09:38:29.000Z","updated_at":"2025-01-19T09:41:58.000Z","dependencies_parsed_at":"2024-06-27T19:43:03.762Z","dependency_job_id":"7f7bb88e-ad4d-4007-abc3-048ff3daf3df","html_url":"https://github.com/lithdew/bincode-zig","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/lithdew%2Fbincode-zig","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fbincode-zig/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fbincode-zig/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lithdew%2Fbincode-zig/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lithdew","download_url":"https://codeload.github.com/lithdew/bincode-zig/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522302,"owners_count":21444511,"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-12-12T21:11:53.334Z","updated_at":"2025-04-23T22:04:04.647Z","avatar_url":"https://github.com/lithdew.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"# bincode-zig\n\nA [Zig](https://ziglang.org) implementation of the [Bincode](https://github.com/bincode-org/bincode) binary format specification.\n\n## Specification\n\nThe endianness of serialized values by default is little-endian. This may be configured.\n\nBoolean types are encoded as 1 byte. 0 for false, 1 for true.\n\nAll basic numeric types will be encoded as either variable-length integers or fixed-length integers depending on the configured integer encoding.\n\nThe numeric type `usize` is encoded/decoded as a `u64`. The numeric type `isize` is encoded/decoded as a `i64`.\n\nAll floating point types will take up either exactly 4 bytes (to represent a `f32`) or 8 bytes (to represent a `f64`).\n\nAll members that are part of a tuple or struct are encoded as-is in their specified order.\n\nEnums are encoded by their discriminant first, followed by their payload.\n\nSlices and vectors are encoded by their length first, followed by their elements.\n\nFixed-length arrays are not encoded by their lengths first. This may be configured.\n\nEncoding an unsigned variable-length integer u (of any type excepting `u8`) works as follows:\n\n1. If `u \u003c 251`, encode it as a single byte with that value.\n2. If `251 \u003c= u \u003c 2**16`, encode it as a literal byte 251, followed by a `u16` with value u.\n3. If `2**16 \u003c= u \u003c 2**32`, encode it as a literal byte 252, followed by a `u32` with value u.\n4. If `2**32 \u003c= u \u003c 2**64`, encode it as a literal byte 253, followed by a `u64` with value u.\n5. If `2**64 \u003c= u \u003c 2**128`, encode it as a literal byte 254, followed by a `u128` with value u.\n6. If `2**128 \u003c= u \u003c 2**256`, encode it as a literal byte 255, followed by a `u256` with value u.\n\nEncoded a signed variable-length integer works by first converting the integer to an unsigned integer using the zigzag algorithm, and then encoding the unsigned integer as an unsigned variable-length integer.\n\nThe zigzag algorithm is defined as follows:\n\n```zig\nfn zigzag(v: Signed) Unsigned {\n    return if (v \u003c 0) (~@bitCast(Unsigned, v) * 2 + 1) else (@intCast(Unsigned, v) * 2);\n}\n```\n\nFixed-length integers are encoded directly. When configured to encode/decode integers as fixed-length integers, enum discriminants are encoded as `u32`, and lengths are encoded as the numeric type `usize`. \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flithdew%2Fbincode-zig","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flithdew%2Fbincode-zig","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flithdew%2Fbincode-zig/lists"}