{"id":30720244,"url":"https://github.com/fincap/zig-rtti","last_synced_at":"2025-09-03T11:02:05.065Z","repository":{"id":309156330,"uuid":"1035043055","full_name":"Fincap/zig-rtti","owner":"Fincap","description":"Runtime Type Information for Zig","archived":false,"fork":false,"pushed_at":"2025-08-23T02:51:33.000Z","size":111,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-08-23T04:19:57.985Z","etag":null,"topics":["rtti","runtime-typechecking","zig","zig-library","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Fincap.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"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,"zenodo":null}},"created_at":"2025-08-09T14:34:30.000Z","updated_at":"2025-08-23T02:51:36.000Z","dependencies_parsed_at":"2025-08-10T08:32:01.911Z","dependency_job_id":"1a24cffd-c773-4cd6-b2be-97d107a339f1","html_url":"https://github.com/Fincap/zig-rtti","commit_stats":null,"previous_names":["fincap/zig_rtti"],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/Fincap/zig-rtti","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fincap%2Fzig-rtti","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fincap%2Fzig-rtti/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fincap%2Fzig-rtti/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fincap%2Fzig-rtti/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Fincap","download_url":"https://codeload.github.com/Fincap/zig-rtti/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Fincap%2Fzig-rtti/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273431417,"owners_count":25104496,"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","status":"online","status_checked_at":"2025-09-03T02:00:09.631Z","response_time":76,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["rtti","runtime-typechecking","zig","zig-library","ziglang"],"created_at":"2025-09-03T11:00:40.327Z","updated_at":"2025-09-03T11:02:04.418Z","avatar_url":"https://github.com/Fincap.png","language":"Zig","readme":"# zig-rtti\nRuntime Type Information for Zig.\n\nThis library provides a `TypeRegistry` container for storing runtime information about types that \nare registered at comptime.\n\nAdds in `Type`, which adapts `std.builtin.Type` to work with the subset of Zig types that are able\nto be meaningfully represented at runtime:\n- bool\n- Int\n- Float\n- Pointer (single-item, many-item, slices, C)\n- Array\n- Struct\n- Optional\n- Enum\n- Union\n\nWhen a type refers to another type (for example, a pointer’s target, a struct’s field type, or an\noptional’s payload), its `Type` holds a pointer to the corresponding `Type` instance. This works \nbecause the `TypeRegistry` stores all `Type` instances at [stable addresses](src/stable_map.zig), \nand the registered types are assumed to remain valid for the lifetime of the registry.\n\nThe library also includes a [formatter module](src/fmt.zig) that can inspect an opaque pointer and \nwrite a human-readable representation to any `std.Io.Writer`, and is an example of how runtime type\ninformation can be utilized.\n\n## Installation\nAdd zig-rtti as a dependency by running the following command in your project root:\n\n```\nzig fetch --save git+https://github.com/Fincap/zig-rtti#v0.2.0\n```\n\nThen updating your `build.zig` to include the following:\n\n```zig\nconst rtti_dep = b.dependency(\"rtti\", .{ \n    .target = target,\n    .optimize = optimize\n});\nconst rtti = rtti_dep.module(\"rtti\");\nexe.root_module.addImport(\"rtti\", rtti);\n```\n\n## Example\nMinimal:\n\n```zig\nconst std = @import(\"std\");\nconst rtti = @import(\"rtti\");\n\npub fn main() !void {\n    // Initialize stdout\n    var stdout_buffer: [1024]u8 = undefined;\n    var stdout_writer = std.fs.File.stdout().writer(\u0026stdout_buffer);\n    const stdout = \u0026stdout_writer.interface;\n\n    // Initialize allocator\n    var arena = std.heap.ArenaAllocator.init(std.heap.page_allocator);\n    const allocator = arena.allocator();\n\n    // `TypeRegistry` holds all registerted type metadata.\n    var type_registry = rtti.TypeRegistry.init(allocator);\n    defer type_registry.deinit();\n\n    // Define and register a new type so it can be inspected at runtime.\n    const MyStruct = struct {\n        number: i32,\n        text: []const u8,\n    };\n    const info = try type_registry.registerType(MyStruct);\n\n    // Create a type-erased pointer to an instance of `MyStruct`.\n    const erased: *const anyopaque = \u0026MyStruct{ .number = 14, .text = \"hello\" };\n\n    // Use the built-in formatter to print the type-erased struct’s fields at runtime.\n    try rtti.fmt.formatType(info, erased, stdout);\n    try stdout.flush();\n    // Output:\n    // { number: 14, text: \"hello\" }\n}\n```\n\nType-erased object:\n\n```zig\nconst rtti = @import(\"rtti\");\n\nconst TypeErasedObject = struct {\n    ptr: *anyopaque,\n    info: *rtti.Type,\n};\n```\n\n## Versions\n\n| Zig version | zig-rtti version |\n|-------------|------------------|\n| 0.15.1      | master           |\n| 0.15.1      | 0.2              |\n| 0.14.1      | 0.1.1            |\n| 0.14.1      | 0.1              |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffincap%2Fzig-rtti","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffincap%2Fzig-rtti","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffincap%2Fzig-rtti/lists"}