Struct Event

Source
pub struct Event<TEventArgs = ()> { /* private fields */ }
Expand description

An event registration.

Implementations§

Source§

impl<TEventArgs> Event<TEventArgs>

Source

pub fn new() -> Self
where TEventArgs: Clone,

Source

pub fn add_fn<T>(&self, handler: T) -> Result<EventHandle<TEventArgs>, String>
where T: Fn(TEventArgs) + Send + 'static,

Source

pub fn add_fnonce<T>( &self, handler: T, ) -> Result<EventHandle<TEventArgs>, String>
where T: FnOnce(TEventArgs) + Send + 'static,

Source

pub fn add_ptr( &self, handler: FnEventHandlerDelegate<TEventArgs>, ) -> Result<EventHandle<TEventArgs>, String>

Source

pub fn len(&self) -> usize

Returns the number of currently registered handlers.

Source

pub fn invoke(&self, args: TEventArgs)
where TEventArgs: Clone,

Invokes the event.

§Arguments
  • args - The event arguments.

Trait Implementations§

Source§

impl Default for Event

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<TEventArgs> Invoke<TEventArgs> for Event<TEventArgs>
where TEventArgs: Clone,

Source§

fn invoke(&self, args: TEventArgs)

Source§

impl<TEventArgs: Send + Sync> Sync for Event<TEventArgs>

Auto Trait Implementations§

§

impl<TEventArgs> Freeze for Event<TEventArgs>

§

impl<TEventArgs> RefUnwindSafe for Event<TEventArgs>

§

impl<TEventArgs> Send for Event<TEventArgs>
where TEventArgs: Send + Sync,

§

impl<TEventArgs> Unpin for Event<TEventArgs>

§

impl<TEventArgs> UnwindSafe for Event<TEventArgs>

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.