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 stream<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: Value,
_ctx: &'life1 Context<Value>,
) -> Pin<Box<dyn Future<Output = Option<Result<Vec<Value>, ModuleError>>> + Send + 'async_trait>>
where Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait { ... }
fn supports_stream(&self) -> bool { ... }
fn describe(&self) -> Value { ... }
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§
Sourcefn input_schema(&self) -> Value
fn input_schema(&self) -> Value
Returns the JSON Schema describing this module’s input.
Sourcefn output_schema(&self) -> Value
fn output_schema(&self) -> Value
Returns the JSON Schema describing this module’s output.
Sourcefn description(&self) -> &str
fn description(&self) -> &str
Returns a human-readable description of this module.
Sourcefn 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,
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§
Sourcefn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: Value,
_ctx: &'life1 Context<Value>,
) -> Pin<Box<dyn Future<Output = Option<Result<Vec<Value>, ModuleError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn stream<'life0, 'life1, 'async_trait>(
&'life0 self,
_inputs: Value,
_ctx: &'life1 Context<Value>,
) -> Pin<Box<dyn Future<Output = Option<Result<Vec<Value>, ModuleError>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Stream execution — yields chunks incrementally.
Default implementation calls execute() once and returns the result
as a single-element vector. Modules that support streaming should
override this to yield multiple chunks.
Returns None if the module does not support streaming, signaling
the executor to fall back to execute().
Sourcefn supports_stream(&self) -> bool
fn supports_stream(&self) -> bool
Whether this module supports streaming output.
Sourcefn describe(&self) -> Value
fn describe(&self) -> Value
Return a structured description of this module for AI/LLM consumption (spec §5.6). Default: builds description from input_schema, output_schema, and description.
Sourcefn preflight(&self) -> PreflightResult
fn preflight(&self) -> PreflightResult
Run preflight checks before execution.
Sourcefn on_suspend(&self) -> Option<Value>
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).