Trait ockam::SystemHandler

source ·
pub trait SystemHandler<C, M>: DynClonewhere
    C: Send + 'static,
    M: Message,{
    // Required methods
    fn initialize<'life0, 'life1, 'life2, 'async_trait>(
        &'life0 mut self,
        ctx: &'life1 mut C,
        routes: &'life2 mut BTreeMap<String, Address>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait,
             'life2: 'async_trait;
    fn handle_message<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        self_addr: Address,
        ctx: &'life1 mut C,
        msg: Routed<M>
    ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;
}
Expand description

Handle a single type of message for a worker system-address

A handle may re-emit messages to the worker system, or to the Ockam runtime. All state associated with a particular protocol must be contained in the type that implements this trait.

A SystemHandler is able to send messages to both external workers, and other internal handlers. To allow workers to create behaviour pipelines, we need to pre-define “routes” for a SystemHandler (i.e. where is a message sent after it is done processing it).

In most cases this only requires a “default” route, but may use different routing labels in more complicated setups (to build processing graphs, instead of pipelines).

It is highly recommended to use the SystemBuilder utility to generate this information.

Required Methods§

source

fn initialize<'life0, 'life1, 'life2, 'async_trait>( &'life0 mut self, ctx: &'life1 mut C, routes: &'life2 mut BTreeMap<String, Address> ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait, 'life2: 'async_trait,

Setup internal route path for this handler

This function is only called once with a route map. To generate this route map see the SystemBuilder utility.

source

fn handle_message<'life0, 'life1, 'async_trait>( &'life0 mut self, self_addr: Address, ctx: &'life1 mut C, msg: Routed<M> ) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Called for every message addressed to the system handler

Implementors§