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
Eventbus
from an external source
Structs§
- Event
- An
Event
for passing - Event
Listener - An
EventListener
wrapper forListener
- Eventbus
- An asynchronous
Eventbus
to interact with - Topic
- A
Topic
wrapper 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