{"id":15031457,"url":"https://github.com/zeozeozeo/type-handle","last_synced_at":"2026-03-16T22:34:30.506Z","repository":{"id":191410916,"uuid":"684762069","full_name":"zeozeozeo/type-handle","owner":"zeozeozeo","description":"Regular and reference-counted type handles for Rust","archived":false,"fork":false,"pushed_at":"2023-08-31T09:37:48.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-28T08:53:46.483Z","etag":null,"topics":["ffi","ffi-helpers","handle","memory-management","native","rchandle","reference-counting","rust-ffi","rust-helper","rust-patterns","rustlang","tiny","types","utils"],"latest_commit_sha":null,"homepage":"https://docs.rs/type-handle","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"unlicense","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zeozeozeo.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":"2023-08-29T19:57:40.000Z","updated_at":"2023-08-29T20:02:59.000Z","dependencies_parsed_at":"2024-10-12T14:10:50.717Z","dependency_job_id":null,"html_url":"https://github.com/zeozeozeo/type-handle","commit_stats":null,"previous_names":["zeozeozeo/type-handle"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeozeozeo%2Ftype-handle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeozeozeo%2Ftype-handle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeozeozeo%2Ftype-handle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zeozeozeo%2Ftype-handle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zeozeozeo","download_url":"https://codeload.github.com/zeozeozeo/type-handle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243382783,"owners_count":20282007,"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":["ffi","ffi-helpers","handle","memory-management","native","rchandle","reference-counting","rust-ffi","rust-helper","rust-patterns","rustlang","tiny","types","utils"],"created_at":"2024-09-24T20:15:43.000Z","updated_at":"2025-12-29T22:18:50.862Z","avatar_url":"https://github.com/zeozeozeo.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# type-handle\n\nTiny Rust library that exports `Handle\u003cT\u003e` and `RCHandle\u003cT\u003e`. Can be useful for wrapping native ffi structs/pointers. \n\nBoth `Handle` and `RCHandle` implement `Clone`, where `Handle` will clone the underlying struct instance (if it implements `Clone`), and `RCHandle` will keep the underlying pointer.\n\n`Handle` and `RCHandle` implement `Send`/`Sync` by default with the `send_sync` feature.\n\nThey both implement `Deref` and `DerefMut`, so you can access a field through a handle the same as you normally would on a normal instance.\n\n# Example\n\n## `Handle\u003cT\u003e`\n\n```rust\n#[derive(Clone)]\nstruct Animal {\n    is_dog: bool,\n}\n\nlet animal = Animal { is_dog: false };\nlet cat = Handle::from_instance(animal);\n\n// clone `cat` and mutate `is_dog`, note that `animal` is not mutable\nlet dog = handle.clone(); // this clones `Animal`, `Animal` must implement `Clone`\ndog.is_dog = true;\n```\n\n## `RCHandle\u003cT\u003e` (reference-counted handle)\n\n```rust\n// don't have to #[derive(Clone)] here!\nstruct Animal {\n    is_dog: bool,\n}\n\nlet mut animal = Animal { is_dog: false };\nlet mut handle = RCHandle::from_ptr(\u0026mut animal);\n\n// note that `Animal` does not implement `Clone`, because \n// cloning an `RCHandle` does not clone the underlying type\nlet mut handle2 = handle.clone();\n\nhandle2.is_dog = true;\nassert!(handle.is_dog == handle2.is_dog);\n```\n\n# Tests\n\nTo run tests, run `cargo test`.\n\n# License\n\nPublic domain (unlicense).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeozeozeo%2Ftype-handle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzeozeozeo%2Ftype-handle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzeozeozeo%2Ftype-handle/lists"}