From 860fb317bca61ce66a2c98df933aa666dae0a43f Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 13 Oct 2025 11:17:00 +0800 Subject: feat: Add JSON-based action invocation to ActionPool - Extend action_gen macro to generate JSON serialization logic - Implement generic action processing using JSON text for type-agnostic calls - Add callback mechanism with action name and arguments in ActionPool - Update client and server registries to use new callback system - Improve action system flexibility at the cost of serialization overhead --- crates/system_action/src/action_pool.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'crates/system_action/src') diff --git a/crates/system_action/src/action_pool.rs b/crates/system_action/src/action_pool.rs index bc60f7f..a3e82d6 100644 --- a/crates/system_action/src/action_pool.rs +++ b/crates/system_action/src/action_pool.rs @@ -72,7 +72,7 @@ impl ActionPool { &'a self, action_name: &'a str, context: ActionContext, - args: Args, + args_json: String, ) -> Result where Args: serde::de::DeserializeOwned + Send + 'static, @@ -80,6 +80,8 @@ impl ActionPool { { if let Some(action) = self.actions.get(action_name) { let _ = self.exec_on_proc_begin(&context).await?; + let args: Args = serde_json::from_str(&args_json) + .map_err(|e| TcpTargetError::Serialization(format!("Deserialize failed: {}", e)))?; let result = action.process_erased(context, Box::new(args)).await?; let result = *result .downcast::() -- cgit