Trait bonsaidb::core::pubsub::PubSub

pub trait PubSub {
    type Subscriber: Subscriber;

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

type Subscriber: Subscriber

The Subscriber type for this PubSub connection.

Required Methods§

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

Create a new Subscriber for this relay.

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

Publishes a payload to all subscribers of topic.

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

Publishes a payload to all subscribers of all topics.

Provided Methods§

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

Publishes a payload to all subscribers of topic.

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.

Implementors§