Trait ockam::SystemHandler
source · [−]pub trait SystemHandler<C, M>: DynClone where
C: Send + 'static,
M: Message, {
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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: '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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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
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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
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.
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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: '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>>ⓘNotable traits for Pin<P>impl<P> Future for Pin<P> where
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
where
'life0: 'async_trait,
'life1: 'async_trait,
Self: 'async_trait,
P: DerefMut,
<P as Deref>::Target: Future, type Output = <<P as Deref>::Target as Future>::Output;
Called for every message addressed to the system handler