pub trait EventBus: Send + Sync {
// Required methods
fn emit(&self, event: &str, payload: Value) -> Result<(), PluginError>;
fn subscribe(
&self,
event: AppEvent,
handler: Box<dyn Fn(Value) + Send + Sync>,
) -> SubscriptionToken;
fn unsubscribe(&self, token: SubscriptionToken);
}Required Methods§
Sourcefn emit(&self, event: &str, payload: Value) -> Result<(), PluginError>
fn emit(&self, event: &str, payload: Value) -> Result<(), PluginError>
Emit a plugin-scoped event.
Full event name on the wire: plugin:{plugin_id}:{event}
Sourcefn subscribe(
&self,
event: AppEvent,
handler: Box<dyn Fn(Value) + Send + Sync>,
) -> SubscriptionToken
fn subscribe( &self, event: AppEvent, handler: Box<dyn Fn(Value) + Send + Sync>, ) -> SubscriptionToken
Subscribe to a well-known app event. Returns a token for unsubscribing.
fn unsubscribe(&self, token: SubscriptionToken)
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".