pub struct EventManager<T> { /* private fields */ }
Expand description

Allows event subscribers to be registered, connected to the event loop, and later removed.

Implementations§

source§

impl<S: MutEventSubscriber> EventManager<S>

source

pub fn new() -> Result<Self>

Create a new EventManger object.

source

pub fn new_with_capacity(ready_events_capacity: usize) -> Result<Self>

Creates a new EventManger object with specified event capacity.

Arguments
  • ready_events_capacity: maximum number of ready events to be processed a single run. The maximum value of this parameter is EventManager::MAX_READY_EVENTS_CAPACITY.
source

pub fn run(&mut self) -> Result<usize>

Run the event loop blocking until events are triggered or an error is returned. Calls subscriber.process() for each event.

On success, it returns number of dispatched events or 0 when interrupted by a signal.

source

pub fn run_with_timeout(&mut self, milliseconds: i32) -> Result<usize>

Wait for events for a maximum timeout of miliseconds or until an error is returned. Calls subscriber.process() for each event.

On success, it returns number of dispatched events or 0 when interrupted by a signal.

source§

impl<S: MutEventSubscriber> EventManager<S>

source

pub fn remote_endpoint(&self) -> RemoteEndpoint<S>

Available on crate feature remote_endpoint only.

Return a RemoteEndpoint object, that allows interacting with the EventManager from a different thread. Using RemoteEndpoint::call_blocking on the same thread the event loop runs on leads to a deadlock.

Trait Implementations§

source§

impl<T: Debug> Debug for EventManager<T>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<T: MutEventSubscriber> SubscriberOps for EventManager<T>

source§

fn add_subscriber(&mut self, subscriber: T) -> SubscriberId

Register a subscriber with the event event_manager and returns the associated ID.

source§

fn remove_subscriber(&mut self, subscriber_id: SubscriberId) -> Result<T>

Unregisters and returns the subscriber associated with the provided ID.

source§

fn subscriber_mut(&mut self, subscriber_id: SubscriberId) -> Result<&mut T>

Return a mutable reference to the subscriber associated with the provided id.

source§

fn event_ops(&mut self, subscriber_id: SubscriberId) -> Result<EventOps<'_>>

Returns a EventOps object for the subscriber associated with the provided ID.

§

type Subscriber = T

Subscriber type for which the operations apply.

Auto Trait Implementations§

§

impl<T> RefUnwindSafe for EventManager<T>
where T: RefUnwindSafe,

§

impl<T> Send for EventManager<T>
where T: Send,

§

impl<T> !Sync for EventManager<T>

§

impl<T> Unpin for EventManager<T>
where T: Unpin,

§

impl<T> UnwindSafe for EventManager<T>
where T: UnwindSafe,

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>,

§

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>,

§

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.