aios_spec/traits/executor.rs
1use crate::intent::AuthorizedAction;
2
3/// 动作执行器
4///
5/// 接收经 PolicyEngine 校验后的 AuthorizedAction,
6/// 执行真正的系统级操作 (调整 oom_score_adj, posix_fadvise 等)。
7pub trait ActionExecutor {
8 /// 执行单个动作
9 fn execute(&self, action: &AuthorizedAction) -> ActionResult;
10
11 /// 批量执行
12 fn execute_batch(&self, actions: &[AuthorizedAction]) -> Vec<ActionResult> {
13 actions.iter().map(|a| self.execute(a)).collect()
14 }
15}
16
17/// 动作执行结果
18#[derive(Debug, Clone)]
19pub struct ActionResult {
20 /// 对应的动作
21 pub action_type: String,
22 /// 目标 (如有)
23 pub target: Option<String>,
24 /// 是否成功
25 pub success: bool,
26 /// 失败原因 (如有)
27 pub error: Option<String>,
28 /// 执行耗时 (微秒)
29 pub latency_us: u64,
30}