Trait bonsaidb::core::pubsub::AsyncPubSub
source · pub trait AsyncPubSub: Send + Sync {
type Subscriber: AsyncSubscriber;
// Required methods
fn create_subscriber<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Subscriber, Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn publish_bytes<'life0, 'async_trait>(
&'life0 self,
topic: Vec<u8>,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
fn publish_bytes_to_all<'life0, 'async_trait>(
&'life0 self,
topics: impl IntoIterator<Item = Vec<u8>> + Send + 'async_trait,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
Self: 'async_trait;
// Provided methods
fn publish<'life0, 'life1, 'life2, 'async_trait, Topic, Payload>(
&'life0 self,
topic: &'life1 Topic,
payload: &'life2 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Topic: 'async_trait + Serialize + Send + Sync,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait { ... }
fn publish_to_all<'topics, 'life0, 'life1, 'async_trait, Topics, Topic, Payload>(
&'life0 self,
topics: Topics,
payload: &'life1 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where 'topics: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Topics: 'async_trait + IntoIterator<Item = &'topics Topic> + Send + 'topics,
Topic: 'async_trait + Serialize + Send + 'topics,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait { ... }
}
Expand description
Publishes and Subscribes to messages on topics.
Required Associated Types§
sourcetype Subscriber: AsyncSubscriber
type Subscriber: AsyncSubscriber
The Subscriber type for this PubSub
connection.
Required Methods§
sourcefn create_subscriber<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Subscriber, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn create_subscriber<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = Result<Self::Subscriber, Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Create a new Subscriber
for this relay.
sourcefn publish_bytes<'life0, 'async_trait>(
&'life0 self,
topic: Vec<u8>,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn publish_bytes<'life0, 'async_trait>(
&'life0 self,
topic: Vec<u8>,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Publishes a payload
to all subscribers of topic
.
sourcefn publish_bytes_to_all<'life0, 'async_trait>(
&'life0 self,
topics: impl IntoIterator<Item = Vec<u8>> + Send + 'async_trait,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
fn publish_bytes_to_all<'life0, 'async_trait>(
&'life0 self,
topics: impl IntoIterator<Item = Vec<u8>> + Send + 'async_trait,
payload: Vec<u8>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
Self: 'async_trait,
Publishes a payload
to all subscribers of all topics
.
Provided Methods§
sourcefn publish<'life0, 'life1, 'life2, 'async_trait, Topic, Payload>(
&'life0 self,
topic: &'life1 Topic,
payload: &'life2 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
fn publish<'life0, 'life1, 'life2, 'async_trait, Topic, Payload>( &'life0 self, topic: &'life1 Topic, payload: &'life2 Payload ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
Publishes a payload
to all subscribers of topic
.
sourcefn publish_to_all<'topics, 'life0, 'life1, 'async_trait, Topics, Topic, Payload>(
&'life0 self,
topics: Topics,
payload: &'life1 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'topics: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Topics: 'async_trait + IntoIterator<Item = &'topics Topic> + Send + 'topics,
Topic: 'async_trait + Serialize + Send + 'topics,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
fn publish_to_all<'topics, 'life0, 'life1, 'async_trait, Topics, Topic, Payload>(
&'life0 self,
topics: Topics,
payload: &'life1 Payload
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where
'topics: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Topics: 'async_trait + IntoIterator<Item = &'topics Topic> + Send + 'topics,
Topic: 'async_trait + Serialize + Send + 'topics,
Payload: 'async_trait + Serialize + Send + Sync,
Self: 'async_trait,
Publishes a payload
to all subscribers of all topics
.
Object Safety§
This trait is not object safe.
Implementors§
source§impl AsyncPubSub for AsyncRemoteDatabase
impl AsyncPubSub for AsyncRemoteDatabase
type Subscriber = AsyncRemoteSubscriber
source§impl AsyncPubSub for AsyncDatabase
impl AsyncPubSub for AsyncDatabase
type Subscriber = Subscriber
source§impl<B> AsyncPubSub for ServerDatabase<B>where
B: Backend,
impl<B> AsyncPubSub for ServerDatabase<B>where
B: Backend,
Uses CustomServer
’s PubSub
relay.