pub trait SubscriptionHandler<R>{
// Required methods
fn subscribe<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_with_filter<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
filter: Box<dyn SubscriptionFilter<R> + Send + Sync>,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn unsubscribe<'life0, 'async_trait>(
&'life0 mut self,
id: usize,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn broadcast<'life0, 'async_trait>(
&'life0 self,
topic: String,
message: R,
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
}Expand description
A trait that defines the behavior for handling subscriptions. The intended use is for async nodes to register and manage subscriptions in a generic way.
Required Methods§
Sourcefn subscribe<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to a topic or event. Any message broadcast to the topic will be sent to the subscriber.
§Parameters
topic: The topic or event to subscribe to.subscription_information: Information related to the subscription.broadcast_tx: The broadcast channel to send messages to the subscriber.respond_to: The channel to send a response to acknowledge the subscription.
Sourcefn subscribe_with_filter<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
filter: Box<dyn SubscriptionFilter<R> + Send + Sync>,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_with_filter<'life0, 'async_trait>(
&'life0 mut self,
topic: String,
filter: Box<dyn SubscriptionFilter<R> + Send + Sync>,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to a topic or event with a filter. The filter will be used to determine if a message should be sent to the subscriber when an event on the topic occurs.
§Parameters
topic: The topic or event to subscribe to.subscription_information: Information related to the subscription.filter: The filter to apply to the subscription.broadcast_tx: The broadcast channel to send messages to the subscriber.respond_to: The channel to send a response to acknowledge the subscription.
Sourcefn unsubscribe<'life0, 'async_trait>(
&'life0 mut self,
id: usize,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn unsubscribe<'life0, 'async_trait>(
&'life0 mut self,
id: usize,
respond_to: SubscriptionResponseTx,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Unsubscribe from a topic or event.
§Parameters
topic: The topic or event to unsubscribe from.subscription_information: Information related to the subscription.respond_to: The channel to send a response to acknowledge the unsubscription.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".