Expand description
An universal eventbus for Rust!
This crate provides a strong-typed asynchronous eventbus implementation.
§Get Started
comet-eventbus is async-first-classed. We recommend you to use async API.
Add following code to your Cargo.toml:
comet-eventbus = "0.1"§Example
use comet_eventbus::{Event, Eventbus};
// define your message struct
struct Message {
content: u8,
}
#[tokio::main]
async fn main() {
// creat a new eventbus
let eventbus = Eventbus::new();
// create topic
let topic = eventbus.create_topic("my awsome topic").await;
// post message to a topic
topic.post_message(Message { content: 0 }).await;
}Modules§
- bridge
bridge - bridge
Eventbusfrom an external source
Structs§
- Event
- An
Eventfor passing - Event
Listener - An
EventListenerwrapper forListener - Eventbus
- An asynchronous
Eventbusto interact with - Topic
- A
Topicwrapper for aTopicKey - Topic
Key - Wrapper of bytes represent a
Topic
Traits§
- Listener
async - Event listener
Type Aliases§
- Event
Listeners - short hand of event listeners set
- Topic
Handlers Map - short hand of topic to handlers map