Documentation Index
Fetch the complete documentation index at: https://docs.praison.ai/llms.txt
Use this file to discover all available pages before exploring further.
EventBus
Defined in the bus module.
Rust AI Agent SDK
Event bus for publish-subscribe messaging.
Fields
| Name | Type | Description |
|---|
subscriptions | RwLock<HashMap<EventType | Subscriptions by event type |
global_subscriptions | RwLock<Vec<Subscription>> | Global subscriptions (receive all events) |
next_id | RwLock<usize> | Next subscription ID |
history | RwLock<Vec<Event>> | Event history (optional) |
max_history | usize | Max history size |
Methods
new
Create a new event bus
with_history
fn with_history(max_history: usize) -> Self
Create with custom history size
Parameters:
unsubscribe
fn unsubscribe(&self, subscription_id: usize) -> bool
Unsubscribe by ID
Parameters:
| Name | Type |
|---|
subscription_id | usize |
publish
fn publish(&self, event: Event) -> ()
Publish an event
Parameters:
history
fn history(&self) -> Vec<Event>
Get event history
events_by_type
fn events_by_type(&self, event_type: EventType) -> Vec<Event>
Get events by type
Parameters:
| Name | Type |
|---|
event_type | EventType |
events_by_source
fn events_by_source(&self, source: &str) -> Vec<Event>
Get events by source
Parameters:
clear_history
fn clear_history(&self) -> ()
Clear history
subscription_count
fn subscription_count(&self, event_type: EventType) -> usize
Get subscription count for an event type
Parameters:
| Name | Type |
|---|
event_type | EventType |
total_subscriptions
fn total_subscriptions(&self) -> usize
Get total subscription count
Source
View on GitHub
praisonai/src/bus/mod.rs at line 201