Skip to main content

Module

Trait Module 

Source
pub trait Module: Send + Sync {
    // Required methods
    fn input_schema(&self) -> Value;
    fn output_schema(&self) -> Value;
    fn description(&self) -> &str;
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        inputs: Value,
        ctx: &'life1 Context<Value>,
    ) -> Pin<Box<dyn Future<Output = Result<Value, ModuleError>> + Send + 'async_trait>>
       where Self: 'async_trait,
             'life0: 'async_trait,
             'life1: 'async_trait;

    // Provided methods
    fn preflight(&self) -> PreflightResult { ... }
    fn on_load(&self) { ... }
    fn on_unload(&self) { ... }
    fn on_suspend(&self) -> Option<Value> { ... }
    fn on_resume(&self, _state: Value) { ... }
}
Expand description

Core trait that all APCore modules must implement.

Required Methods§

Source

fn input_schema(&self) -> Value

Returns the JSON Schema describing this module’s input.

Source

fn output_schema(&self) -> Value

Returns the JSON Schema describing this module’s output.

Source

fn description(&self) -> &str

Returns a human-readable description of this module.

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, inputs: Value, ctx: &'life1 Context<Value>, ) -> Pin<Box<dyn Future<Output = Result<Value, ModuleError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Execute the module with the given inputs and context.

Provided Methods§

Source

fn preflight(&self) -> PreflightResult

Run preflight checks before execution.

Source

fn on_load(&self)

Called after the module is registered. Default: no-op.

Source

fn on_unload(&self)

Called before the module is unregistered. Default: no-op.

Source

fn on_suspend(&self) -> Option<Value>

Called before hot-reload to capture state. Returns state dict for on_resume(). Default: returns None (no state to preserve).

Source

fn on_resume(&self, _state: Value)

Called after hot-reload to restore state from on_suspend(). Default: no-op.

Implementors§