diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-04-01 20:14:56 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-04-01 20:16:17 +0800 |
| commit | f1ed18e668a830646fe507ee33c4b010a1690342 (patch) | |
| tree | 6d13b5ca65ec4df6b8df1c03df3c96301d435bbf /mingling_core/src/asset/dispatcher.rs | |
| parent | 227e710fe716c8901ee02e670a57fb70eb3f222b (diff) | |
Add documentation for mingling_core
Diffstat (limited to 'mingling_core/src/asset/dispatcher.rs')
| -rw-r--r-- | mingling_core/src/asset/dispatcher.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/mingling_core/src/asset/dispatcher.rs b/mingling_core/src/asset/dispatcher.rs index 0863f16..86dfe7c 100644 --- a/mingling_core/src/asset/dispatcher.rs +++ b/mingling_core/src/asset/dispatcher.rs @@ -2,12 +2,22 @@ use std::fmt::Display; use crate::{ChainProcess, Program, asset::node::Node}; +/// Dispatches user input commands to specific [ChainProcess](./enum.ChainProcess.html) +/// +/// Note: If you are using [mingling_macros](https://crates.io/crates/mingling_macros), +/// you can use the `dispatcher!("node.subnode", CommandType => Entry)` macro to declare a `Dispatcher` pub trait Dispatcher<G> where G: Display, { + /// Returns a command node for matching user input fn node(&self) -> Node; + + /// Returns a [ChainProcess](./enum.ChainProcess.html) based on user input arguments, + /// to be sent to the specific invocation fn begin(&self, args: Vec<String>) -> ChainProcess<G>; + + /// Clones the current dispatcher for implementing the `Clone` trait fn clone_dispatcher(&self) -> Box<dyn Dispatcher<G>>; } @@ -39,6 +49,16 @@ impl<C: crate::program::ProgramCollect, G: Display> Program<C, G> { } } +/// A collection of dispatchers. +/// +/// This struct holds a vector of boxed `Dispatcher` trait objects, +/// allowing multiple dispatchers to be grouped together and passed +/// to the program via `Program::with_dispatchers`. +/// A collection of dispatchers. +/// +/// This struct holds a vector of boxed `Dispatcher` trait objects, +/// allowing multiple dispatchers to be grouped together and passed +/// to the program via `Program::with_dispatchers`. pub struct Dispatchers<G> { dispatcher: Vec<Box<dyn Dispatcher<G> + 'static>>, } |
