aios_action/
offline_adapter.rs1use aios_core::governance::{ActionAdapter, AuthorizedAction};
7use aios_spec::governance::{ActionOutcome, AdapterError};
8use aios_spec::intent::ActionType;
9
10#[derive(Debug, Clone, Copy, Default)]
12pub struct OfflineAdapter;
13
14impl OfflineAdapter {
15 pub fn new() -> Self {
16 Self
17 }
18}
19
20impl ActionAdapter for OfflineAdapter {
21 fn name(&self) -> &'static str {
22 "offline"
23 }
24
25 fn execute(&self, authorized: &AuthorizedAction) -> Result<ActionOutcome, AdapterError> {
26 let action = authorized.action();
27 let action_type_name = format!("{:?}", action.action_type);
28 let target = action.target.clone();
29
30 let summary = match action.action_type {
31 ActionType::NoOp => "noop".to_string(),
32 ActionType::PreWarmProcess => {
33 format!(
34 "simulate_prewarm:{}",
35 target.as_deref().unwrap_or("unknown")
36 )
37 },
38 ActionType::PrefetchFile => {
39 format!("simulate_cache:{}", target.as_deref().unwrap_or("unknown"))
40 },
41 ActionType::KeepAlive => {
42 format!(
43 "simulate_keepalive:{}",
44 target.as_deref().unwrap_or("system")
45 )
46 },
47 ActionType::ReleaseMemory => {
48 format!("simulate_release:{}", target.as_deref().unwrap_or("system"))
49 },
50 };
51
52 Ok(ActionOutcome {
53 action_type: action_type_name,
54 target,
55 summary,
56 latency_us: 0,
57 })
58 }
59}