From b2c45bf5c16391917caccd703ac85b80c5c77cca Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Fri, 24 Oct 2025 14:47:20 +0800 Subject: Re-export subcrate `action_system` to `just_enough_vcs` --- crates/system_action/src/lib.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'crates/system_action') diff --git a/crates/system_action/src/lib.rs b/crates/system_action/src/lib.rs index 07be1bb..12ae999 100644 --- a/crates/system_action/src/lib.rs +++ b/crates/system_action/src/lib.rs @@ -1,5 +1,6 @@ -pub use action_system_macros::*; -pub extern crate action_system_macros as macros; +pub mod macros { + pub use action_system_macros::*; +} pub mod action; pub mod action_pool; -- cgit From 45cee7d8def7738d3347b201d3c54c0055817a4c Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 27 Oct 2025 17:20:01 +0800 Subject: fix: Make the ActionContext passed to on_proc_begin mutable --- crates/system_action/action_macros/src/lib.rs | 2 +- crates/system_action/src/action_pool.rs | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) (limited to 'crates/system_action') diff --git a/crates/system_action/action_macros/src/lib.rs b/crates/system_action/action_macros/src/lib.rs index ce50073..7362cdf 100644 --- a/crates/system_action/action_macros/src/lib.rs +++ b/crates/system_action/action_macros/src/lib.rs @@ -64,7 +64,7 @@ fn generate_action_struct(input_fn: ItemFn, _is_local: bool) -> proc_macro2::Tok #fn_vis async fn #proc_this_action( pool: &action_system::action_pool::ActionPool, - ctx: action_system::action::ActionContext, + mut ctx: action_system::action::ActionContext, #arg_param_name: #arg_type ) -> Result<#return_type, tcp_connection::error::TcpTargetError> { let args_json = serde_json::to_string(&#arg_param_name) diff --git a/crates/system_action/src/action_pool.rs b/crates/system_action/src/action_pool.rs index c28de1e..c3ad4a1 100644 --- a/crates/system_action/src/action_pool.rs +++ b/crates/system_action/src/action_pool.rs @@ -7,7 +7,7 @@ use tcp_connection::error::TcpTargetError; use crate::action::{Action, ActionContext}; type ProcBeginCallback = for<'a> fn( - &'a ActionContext, + &'a mut ActionContext, args: &'a (dyn std::any::Any + Send + Sync), ) -> ProcBeginFuture<'a>; type ProcEndCallback = fn() -> ProcEndFuture; @@ -94,9 +94,9 @@ impl ActionPool { if let Some(action) = self.actions.get(action_name) { // Set action name and args in context for callbacks let context = context.set_action_name(action_name.to_string()); - let context = context.set_action_args(args_json.clone()); + let mut context = context.set_action_args(args_json.clone()); - self.exec_on_proc_begin(&context, &args_json).await?; + self.exec_on_proc_begin(&mut context, &args_json).await?; let result = action.process_json_erased(context, args_json).await?; self.exec_on_proc_end().await?; Ok(result) @@ -114,7 +114,7 @@ impl ActionPool { pub async fn process<'a, Args, Return>( &'a self, action_name: &'a str, - context: ActionContext, + mut context: ActionContext, args: Args, ) -> Result where @@ -122,7 +122,7 @@ impl ActionPool { Return: serde::Serialize + Send + 'static, { if let Some(action) = self.actions.get(action_name) { - self.exec_on_proc_begin(&context, &args).await?; + self.exec_on_proc_begin(&mut context, &args).await?; let result = action.process_erased(context, Box::new(args)).await?; let result = *result .downcast::() @@ -137,7 +137,7 @@ impl ActionPool { /// Executes the process begin callback if set async fn exec_on_proc_begin( &self, - context: &ActionContext, + context: &mut ActionContext, args: &(dyn std::any::Any + Send + Sync), ) -> Result<(), TcpTargetError> { if let Some(callback) = &self.on_proc_begin { -- cgit From 9766cdc3f0a741a7548c413297425efd298af8f2 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 27 Oct 2025 17:20:31 +0800 Subject: "fix: Fix indentation issues --- crates/system_action/action_macros/src/lib.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/system_action') diff --git a/crates/system_action/action_macros/src/lib.rs b/crates/system_action/action_macros/src/lib.rs index 7362cdf..f65d424 100644 --- a/crates/system_action/action_macros/src/lib.rs +++ b/crates/system_action/action_macros/src/lib.rs @@ -121,11 +121,12 @@ fn validate_function_signature(fn_sig: &syn::Signature) { if let syn::Type::Path(type_path) = return_type.as_ref() { if let Some(segment) = type_path.path.segments.last() - && segment.ident != "Result" { - panic!( - "Expected Action function to return Result, but found different return type" - ); - } + && segment.ident != "Result" + { + panic!( + "Expected Action function to return Result, but found different return type" + ); + } } else { panic!( "Expected Action function to return Result, but found no return type" -- cgit From 2954fc5ce35126e4cf9ebfc64043c0e52a990e01 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 27 Oct 2025 17:38:28 +0800 Subject: update: ActionContext 1. Rename `local` to `proc_on_local` 2. Add `is_remote_action` --- crates/system_action/src/action.rs | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) (limited to 'crates/system_action') diff --git a/crates/system_action/src/action.rs b/crates/system_action/src/action.rs index 8a6180a..9eef1db 100644 --- a/crates/system_action/src/action.rs +++ b/crates/system_action/src/action.rs @@ -23,7 +23,10 @@ where #[derive(Default)] pub struct ActionContext { /// Whether the action is executed locally or remotely - local: bool, + proc_on_local: bool, + + /// Whether the action being executed in the current context is a remote action + is_remote_action: bool, /// The name of the action being executed action_name: String, @@ -42,7 +45,7 @@ impl ActionContext { /// Generate local context pub fn local() -> Self { ActionContext { - local: true, + proc_on_local: true, ..Default::default() } } @@ -50,7 +53,7 @@ impl ActionContext { /// Generate remote context pub fn remote() -> Self { ActionContext { - local: false, + proc_on_local: false, ..Default::default() } } @@ -75,13 +78,23 @@ impl ActionContext { impl ActionContext { /// Whether the action is executed locally - pub fn is_local(&self) -> bool { - self.local + pub fn is_proc_on_local(&self) -> bool { + self.proc_on_local } /// Whether the action is executed remotely - pub fn is_remote(&self) -> bool { - !self.local + pub fn is_proc_on_remote(&self) -> bool { + !self.proc_on_local + } + + /// Whether the action being executed in the current context is a remote action + pub fn is_remote_action(&self) -> bool { + self.is_remote_action + } + + /// Set whether the action being executed in the current context is a remote action + pub fn set_is_remote_action(&mut self, is_remote_action: bool) { + self.is_remote_action = is_remote_action; } /// Get the connection instance in the current context -- cgit From 3aafc7f2769284c3afab4157863e93e44c571040 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 27 Oct 2025 17:45:01 +0800 Subject: fixed: Incorrect condition setting for determining whether to send parameters during `on_proc_begin` --- crates/system_action/action_macros/src/lib.rs | 1 + 1 file changed, 1 insertion(+) (limited to 'crates/system_action') diff --git a/crates/system_action/action_macros/src/lib.rs b/crates/system_action/action_macros/src/lib.rs index f65d424..4c03b63 100644 --- a/crates/system_action/action_macros/src/lib.rs +++ b/crates/system_action/action_macros/src/lib.rs @@ -67,6 +67,7 @@ fn generate_action_struct(input_fn: ItemFn, _is_local: bool) -> proc_macro2::Tok mut ctx: action_system::action::ActionContext, #arg_param_name: #arg_type ) -> Result<#return_type, tcp_connection::error::TcpTargetError> { + ctx.set_is_remote_action(!#_is_local); let args_json = serde_json::to_string(&#arg_param_name) .map_err(|e| { tcp_connection::error::TcpTargetError::Serialization(e.to_string()) -- cgit