Struct EventMap

Source
pub struct EventMap { /* private fields */ }
Expand description

An event map which allows sending messages to a set of channels

Implementations§

Source§

impl EventMap

Source

pub fn new() -> Self

Create a new EventMap

Source

pub fn register_stream<T: Clone + 'static>(&mut self) -> EventStream<T>

Register this type with the EventMap, returning a clonable Receiver end

Source

pub fn register_iter<T: Clone + 'static>(&mut self) -> EventIter<T>

Register this type with the EventMap, returning a clonable Receiver end

Source

pub fn send<T: Clone + 'static>(&mut self, msg: T) -> bool

Send this message to anything listening for it

This will automatically clean up any stale senders after it fails to send

Source

pub fn active<T: 'static>(&self) -> usize

Get the number of potential listeners for this message

Source

pub fn is_empty<T: 'static>(&self) -> bool

Determine whether there are any listeners for this message

Source

pub fn get_senders<T: 'static>(&self) -> Option<Senders<'_, T>>

Get an iterator of all senders for this type

The iterator will be over the (Id, Sender<T>)

This returns None if no active senders are available

Source

pub fn reset(&mut self)

Reset this EventMap, causing all pending Receivers to end.

After doing this, you’ll need to re-register all subscriptions

Trait Implementations§

Source§

impl Default for EventMap

Source§

fn default() -> EventMap

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

Auto Trait Implementations§

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.