PubSubManager

Trait PubSubManager 

Source
pub trait PubSubManager {
    // Required methods
    fn subscribe(&mut self, sub: &Subscription) -> Fallible<()>;
    fn get_subscriptions(&self) -> &Vec<Subscription>;
    fn get_default_pub_socket(&self) -> &Option<ZMQSocketArc>;

    // Provided methods
    fn dispatch(&self, psmsg: PubSubMessage) { ... }
    fn publish_to_socket<T: PubSubMessageMarker + Debug>(
        &self,
        msg: &T,
        socket_mutex: &ZMQSocketArc,
    ) -> Fallible<()> { ... }
    fn publish<T: PubSubMessageMarker + Debug>(&self, msg: &T) -> Fallible<()> { ... }
}
Expand description

Generic traits any PUB/SUB manager should implement

Required Methods§

Source

fn subscribe(&mut self, sub: &Subscription) -> Fallible<()>

Add subscription to the manager

Source

fn get_subscriptions(&self) -> &Vec<Subscription>

Return the list of subscriptons

Source

fn get_default_pub_socket(&self) -> &Option<ZMQSocketArc>

Get the default publish socket (if available)

Provided Methods§

Source

fn dispatch(&self, psmsg: PubSubMessage)

Dispatch message to matching subscribers

Source

fn publish_to_socket<T: PubSubMessageMarker + Debug>( &self, msg: &T, socket_mutex: &ZMQSocketArc, ) -> Fallible<()>

Publish a message (anything with pubsub marker) to given socket Usually you would just use .publish() instead

Source

fn publish<T: PubSubMessageMarker + Debug>(&self, msg: &T) -> Fallible<()>

Publish a message (anything with pubsub marker) to default socket

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§