Skip to main content

IoHandler

Trait IoHandler 

Source
pub trait IoHandler: Send + Sync {
    // Required method
    fn execute<'life0, 'life1, 'async_trait>(
        &'life0 self,
        params: &'life1 JsonValue,
    ) -> Pin<Box<dyn Future<Output = Result<JsonValue, String>> + Send + 'async_trait>>
       where 'life0: 'async_trait,
             'life1: 'async_trait,
             Self: 'async_trait;
}
Expand description

I/O handler trait — all I/O handlers implement this interface.

Uses #[async_trait] to make the trait object-safe, enabling Arc<dyn IoHandler> dynamic dispatch.

params comes from Fact::IoRequest.params, already resolved from path references into concrete values by the TCB.

§Implementer responsibilities

  • Extract the required fields from params (e.g. url, query, key)
  • Perform the actual I/O operation (HTTP request, SQL query, file I/O, etc.)
  • Return Ok(JsonValue) or Err(String)

§Callers

  • The governance IoDispatcher dispatches to the matching handler by IoType
  • The governance IoSubscriber subscribes to Fact::IoRequest and calls dispatch

Required Methods§

Source

fn execute<'life0, 'life1, 'async_trait>( &'life0 self, params: &'life1 JsonValue, ) -> Pin<Box<dyn Future<Output = Result<JsonValue, String>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Execute the I/O operation.

§Parameters
  • params: I/O request parameters (passed through by the io_request instruction; e.g. call_external carries {"messages": [...], "tools": [...]}, call_service carries {"service_name": "...", "args": {...}})
§Returns
  • Ok(JsonValue): I/O result (injected into payload.__io_results__.{io_type})
  • Err(String): error message (recorded into IoResponse.error; the result is not consumed)

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§