Skip to main content

Worker

Trait Worker 

Source
pub trait Worker: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn description(&self) -> &'static str;
    fn example(&self) -> &'static str;
    fn handle<'life0, 'async_trait>(
        &'life0 self,
        db: DatabaseConnection,
        msg: MessageEvent,
        args: HashMap<String, String>,
    ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait;
}
Expand description

A Worker receives a MessageEvent from the SensoriumLoop and handles it.

§Contract

  • The worker writes any ProcessEvents it generates to the process_events table via db.
  • Return Ok(true) if the message was accepted and handled, Ok(false) to pass.

Required Methods§

Source

fn name(&self) -> &'static str

Human-readable name used in log output to identify this worker.

Source

fn description(&self) -> &'static str

One-line description shown in /help output.

Source

fn example(&self) -> &'static str

Example invocation shown in /help output (e.g. “/task list”).

Source

fn handle<'life0, 'async_trait>( &'life0 self, db: DatabaseConnection, msg: MessageEvent, args: HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<bool>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§