[][src]Trait meio::Actor

pub trait Actor: Sized + Send + 'static {
    fn name(&self) -> String { ... }
fn start<T>(self, supervisor: Option<T>) -> Address<Self>
    where
        T: Into<Controller> + Send
, { ... }
#[must_use] fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _ctx: &'life1 mut Context<Self>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... }
#[must_use] fn stop_signal<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        child: Option<Id>,
        ctx: &'life1 mut Context<Self>
    ) -> Pin<Box<dyn Future<Output = TerminationProgress> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        'life1: 'async_trait,
        Self: 'async_trait
, { ... }
#[must_use] fn terminate<'life0, 'async_trait>(
        &'life0 mut self
    ) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
, { ... } }

The main trait. Your structs have to implement it to be compatible with ActorRuntime and Address system.

Provided methods

fn name(&self) -> String

Returns unique name of the Actor. Uses Uuid by default.

fn start<T>(self, supervisor: Option<T>) -> Address<Self> where
    T: Into<Controller> + Send

Starts an actor

#[must_use]fn initialize<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    _ctx: &'life1 mut Context<Self>
) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Called when actor initializing. You should spawn workers here if needed.

Don't worry if this method failed. terminate will be called in any case and you can finalize all workers there.

#[must_use]fn stop_signal<'life0, 'life1, 'async_trait>(
    &'life0 mut self,
    child: Option<Id>,
    ctx: &'life1 mut Context<Self>
) -> Pin<Box<dyn Future<Output = TerminationProgress> + Send + 'async_trait>> where
    'life0: 'async_trait,
    'life1: 'async_trait,
    Self: 'async_trait, 

Called on every potential shutdown signal received.

#[must_use]fn terminate<'life0, 'async_trait>(
    &'life0 mut self
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>> where
    'life0: 'async_trait,
    Self: 'async_trait, 

Called when actor teminating. This method doesn't have a result to don't allow you to use ? operator that can interrupt termination and resources releasing process. You should also terminate workers here.

This method will be called even if initialization failed.

If you have optional fields filled during initialization, don't unwrap them, because they can be None.

Loading content...

Implementors

Loading content...