Crate ic_event_hub_macros
source · [−]Expand description
Various macro for IC canisters to enable event-based pub/sub
Usage:
// somewhere in your canister
implement_event_emitter!();
implement_subscribe!();
implement_unsubscribe!();
...
#[derive(Event)]
struct Event {
#[topic]
pub a: u64,
pub b: String,
}
emit(Event {
a: 10,
b: String::from("test")
});
Check the companion crate to see how a listener could start receiving events
Derive Macros
Generates an implementation of ic_event_hub::types::IEvent
trait for a given struct. Also generates a *Filter
struct and an implementation of ic_event_hub::types::IEventFilter
trait for that struct which can be used to filter
topics while listening to the given event.