[−][src]Struct concurrent_event::Event
An event manages multiple handlers which can be registered.
Type Parameters
A
: The type of event arguments which are distributed to the handlers.H
: The type of event handlers which can be registered with this event. To allow for different types, useBox<dyn EventHandler<...>>
.
Implementations
impl<A: Copy + Send, H: EventHandler<A>> Event<A, H>
[src]
pub fn new() -> Event<A, H>
[src]
Creates a new event without handlers.
pub fn emit(&mut self, arg: A) -> bool
[src]
Emits an event, invoking all currently registered handlers in parallel.
If all event handlers terminated without panicking, true
is returned.
If any event handler panics, false
is returned.
Parameters
arg
: The event argument to dispatch.
pub fn add_handler(&mut self, handler: H) -> HandlerId
[src]
Adds an event handler to notify for future events. A handler ID is returned, which can be used to identify the handler later.
Parameters
handler
: The event handler to register.
pub fn get_handler(&self, id: HandlerId) -> Option<&H>
[src]
Gets a reference to the event handler registered under the given ID
wrapped in a Some
option variant. If no such handler is registered,
None
is returned.
Parameters
id
: The handler ID for which to get the associated event handler.
impl<'a, A: Copy + Send> Event<A, Box<dyn EventHandler<A> + 'a>>
[src]
pub fn add_handler_boxed(
&'a mut self,
handler: impl EventHandler<A> + 'a
) -> HandlerId
[src]
&'a mut self,
handler: impl EventHandler<A> + 'a
) -> HandlerId
Adds an event handler wrapped into a box to this event. This is mainly
syntactic sugar for event.add_handler(Box::new(handler))
.
Parameters
handler
: The event handler to wrap in a box and register with this event.
Auto Trait Implementations
impl<A, H> RefUnwindSafe for Event<A, H> where
A: RefUnwindSafe,
H: RefUnwindSafe,
A: RefUnwindSafe,
H: RefUnwindSafe,
impl<A, H> Send for Event<A, H>
impl<A, H> Sync for Event<A, H> where
A: Sync,
H: Sync,
A: Sync,
H: Sync,
impl<A, H> Unpin for Event<A, H> where
A: Unpin,
H: Unpin,
A: Unpin,
H: Unpin,
impl<A, H> UnwindSafe for Event<A, H> where
A: UnwindSafe,
H: UnwindSafe,
A: UnwindSafe,
H: UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,