{"id":13710211,"url":"https://github.com/ziglibs/s2s","last_synced_at":"2025-04-05T00:05:20.342Z","repository":{"id":37066827,"uuid":"461762046","full_name":"ziglibs/s2s","owner":"ziglibs","description":"A zig binary serialization format.","archived":false,"fork":false,"pushed_at":"2025-03-19T23:41:58.000Z","size":3787,"stargazers_count":141,"open_issues_count":3,"forks_count":23,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-28T23:03:39.502Z","etag":null,"topics":["binary-data","serialization","serialization-library","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/ziglibs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":null,"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},"funding":{"github":"MasterQ32"}},"created_at":"2022-02-21T08:07:25.000Z","updated_at":"2025-03-27T22:17:45.000Z","dependencies_parsed_at":"2023-11-27T17:46:23.914Z","dependency_job_id":"ad293123-592c-4b08-807a-ebc333070146","html_url":"https://github.com/ziglibs/s2s","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/ziglibs%2Fs2s","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziglibs%2Fs2s/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziglibs%2Fs2s/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziglibs%2Fs2s/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziglibs","download_url":"https://codeload.github.com/ziglibs/s2s/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247266562,"owners_count":20910836,"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":["binary-data","serialization","serialization-library","zig","zig-package"],"created_at":"2024-08-02T23:00:53.098Z","updated_at":"2025-04-05T00:05:20.319Z","avatar_url":"https://github.com/ziglibs.png","language":"Zig","readme":"# struct to stream | stream to struct\n\nA Zig binary serialization format and library.\n\n![Project logo](design/logo.png)\n\n## Features\n\n- Convert (nearly) any Zig runtime datatype to binary data and back.\n- Computes a stream signature that prevents deserialization of invalid data.\n- No support for graph like structures. Everything is considered to be tree data.\n\n**Unsupported types**:\n\n- All `comptime` only types\n- Unbound pointers (c pointers, pointer to many)\n- `volatile` pointers\n- Untagged or `external` unions\n- Opaque types\n- Function pointers\n- Frames\n\n## API\n\nThe library itself provides only some APIs, as most of the serialization process is not configurable.\n\n```zig\n/// Serializes the given `value: T` into the `stream`.\n/// - `stream` is a instance of `std.io.Writer`\n/// - `T` is the type to serialize\n/// - `value` is the instance to serialize.\nfn serialize(stream: anytype, comptime T: type, value: T) StreamError!void;\n\n/// Deserializes a value of type `T` from the `stream`.\n/// - `stream` is a instance of `std.io.Reader`\n/// - `T` is the type to deserialize\nfn deserialize(stream: anytype, comptime T: type) (StreamError || error{UnexpectedData,EndOfStream})!T;\n\n/// Deserializes a value of type `T` from the `stream`.\n/// - `stream` is a instance of `std.io.Reader`\n/// - `T` is the type to deserialize\n/// - `allocator` is an allocator require to allocate slices and pointers.\n/// Result must be freed by using `free()`.\nfn deserializeAlloc(stream: anytype, comptime T: type, allocator: std.mem.Allocator) (StreamError || error{ UnexpectedData, OutOfMemory,EndOfStream })!T;\n\n/// Releases all memory allocated by `deserializeAlloc`.\n/// - `allocator` is the allocator passed to `deserializeAlloc`.\n/// - `T` is the type that was passed to `deserializeAlloc`.\n/// - `value` is the value that was returned by `deserializeAlloc`.\nfn free(allocator: std.mem.Allocator, comptime T: type, value: T) void;\n```\n\n## Usage and Development\n\n### Adding the library\n\nJust add the `s2s.zig` as a package to your Zig project. It has no external dependencies.\n\n### Running the test suite\n\n```sh-session\n[user@host s2s]$ zig test s2s.zig\nAll 3 tests passed.\n[user@host s2s]$\n```\n\n## Project Status\n\nMost of the serialization/deserialization is implemented for the _trivial_ case.\n\nPointers/slices with non-standard alignment aren't properly supported yet.\n","funding_links":["https://github.com/sponsors/MasterQ32"],"categories":["Libraries","Language Essentials"],"sub_categories":["File Format Processing"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziglibs%2Fs2s","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziglibs%2Fs2s","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziglibs%2Fs2s/lists"}