pub trait EventSubscriber {
// Required methods
fn subscribe<'life0, 'async_trait>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Subscriber>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn subscribe_with_type<'life0, 'async_trait, T>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<impl Stream<Item = Result<T>> + Send>> + Send + 'async_trait>>
where T: 'async_trait + for<'de> Deserialize<'de> + Send + 'static,
Self: 'async_trait,
'life0: 'async_trait;
}Expand description
An EventSubscriber is an object that can subscribe to events.
This trait provides methods to subscribe to events published on specific subjects.
Required Methods§
Sourcefn subscribe<'life0, 'async_trait>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Subscriber>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe<'life0, 'async_trait>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<Subscriber>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to events with the given event name.
The event_name will be . concatenated with the base subject provided by the implementation.
Returns a subscriber that can be used to receive events.
Sourcefn subscribe_with_type<'life0, 'async_trait, T>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<impl Stream<Item = Result<T>> + Send>> + Send + 'async_trait>>where
T: 'async_trait + for<'de> Deserialize<'de> + Send + 'static,
Self: 'async_trait,
'life0: 'async_trait,
fn subscribe_with_type<'life0, 'async_trait, T>(
&'life0 self,
event_name: impl 'async_trait + AsRef<str> + Send + Sync,
) -> Pin<Box<dyn Future<Output = Result<impl Stream<Item = Result<T>> + Send>> + Send + 'async_trait>>where
T: 'async_trait + for<'de> Deserialize<'de> + Send + 'static,
Self: 'async_trait,
'life0: 'async_trait,
Subscribe to events with the given event name and deserialize them to the specified type. This is a convenience method that combines subscribe and deserialization.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.