psbus
Generic Publish / Subscribe model for application messaging
NOTE: This module was heavily inspired by Lakelezz's (now dormant) hey_listen: https://github.com/Lakelezz/hey_listen
psbus
allows for any application to implement their own Publish/Subscribe model for easy messaging. psbus
currently supports the following use cases:
- Single-threaded event dispatch
- Single-threaded + prioritized event dispatch
- Thread-safe / synchronized event dispatch
- Thread-safe / synchronized + prioritized event dispatch
Installation
Add this to your Cargo.toml
:
[]
= "0.1.0"
Example
Aside from type name differences, the usage is consistent across the board for dispatchers. This example uses a single-threaded, non-prioritized dispatch model.
use ;
use Rc;
// Define the categories into which your events will fall
// Define the events themselves, note that you can use bare, tuple or struct enums all the same!
// Implement the Event trait for your custom event
// Now lets make a test Subscriber...
// And a test Publisher...
// And finally, we define our EventBus type
pub type TestEventBus = ;