[][src]Trait maxim::actors::Processor

pub trait Processor<S: Send + Sync, R: Future<Output = ActorResult<S>> + Send + 'static>: FnMut(S, Context, Message) -> R + Send + Sync { }

A type for a function that processes messages for an actor.

This will be passed to a spawn function to specify the function used for managing the state of the actor based on the messages passed to the actor. The processor should return the status of the actor, as well as the potentially modified state. If the actor returns Err then it will be stopped as if the actor had returned Stop. The processor takes three arguments:

  • state - The current state of the actor.
  • context - The immutable context for this actor and its system.
  • message - The current message to process. The actor must return the state on success as a (State, Status) tuple. See Status for helper methods for returns.

Implementors

impl<F, S, R> Processor<S, R> for F where
    S: Send + Sync,
    R: Future<Output = ActorResult<S>> + Send + 'static,
    F: FnMut(S, Context, Message) -> R + Send + Sync + 'static, 
[src]

Loading content...