{"id":36944892,"url":"https://github.com/jasterv/event_bus.rs","last_synced_at":"2026-03-02T03:07:55.872Z","repository":{"id":326392314,"uuid":"1105314583","full_name":"JasterV/event_bus.rs","owner":"JasterV","description":"A runtime-agnostic, async, and thread-safe event bus for Rust.","archived":false,"fork":false,"pushed_at":"2026-03-01T18:39:48.000Z","size":104,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-01T20:34:18.287Z","etag":null,"topics":[],"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/JasterV.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-11-27T12:37:36.000Z","updated_at":"2026-03-01T18:37:51.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/JasterV/event_bus.rs","commit_stats":null,"previous_names":["jasterv/event_bus.rs"],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/JasterV/event_bus.rs","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasterV%2Fevent_bus.rs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasterV%2Fevent_bus.rs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasterV%2Fevent_bus.rs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasterV%2Fevent_bus.rs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JasterV","download_url":"https://codeload.github.com/JasterV/event_bus.rs/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JasterV%2Fevent_bus.rs/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29991309,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-02T01:47:34.672Z","status":"online","status_checked_at":"2026-03-02T02:00:07.342Z","response_time":60,"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":[],"created_at":"2026-01-13T11:10:58.085Z","updated_at":"2026-03-02T03:07:55.867Z","avatar_url":"https://github.com/JasterV.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# event_bus.rs\n\n[![Crate Version: event_bus_rs](https://img.shields.io/crates/v/event_bus_rs.svg)](https://crates.io/crates/event_bus_rs)\n\nA **runtime-agnostic**, **async**, and **thread-safe** event bus for Rust.\nDesigned to be **efficient**, **simple**, and **easy to use**, allowing you to publish and subscribe to messages across threads and async tasks.\n\n---\n\n## Features\n\n- **Runtime-agnostic**: works with any async runtime (Tokio, async-std, smol, etc.)\n- **Thread-safe**: multiple publishers and subscribers can safely coexist\n- **Async \u0026 Stream-based**: subscribers implement `futures::Stream`\n- **Automatic cleanup**: topics are removed when the last subscriber drops\n- **Minimal \u0026 simple API**: just `EventBus::subscribe` and `EventBus::publish`\n\n## Topic capacity\n\nThe EventBus is build on top of bounded channels, which means that each time a topic is created, we need to specify a capacity.\n\nThe default one is set to an arbitrary value which is available and documented in the docs.\n\nTo know more about how the bounded channels work, check [async_broadcast](https://docs.rs/async-broadcast/0.7.2/async_broadcast/index.html)\n\n---\n\n## Installation\n\nAdd to your `Cargo.toml`:\n\n```toml\n[dependencies]\nevent_bus_rs = \"0.1.0\"\nfutures = \"0.3\"\n````\n\n---\n## Usage Example\n\n```rust\nuse event_bus_rs::EventBus;\nuse futures::StreamExt;\n\n#[tokio::main]\nasync fn main() {\n    let bus = EventBus::new_with_topic_capacity(50);\n\n    // Subscribe to a topic\n    let mut sub = bus.subscribe(\"my_topic\");\n\n    // Spawn a subscriber task\n    tokio::spawn(async move {\n        while let Some(msg) = sub.next().await {\n            println!(\"Received: {}\", String::from_utf8_lossy(\u0026msg));\n        }\n    });\n\n    // Publish a message\n    bus.publish(\"my_topic\", b\"Hello, EventBus!\").unwrap();\n}\n```\n\n**Notes:**\n\n* Messages are published as `\u0026[u8]`; encoding/decoding is the user's responsibility.\n* Multiple subscribers to the same topic each get a copy of every message.\n* When all subscribers of a topic are dropped, the topic is automatically cleaned up.\n\n---\n\n## API Overview\n\n* `EventBus::new() -\u003e EventBus` – create a new bus\n* `EventBus::new_with_topic_capacity() -\u003e EventBus` - create a new but with a configure topic capacity\n* `EventBus::subscribe(\u0026self, topic: \u0026str) -\u003e Subscription` – subscribe to a topic\n* `EventBus::publish(\u0026self, topic: \u0026str, data: \u0026[u8]) -\u003e Result\u003c(), PublishError\u003e` – publish a message\n* `Subscription` implements `futures::Stream\u003cItem = Arc\u003c[u8]\u003e\u003e`\n\n---\n\n## License\n\nMIT OR Apache-2.0\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasterv%2Fevent_bus.rs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasterv%2Fevent_bus.rs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasterv%2Fevent_bus.rs/lists"}