acton_core::prelude

Trait Subscribable

Source
pub trait Subscribable {
    // Required methods
    fn subscribe<T: ActonMessage + Send + Sync + 'static>(
        &self,
    ) -> impl Future<Output = ()> + Send + Sync + '_
       where Self: Actor + Subscriber;
    fn unsubscribe<T: ActonMessage>(&self)
       where Self: Actor + Subscriber + Send + Sync + 'static;
}
Expand description

Trait for types that can subscribe to and unsubscribe from messages.

Required Methods§

Source

fn subscribe<T: ActonMessage + Send + Sync + 'static>( &self, ) -> impl Future<Output = ()> + Send + Sync + '_
where Self: Actor + Subscriber,

Subscribes the implementing type to messages of type T.

§Type Parameters
  • T: The type of message to subscribe to. Must implement ActonMessage + Send + Sync + 'static.
§Returns

A Future that resolves to () when the subscription is complete.

Source

fn unsubscribe<T: ActonMessage>(&self)
where Self: Actor + Subscriber + Send + Sync + 'static,

Unsubscribes the implementing type from messages of type T.

§Type Parameters
  • T: The type of message to unsubscribe from. Must implement ActonMessage.

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.

Implementors§

Source§

impl<T> Subscribable for T
where T: ActonMessage + Send + Sync + 'static,

Implementation of Subscribable for any type that implements ActonMessage + Send + Sync + 'static.