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: 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§
sourcetype Subscriber: Subscriber
type Subscriber: Subscriber
The Subscriber type for this PubSub
connection.
Required Methods§
sourcefn create_subscriber(&self) -> Result<Self::Subscriber, Error>
fn create_subscriber(&self) -> Result<Self::Subscriber, Error>
Create a new Subscriber
for this relay.
Provided Methods§
sourcefn publish<Topic: Serialize, Payload: Serialize>(
&self,
topic: &Topic,
payload: &Payload
) -> Result<(), Error>
fn publish<Topic: Serialize, Payload: Serialize>( &self, topic: &Topic, payload: &Payload ) -> Result<(), Error>
Publishes a payload
to all subscribers of topic
.
sourcefn publish_to_all<'topics, Topics: IntoIterator<Item = &'topics Topic> + 'topics, Topic: Serialize + 'topics, Payload: Serialize>(
&self,
topics: Topics,
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>
Publishes a payload
to all subscribers of all topics
.