Trait ockam::Worker

source ·
pub trait Worker: Send + 'static {
    type Message: Message;
    type Context: Send + 'static;

    // Provided methods
    fn initialize<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn shutdown<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
    fn handle_message<'life0, 'life1, 'async_trait>(
        &'life0 mut self,
        _context: &'life1 mut Self::Context,
        _msg: Routed<Self::Message>
    ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait { ... }
}
Expand description

Defines the core interface shared by all Ockam Workers.

While all methods do not need to be implemented, at the very least, the Context and Message types need to be specified before a worker can be used in any call to a Context API such as context.start_worker(...).

Required Associated Types§

source

type Message: Message

The type of Message the Worker is sent in Self::handle_message.

source

type Context: Send + 'static

The API and other resources available for the worker during message processing.

Currently, this should be always ockam::Context or ockam_node::Context (which are the same type), but in the future custom node implementations may use a different context type.

Provided Methods§

source

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

Override initialisation behaviour.

source

fn shutdown<'life0, 'life1, 'async_trait>( &'life0 mut self, _context: &'life1 mut Self::Context ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Override shutdown behaviour.

source

fn handle_message<'life0, 'life1, 'async_trait>( &'life0 mut self, _context: &'life1 mut Self::Context, _msg: Routed<Self::Message> ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Try to open and handle a typed message.

Implementations on Foreign Types§

source§

impl Worker for CredentialsIssuer

§

type Context = Context

§

type Message = Vec<u8>

source§

fn handle_message<'life0, 'life1, 'async_trait>( &'life0 mut self, c: &'life1 mut Context, m: Routed<<CredentialsIssuer as Worker>::Message> ) -> Pin<Box<dyn Future<Output = Result<(), Error>> + Send + 'async_trait>>where 'life0: 'async_trait, 'life1: 'async_trait, CredentialsIssuer: 'async_trait,

source§

impl Worker for NullWorker

Implementors§