Crates.io | ebus |
lib.rs | ebus |
version | 1.3.0 |
source | src |
created_at | 2022-11-12 11:58:07.551271 |
updated_at | 2023-08-14 15:55:33.91061 |
description | Basic Event Bus implementation |
homepage | |
repository | https://github.com/WeirdPtr/ebus |
max_upload_size | |
id | 713577 |
size | 27,428 |
ebus is a simple Eventbus implementation written in Rust.
Report Bug
ยท
Request Feature
This is a small Eventbus implementation that can be used to asynchronously transmit data to subscribers of a EventBus instance.
cargo build --release
cargo run --example basic-implementation
use ebus::{async_subscriber, EventBus, Subscriber};
#[derive(Default)]
pub struct ExampleSubscriber;
#[async_subscriber]
impl Subscriber for ExampleSubscriber {
type Input = String;
async fn on_event_publish(&mut self, event: &Self::Input) {
println!("Received Data: {:#?}", event);
}
}
#[tokio::main]
async fn main() {
// Create a new event bus
let mut event_bus = EventBus::default();
// Create a new subscriber and subscribe it to the event bus
let subscriber = ExampleSubscriber::default();
event_bus.subscribe(subscriber);
// Create an event and queue it for processing
let event_data = "Hello World!".to_owned();
event_bus.queue_and_process(event_data).await;
}
See the open issues for a full list of proposed features (and known issues).
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
git checkout -b feat(amazing)/amazing-feature
)git commit -m 'feat(amazing): such progress'
)git push origin feat(amazing)/amazing-feature
)Distributed under the MIT or Apache 2 License. See LICENSE-MIT
or LICENSE-APACHE
for more information.