{"id":19198853,"url":"https://github.com/rustgd/shrev-rs","last_synced_at":"2025-04-09T21:20:29.642Z","repository":{"id":57667300,"uuid":"98398626","full_name":"rustgd/shrev-rs","owner":"rustgd","description":"Shred based event handler","archived":false,"fork":false,"pushed_at":"2022-06-04T10:09:47.000Z","size":116,"stargazers_count":59,"open_issues_count":4,"forks_count":12,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-02T19:07:32.509Z","etag":null,"topics":["events","multithreading","ring-buffer","rust"],"latest_commit_sha":null,"homepage":null,"language":"Rust","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/rustgd.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}},"created_at":"2017-07-26T08:25:30.000Z","updated_at":"2024-09-21T10:49:49.000Z","dependencies_parsed_at":"2022-09-02T14:01:20.793Z","dependency_job_id":null,"html_url":"https://github.com/rustgd/shrev-rs","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/rustgd%2Fshrev-rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustgd%2Fshrev-rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustgd%2Fshrev-rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustgd%2Fshrev-rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustgd","download_url":"https://codeload.github.com/rustgd/shrev-rs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248112317,"owners_count":21049633,"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":["events","multithreading","ring-buffer","rust"],"created_at":"2024-11-09T12:24:29.437Z","updated_at":"2025-04-09T21:20:29.609Z","avatar_url":"https://github.com/rustgd.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `shrev`\n\n[![crates.io badge](https://img.shields.io/crates/v/shrev.svg)](https://crates.io/crates/shrev) [![docs badge](https://docs.rs/shrev/badge.svg)](https://docs.rs/shrev)\n\nA pull based event channel, with events stored in a ring buffer,\nmeant to be used as a resource in [`specs`].\n \n[`specs`]: https://github.com/slide-rs/specs\n\n## Example usage\n\n```rust\nextern crate shrev;\n\nuse shrev::EventChannel;\n\n#[derive(Clone, Debug, PartialEq, Eq)]\npub struct TestEvent {\n    data: u32,\n}\n\nfn main() {\n    let mut channel = EventChannel::new();\n\n    channel.drain_vec_write(\u0026mut vec![TestEvent { data: 1 }, TestEvent { data: 2 }]);\n\n    let mut reader_id = channel.register_reader();\n\n    // Should be empty, because reader was created after the write\n    assert_eq!(\n        Vec::\u003cTestEvent\u003e::default(),\n        channel.read(\u0026mut reader_id).cloned().collect::\u003cVec\u003c_\u003e\u003e()\n    );\n\n    // Should have data, as a second write was done\n    channel.single_write(TestEvent { data: 5 });\n\n    assert_eq!(\n        vec![TestEvent { data: 5 }],\n        channel.read(\u0026mut reader_id).cloned().collect::\u003cVec\u003c_\u003e\u003e()\n    );\n\n    // We can also just send in an iterator.\n    channel.iter_write(\n        [TestEvent { data: 8 }, TestEvent { data: 9 }]\n            .iter()\n            .cloned(),\n    );\n\n    assert_eq!(\n        vec![TestEvent { data: 8 }, TestEvent { data: 9 }],\n        channel.read(\u0026mut reader_id).cloned().collect::\u003cVec\u003c_\u003e\u003e()\n    );\n}\n```\n\n## License\n\n`shrev-rs` is free and open source software distributed under the terms of both\nthe MIT License and the Apache License 2.0.\n\nUnless you explicitly state otherwise, any contribution intentionally submitted\nfor inclusion in the work by you, as defined in the Apache-2.0 license, shall\nbe dual licensed as above, without any additional terms or conditions.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustgd%2Fshrev-rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustgd%2Fshrev-rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustgd%2Fshrev-rs/lists"}