pub struct EventBus { /* private fields */ }Expand description
The event bus for managing events within a task context
Implementations§
Source§impl EventBus
impl EventBus
Sourcepub fn with_handlers(handlers: Vec<Arc<dyn EventHandler>>) -> Self
pub fn with_handlers(handlers: Vec<Arc<dyn EventHandler>>) -> Self
Create a new event bus with handlers
Sourcepub async fn run<F, Fut, T>(&self, f: F) -> T
pub async fn run<F, Fut, T>(&self, f: F) -> T
Run a function with this event bus as the task-local context
Sourcepub async fn register_handler(handler: Arc<dyn EventHandler>) -> Result<()>
pub async fn register_handler(handler: Arc<dyn EventHandler>) -> Result<()>
Register an event handler to the current task-local event bus
Sourcepub async fn emit(
event: AlienEvent,
parent_id: Option<String>,
state: EventState,
) -> Result<EventHandle>
pub async fn emit( event: AlienEvent, parent_id: Option<String>, state: EventState, ) -> Result<EventHandle>
Emit a new event using the current task-local event bus
Sourcepub async fn update(id: &str, event: AlienEvent) -> Result<()>
pub async fn update(id: &str, event: AlienEvent) -> Result<()>
Update an existing event using the current task-local event bus
Sourcepub async fn update_state(id: &str, new_state: EventState) -> Result<()>
pub async fn update_state(id: &str, new_state: EventState) -> Result<()>
Update the state of an event using the current task-local event bus
Sourcepub async fn with_parent<F, Fut, T>(parent_id: Option<String>, f: F) -> T
pub async fn with_parent<F, Fut, T>(parent_id: Option<String>, f: F) -> T
Run a function with a parent event context
Trait Implementations§
Auto Trait Implementations§
impl Freeze for EventBus
impl !RefUnwindSafe for EventBus
impl Send for EventBus
impl Sync for EventBus
impl Unpin for EventBus
impl UnsafeUnpin for EventBus
impl !UnwindSafe for EventBus
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more