Struct bee_runtime::event::Bus[][src]

pub struct Bus<'a, ID = TypeId> { /* fields omitted */ }

An event bus for arbitrary event types.

Implementations

impl<'a, ID: Clone + PartialEq> Bus<'a, ID>[src]

pub fn dispatch<E: Any>(&self, event: E)[src]

Dispatch an event via this event bus.

All active listeners registered for this event will be invoked.

pub fn add_listener_raw<E: Any, F: Fn(&E) + Send + Sync + 'a>(
    &self,
    id: ID,
    handler: F
)
[src]

Add an event listener bound to a specific event type, E, and registered with the given ID.

pub fn remove_listeners_by_id(&self, id: ID)[src]

Remove all event listeners registered with the given ID, dropping them in the process.

impl<'a> Bus<'a, TypeId>[src]

pub fn add_listener<T: Any, E: Any, F: Fn(&E) + Send + Sync + 'a>(
    &self,
    handler: F
)
[src]

Add an event listener bound to a specific event type, E, and bound to a type T.

This event listener will be removed when Bus::remove_listeners_by_id is called with the TypeId of T.

pub fn add_static_listener<E: Any, F: Fn(&E) + Send + Sync + 'a>(
    &self,
    handler: F
)
[src]

Add an event listener bound to a specific event type, E, registered using a hidden type that will prevent its removal until the event bus is dropped.

Trait Implementations

impl<'a, ID> Default for Bus<'a, ID>[src]

Auto Trait Implementations

impl<'a, ID = TypeId> !RefUnwindSafe for Bus<'a, ID>[src]

impl<'a, ID> Send for Bus<'a, ID> where
    ID: Send
[src]

impl<'a, ID> Sync for Bus<'a, ID> where
    ID: Send + Sync
[src]

impl<'a, ID> Unpin for Bus<'a, ID>[src]

impl<'a, ID = TypeId> !UnwindSafe for Bus<'a, ID>[src]

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.