[][src]Trait event_manager::SubscriberOps

pub trait SubscriberOps {
    type Subscriber: MutEventSubscriber;
    fn add_subscriber(&mut self, subscriber: Self::Subscriber) -> SubscriberId;
fn remove_subscriber(
        &mut self,
        subscriber_id: SubscriberId
    ) -> Result<Self::Subscriber>;
fn subscriber_mut(
        &mut self,
        subscriber_id: SubscriberId
    ) -> Result<&mut Self::Subscriber>;
fn event_ops(&mut self, subscriber_id: SubscriberId) -> Result<EventOps<'_>>; }

API that allows users to add, remove, and interact with registered subscribers.

Associated Types

type Subscriber: MutEventSubscriber

Subscriber type for which the operations apply.

Loading content...

Required methods

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

Registers a new subscriber and returns the ID associated with it.

Panics

This function might panic if the subscriber is already registered. Whether a panic is triggered depends on the implementation of Subscriber::init().

Typically, in the init function, the subscriber adds fds to its interest list. The same fd cannot be added twice and the EventManager will return Error::FdAlreadyRegistered. Using unwrap in init in this situation triggers a panic.

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

Removes the subscriber corresponding to subscriber_id from the watch list.

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

Returns a mutable reference to the subscriber corresponding to subscriber_id.

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

Creates an event operations wrapper for the subscriber corresponding to subscriber_id.

The event operations can be used to update the events monitored by the subscriber.

Loading content...

Implementors

impl<T: MutEventSubscriber> SubscriberOps for EventManager<T>[src]

type Subscriber = T

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

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

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

Unregisters and returns the subscriber associated with the provided ID.

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

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

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

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

Loading content...