pub struct EventMap<E>{ /* private fields */ }Available on crate feature
event_map only.Expand description
A mediator pattern implementation for rust async rt.
Implementations§
Source§impl<E> EventMap<E>
impl<E> EventMap<E>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create new EventMap<E> instance with default config.
Sourcepub async fn once<G>(&self, event: E, guard: G) -> Result<(), EventStatus>
pub async fn once<G>(&self, event: E, guard: G) -> Result<(), EventStatus>
Listens for the event to be triggered once.
§Parameters
- guard: An RAII guard returned by some lock primitives.
Sourcepub fn notify<Q: Borrow<E>>(&self, event: Q, status: EventStatus) -> bool
pub fn notify<Q: Borrow<E>>(&self, event: Q, status: EventStatus) -> bool
Notify event listener, and set the listener status to status.
Sourcepub fn notify_all<Q: Borrow<E>, L: AsRef<[Q]>>(
&self,
event_list: L,
status: EventStatus,
)
pub fn notify_all<Q: Borrow<E>, L: AsRef<[Q]>>( &self, event_list: L, status: EventStatus, )
Notify all provided event listeners on event_list, and set the listener status to status.
pub fn close(&self)
Trait Implementations§
Auto Trait Implementations§
impl<E> !Freeze for EventMap<E>
impl<E> !RefUnwindSafe for EventMap<E>
impl<E> Send for EventMap<E>where
E: Send,
impl<E> Sync for EventMap<E>where
E: Send,
impl<E> Unpin for EventMap<E>where
E: Unpin,
impl<E> UnwindSafe for EventMap<E>where
E: UnwindSafe,
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
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more