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§
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, Payload>(
&self,
topic: &Topic,
payload: &Payload
) -> Result<(), Error>
fn publish<Topic, Payload>( &self, topic: &Topic, payload: &Payload ) -> Result<(), Error>
Publishes a payload
to all subscribers of topic
.
sourcefn 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,
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.