Crate comet_eventbus

Source
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§

bridgebridge
bridge Eventbus from an external source

Structs§

Event
An Event for passing
EventListener
An EventListener wrapper for Listener
Eventbus
An asynchronous Eventbus to interact with
Topic
A Topic wrapper for a TopicKey
TopicKey
Wrapper of bytes represent a Topic

Traits§

Listenerasync
Event listener

Type Aliases§

EventListeners
short hand of event listeners set
TopicHandlersMap
short hand of topic to handlers map

Attribute Macros§

async_trait