Trait bonsaidb::core::pubsub::PubSub

source ·
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, Payload>(
        &self,
        topic: &Topic,
        payload: &Payload
    ) -> Result<(), Error>
       where Topic: Serialize,
             Payload: Serialize { ... }
    fn publish_to_all<'topics, Topics, Topic, Payload>(
        &self,
        topics: Topics,
        payload: &Payload
    ) -> Result<(), Error>
       where Topics: IntoIterator<Item = &'topics Topic> + 'topics,
             Topic: Serialize + 'topics,
             Payload: Serialize { ... }
}
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, Payload>( &self, topic: &Topic, payload: &Payload ) -> Result<(), Error>
where Topic: Serialize, Payload: Serialize,

Publishes a payload to all subscribers of topic.

source

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

Publishes a payload to all subscribers of all topics.

Object Safety§

This trait is not object safe.

Implementors§