diff options
| author | 魏曹先生 <1992414357@qq.com> | 2025-10-12 18:15:44 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2025-10-12 18:15:44 +0800 |
| commit | e076b120293995fe4a7c944ce899a2903e31b9bf (patch) | |
| tree | 0154588538458f40f9c9cc9503aeb1413e908226 | |
| parent | b590a40891dcf843a2f3ca23d930aca4363e7ffe (diff) | |
fix: Resolve callback type mismatch in client_registry
- Fix lifetime issue in on_proc_begin callback registration
- Use cloned context in async closure to avoid lifetime conflicts
- Rename unused variable to suppress warning
| -rw-r--r-- | crates/vcs_actions/src/registry/client_registry.rs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/crates/vcs_actions/src/registry/client_registry.rs b/crates/vcs_actions/src/registry/client_registry.rs index e69de29..c32ce5a 100644 --- a/crates/vcs_actions/src/registry/client_registry.rs +++ b/crates/vcs_actions/src/registry/client_registry.rs @@ -0,0 +1,39 @@ +use action_system::{action::ActionContext, action_pool::ActionPool}; +use tcp_connection::error::TcpTargetError; + +use crate::actions::local_actions::SetUpstreamVaultAction; + +fn register_actions(pool: &mut ActionPool) { + // Pool register here + SetUpstreamVaultAction::register_to_pool(pool); +} + +pub fn client_action_pool() -> ActionPool { + // Create pool + let mut pool = ActionPool::new(); + + // Register actions + register_actions(&mut pool); + + // Add process events + pool.set_on_proc_begin(|ctx| Box::pin(on_proc_begin(ctx))); + + // Return + pool +} + +async fn on_proc_begin(ctx: &ActionContext) -> Result<(), TcpTargetError> { + // Get instance + let Some(_instance) = ctx.instance() else { + return Err(TcpTargetError::Unsupported( + "Missing ConnectionInstance in current context, this ActionPool does not support this call" + .to_string())); + }; + + // If it's remote, invoke action at server + if ctx.is_remote() { + // instance.write_text(text) + } + + Ok(()) +} |
