1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
// SPDX-License-Identifier: AGPL-3.0-or-later
// Copyright (C) 2026 EvoRule Project
// This file is part of EvoRule, licensed under GNU Affero General Public License v3 or later.
//! I/O handler trait — object-safe, supports dynamic dispatch via trait objects.
//!
//! This contract was historically defined inside the reactor crate (itself
//! moved there from governance during the H5 architecture-debt fix). It now
//! lives at the base-primitive layer so that any ecosystem block can speak
//! the I/O handler contract without depending on the canonical execution
//! crates; the reactor re-exports it unchanged.
//!
//! # Usage example
//!
//! ```
//! use async_trait::async_trait;
//! use evorule_primitives::{IoHandler, IoResult};
//! use evorule_primitives::JsonValue;
//!
//! struct EchoHandler;
//!
//! #[async_trait]
//! impl IoHandler for EchoHandler {
//! async fn execute(&self, params: &JsonValue) -> IoResult {
//! Ok(params.clone())
//! }
//! }
//! ```
use crateJsonValue;
use Box;
use String;
use async_trait;
/// I/O execution result.
///
/// On success returns a [`JsonValue`] (injected into
/// `payload.__io_results__.{io_type}` by the reactor); on failure returns an
/// error message (recorded into the `IoResponse.error` field).
pub type IoResult = ;
/// 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