pub trait PubSub {
    type Subscriber: Subscriber;

    // Required methods
    fn create_subscriber(&self) -> Result<Self::Subscriber, Error>;
    fn publish_bytes(
        &self,
        topic: Vec<u8>,
        payload: Vec<u8>
    ) -> Result<(), Error>;
    fn publish_bytes_to_all(
        &self,
        topics: impl IntoIterator<Item = Vec<u8>> + Send,
        payload: Vec<u8>
    ) -> Result<(), Error>;

    // Provided methods
    fn publish<Topic: Serialize, Payload: Serialize>(
        &self,
        topic: &Topic,
        payload: &Payload
    ) -> Result<(), Error> { ... }
    fn publish_to_all<'topics, Topics: IntoIterator<Item = &'topics Topic> + 'topics, Topic: Serialize + 'topics, Payload: Serialize>(
        &self,
        topics: Topics,
        payload: &Payload
    ) -> Result<(), Error> { ... }
}
Expand description

Publishes and Subscribes to messages on topics.

Required Associated Types§

source

type Subscriber: Subscriber

The Subscriber type for this PubSub connection.

Required Methods§

source

fn create_subscriber(&self) -> Result<Self::Subscriber, Error>

Create a new Subscriber for this relay.

source

fn publish_bytes(&self, topic: Vec<u8>, payload: Vec<u8>) -> Result<(), Error>

Publishes a payload to all subscribers of topic.

source

fn publish_bytes_to_all( &self, topics: impl IntoIterator<Item = Vec<u8>> + Send, payload: Vec<u8> ) -> Result<(), Error>

Publishes a payload to all subscribers of all topics.

Provided Methods§

source

fn publish<Topic: Serialize, Payload: Serialize>( &self, topic: &Topic, payload: &Payload ) -> Result<(), Error>

Publishes a payload to all subscribers of topic.

source

fn publish_to_all<'topics, Topics: IntoIterator<Item = &'topics Topic> + 'topics, Topic: Serialize + 'topics, Payload: Serialize>( &self, topics: Topics, payload: &Payload ) -> Result<(), Error>

Publishes a payload to all subscribers of all topics.

Object Safety§

This trait is not object safe.

Implementors§