{"id":16153900,"url":"https://github.com/hinto-janai/rolock","last_synced_at":"2025-10-29T00:37:06.841Z","repository":{"id":195959026,"uuid":"616245899","full_name":"hinto-janai/rolock","owner":"hinto-janai","description":"Read Only Lock","archived":false,"fork":false,"pushed_at":"2023-03-29T18:42:38.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-04-23T22:39:30.488Z","etag":null,"topics":["lock","read-only","rust","sync"],"latest_commit_sha":null,"homepage":"https://docs.rs/rolock","language":"Rust","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/hinto-janai.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}},"created_at":"2023-03-20T01:55:36.000Z","updated_at":"2023-03-30T12:17:48.000Z","dependencies_parsed_at":"2023-09-20T09:33:43.720Z","dependency_job_id":null,"html_url":"https://github.com/hinto-janai/rolock","commit_stats":null,"previous_names":["hinto-janai/rolock"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Frolock","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Frolock/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Frolock/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hinto-janai%2Frolock/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hinto-janai","download_url":"https://codeload.github.com/hinto-janai/rolock/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247569130,"owners_count":20959758,"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":["lock","read-only","rust","sync"],"created_at":"2024-10-10T01:14:53.041Z","updated_at":"2025-10-29T00:37:01.822Z","avatar_url":"https://github.com/hinto-janai.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RoLock\n[![Windows](https://github.com/hinto-janai/rolock/actions/workflows/windows.yml/badge.svg)](https://github.com/hinto-janai/rolock/actions/workflows/windows.yml) [![macOS](https://github.com/hinto-janai/rolock/actions/workflows/macos.yml/badge.svg)](https://github.com/hinto-janai/rolock/actions/workflows/macos.yml) [![Linux](https://github.com/hinto-janai/rolock/actions/workflows/linux.yml/badge.svg)](https://github.com/hinto-janai/rolock/actions/workflows/linux.yml) [![crates.io](https://img.shields.io/crates/v/rolock.svg)](https://crates.io/crates/rolock) [![docs.rs](https://docs.rs/rolock/badge.svg)](https://docs.rs/rolock)\n\nRead Only Lock.\n\nThis is a wrapper around `Arc\u003cRwLock\u003cT\u003e\u003e` that only implements `RwLock::read()` operations.\n\n## Usage\nCreate a normal `Arc\u003cRwLock\u003cT\u003e\u003e` in `thread_1`, send a `RoLock` to `thread_2`:\n```rust\nlet rw = Arc::new(RwLock::new(0));     // Regular Arc\u003cRwLock\u003cT\u003e\u003e.\nlet ro = RoLock::new(\u0026rw);             // Read Only Lock.\n\nassert!(*rw.read().unwrap() == 0);     // This can read...\n*rw.write().unwrap() = 1;              // and write.\n\nstd::thread::spawn(move|| {\n\tassert!(*ro.read().unwrap() == 1); // This one can only read.\n});\n```\n- `thread_1` still has full read/write control\n- `thread_2` can only `RoLock::read()`\n\nThis type guarantees at compile time that you cannot write because the function doesn't even exist:\n```rust\nlet rw = Arc::new(RwLock::new(0));\nlet ro = RoLock::new(\u0026rw);\n\nro.write(); // Compile error!\n```\n\nSince the inner field of `RoLock` (`self.0`) is private, you can't call `RwLock::write` directly either:\n```rust\nlet rw = Arc::new(RwLock::new(0));\nlet ro = RoLock::new(\u0026rw);\n\nro.0.write(); // Compile error!\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinto-janai%2Frolock","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhinto-janai%2Frolock","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhinto-janai%2Frolock/lists"}