From 6980fbf2f9fb4c599d8dc6ff549a8b3288eb24e9 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Mon, 17 Aug 2026 02:29:30 +0800 Subject: refactor!: remove dynamic dispatcher registration API Dispatchers are now always registered at compile time, removing the `with_dispatcher` / `with_dispatchers` methods and the `PathfinderConfig` API. The `dispatch_tree` feature now only controls the matching strategy (trie vs linear list). --- mingling_core/src/program.rs | 55 ++++---------------------------------------- 1 file changed, 4 insertions(+), 51 deletions(-) (limited to 'mingling_core/src/program.rs') diff --git a/mingling_core/src/program.rs b/mingling_core/src/program.rs index 7bafe72..1c8fb07 100644 --- a/mingling_core/src/program.rs +++ b/mingling_core/src/program.rs @@ -53,9 +53,6 @@ where pub(crate) args: Vec, - #[cfg(not(feature = "dispatch_tree"))] - pub(crate) dispatcher: Vec + Send + Sync>>, - /// Program stdout settings. /// /// This struct controls the program's output behavior, including whether @@ -116,9 +113,6 @@ where collect: std::marker::PhantomData, args: args.into().into(), - #[cfg(not(feature = "dispatch_tree"))] - dispatcher: Vec::new(), - stdout_setting: ProgramStdoutSetting::default(), user_context: ProgramUserContext::default(), @@ -188,25 +182,12 @@ where get_nodes(self) } - /// Dynamically dispatch input arguments to registered entry types + /// Dispatch input arguments to an entry /// /// # Errors /// /// Returns `Err(ChainProcessError)` if the dispatch fails, /// e.g., if no dispatcher is found for the given arguments. - pub fn dispatch_args_dynamic( - &'static self, - args: impl Into, - ) -> Result, ChainProcessError> { - let sv: Vec = args.into().into(); - match exec::dispatch_args_dynamic(self, &sv) { - Ok(ok) => Ok(ok), - Err(e) => Err(e.into()), - } - } - - /// Use a prefix tree to quickly match arguments and dispatch to an Entry - #[cfg(feature = "dispatch_tree")] pub fn dispatch_args( &'static self, args: impl Into, @@ -225,40 +206,12 @@ where pub fn get_nodes>( program: &'static Program, ) -> Vec<(String, &'static (dyn Dispatcher + Send + Sync + 'static))> { - #[cfg(feature = "dispatch_tree")] let r = C::get_nodes(); - #[cfg(feature = "dispatch_tree")] - { - #[cfg(feature = "debug")] - { - let node_strs: Vec = r.iter().map(|v| v.0.clone()).collect(); - crate::info!("All Nodes: [{}]", node_strs.join(", ")); - } - } - - #[cfg(not(feature = "dispatch_tree"))] - let r: Vec<_> = program - .dispatcher - .iter() - .map(|disp| { - let node_str = disp - .node() - .to_string() - .split('.') - .collect::>() - .join(" "); - (node_str, &**disp) - }) - .collect(); - - #[cfg(not(feature = "dispatch_tree"))] + #[cfg(feature = "debug")] { - #[cfg(feature = "debug")] - { - let node_strs: Vec = r.iter().map(|v| v.0.clone()).collect(); - crate::info!("All Nodes: [{}]", node_strs.join(", ")); - } + let node_strs: Vec = r.iter().map(|v| v.0.clone()).collect(); + crate::info!("All Nodes: [{}]", node_strs.join(", ")); } r -- cgit