pub trait Actor: Addr {
type Context;
// Required methods
fn ctx<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = RwLockReadGuard<'_, Self::Context>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn ctx_mut<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = RwLockWriteGuard<'_, Self::Context>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait;
fn start<'async_trait, Id>(
id: Id,
ctx: Self::Context
) -> Pin<Box<dyn Future<Output = Result<StrongAddr<Self>>> + Send + 'async_trait>>
where Id: 'async_trait + Into<ActorId> + Send,
Self: 'async_trait;
}Expand description
Actor trait that all generic (non-specialized) actors must implement.
Usage
Implementation is generated by the [vin::actor] proc macro.
Behind the scenes
The way actors work in [vin] is that they live in their own tokio task, polling messages sent
and starting handler tasks for each message received. Shutdown is also synchronized and actors
will be given time to gracefully shutdown before being forcibly closed.
Required Associated Types§
Required Methods§
sourcefn ctx<'life0, 'async_trait>(
&'life0 self
) -> Pin<Box<dyn Future<Output = RwLockReadGuard<'_, Self::Context>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ctx<'life0, 'async_trait>( &'life0 self ) -> Pin<Box<dyn Future<Output = RwLockReadGuard<'_, Self::Context>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait,
Returns a read lock to the underlying actor context.