{"id":21586059,"url":"https://github.com/magiclen/synchronized-writer","last_synced_at":"2025-04-10T20:15:05.727Z","repository":{"id":57669113,"uuid":"154490330","full_name":"magiclen/synchronized-writer","owner":"magiclen","description":"A tiny implement for synchronously writing data.","archived":false,"fork":false,"pushed_at":"2023-09-09T05:32:09.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-24T17:55:18.255Z","etag":null,"topics":["rust"],"latest_commit_sha":null,"homepage":"","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/magiclen.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":"2018-10-24T11:35:42.000Z","updated_at":"2024-10-08T16:06:39.000Z","dependencies_parsed_at":"2024-11-24T18:01:14.658Z","dependency_job_id":null,"html_url":"https://github.com/magiclen/synchronized-writer","commit_stats":{"total_commits":18,"total_committers":1,"mean_commits":18.0,"dds":0.0,"last_synced_commit":"485ea8e0920150f4182422fe66024fbccbc26e7a"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fsynchronized-writer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fsynchronized-writer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fsynchronized-writer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/magiclen%2Fsynchronized-writer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/magiclen","download_url":"https://codeload.github.com/magiclen/synchronized-writer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248288600,"owners_count":21078907,"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":["rust"],"created_at":"2024-11-24T15:12:30.982Z","updated_at":"2025-04-10T20:15:05.699Z","avatar_url":"https://github.com/magiclen.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"Synchronized Writer\n====================\n\n[![CI](https://github.com/magiclen/synchronized-writer/actions/workflows/ci.yml/badge.svg)](https://github.com/magiclen/synchronized-writer/actions/workflows/ci.yml)\n\nA tiny implement for synchronously writing data.\n\n## Examples\n\n### SynchronizedWriter\n\n```rust\nuse synchronized_writer::SynchronizedWriter;\nuse std::sync::{Arc, Mutex};\nuse std::thread;\nuse std::io::Write;\n\nlet data = Mutex::new(Vec::new());\n\nlet data_arc = Arc::new(data);\n\nlet mut threads = Vec::with_capacity(10);\n\nfor _ in 0..10 {\n    let mut writer = SynchronizedWriter::new(data_arc.clone());\n\n    let thread = thread::spawn(move || {\n        writer.write(b\"Hello world!\").unwrap();\n    });\n\n    threads.push(thread);\n}\n\nfor thread in threads {\n    thread.join().unwrap();\n}\n\nassert_eq!(b\"Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!Hello world!\".to_vec(), *data_arc.lock().unwrap());\n```\n\n### SynchronizedOptionWriter\n\n```rust\nuse synchronized_writer::SynchronizedOptionWriter;\nuse std::sync::{Arc, Mutex};\nuse std::io::Write;\n\nlet data = Mutex::new(Some(Vec::new()));\n\nlet data_arc = Arc::new(data);\n\nlet mut writer = SynchronizedOptionWriter::new(data_arc.clone());\n\nwriter.write(b\"Hello world!\").unwrap();\n\nwriter.flush().unwrap();\n\nlet data = data_arc.lock().unwrap().take().unwrap(); // remove out the vec from arc\n\nassert_eq!(b\"Hello world!\".to_vec(), data);\n```\n\n## Crates.io\n\nhttps://crates.io/crates/synchronized-writer\n\n## Documentation\n\nhttps://docs.rs/synchronized-writer\n\n## License\n\n[MIT](LICENSE)","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fsynchronized-writer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmagiclen%2Fsynchronized-writer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmagiclen%2Fsynchronized-writer/lists"}