Struct EventManager

Source
pub struct EventManager<Event: Hash + Eq, Payload: Clone> { /* private fields */ }
Expand description

EventManager is used to get subscribers and emitters, but can also emit events itself

let mut manager: EventManager<StringEvent, i32> = EventManager::new();
let subscriber = manager.once("Event".into());
manager.emit("Event".into(), 57);
assert_eq!(futures::executor::block_on(subscriber), Ok(57));

Implementations§

Source§

impl<Event: Hash + Eq, Payload: Clone> EventManager<Event, Payload>

Source

pub fn new() -> Self

Create the EventManager, which can send any event, or create emitters and subscribers for a single event.

Source

pub fn emitter(&mut self, event: Event) -> Emitter<Event, Payload>

Get an Emitter that sends the specified event

Source

pub fn emitter_any(&mut self) -> EmitterAny<Event, Payload>

Get an Emitter that can send any event

Source

pub fn subscribe(&mut self, event: Event) -> Subscriber<Event, Payload>

Create a subscriber that will trigger on each of the specified event

Source

pub fn once(&mut self, event: Event) -> SubscriberOnce<Event, Payload>

Create a subscriber that will trigger only once

Source

pub fn emit(&mut self, event: Event, payload: Payload)

Emit an event with the specified Payload

Auto Trait Implementations§

§

impl<Event, Payload> Freeze for EventManager<Event, Payload>

§

impl<Event, Payload> RefUnwindSafe for EventManager<Event, Payload>

§

impl<Event, Payload> Send for EventManager<Event, Payload>
where Event: Send, Payload: Send,

§

impl<Event, Payload> Sync for EventManager<Event, Payload>
where Event: Send, Payload: Send,

§

impl<Event, Payload> Unpin for EventManager<Event, Payload>

§

impl<Event, Payload> UnwindSafe for EventManager<Event, Payload>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.