[][src]Struct ripb::Subscriber

pub struct Subscriber { /* fields omitted */ }

A subscriber to a Bus.

Subscribers are created with the method [Bus.create_subscriber]

Register new callbacks with the [on_message] method, callback will live until the subscriber is dropped. If you need more control on callback lifecycle use [on_message_with_token] that will give you a SubscriptionToken you can use to [unsubscribe] a callback.

Methods

impl Subscriber[src]

pub fn on_message<F, M>(&self, callback: F) -> Result<(), DeadBusError> where
    F: Fn(&M) + Send + 'static,
    M: Message + 'static, 
[src]

Register a new callback to be called each time a message of the given type is published on the bus, callback lives as until the Subscriber is dropped

pub fn on_message_with_token<F, M>(
    &self,
    callback: F
) -> Result<SubscriptionToken, DeadBusError> where
    F: Fn(&M) + Send + 'static,
    M: Message + 'static, 
[src]

Register a new callback to be called each time a message of the given type is published on the bus, callback lives as until the SubscriptionToken is dropped, unsubscribe is called on it or the Subscriber is dropped

Trait Implementations

impl Drop for Subscriber[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Message for T where
    T: Send + Sync
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]