From f1ed18e668a830646fe507ee33c4b010a1690342 Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 1 Apr 2026 20:14:56 +0800 Subject: Add documentation for mingling_core --- mingling_core/src/asset/dispatcher.rs | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'mingling_core/src/asset/dispatcher.rs') 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 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) -> ChainProcess; + + /// Clones the current dispatcher for implementing the `Clone` trait fn clone_dispatcher(&self) -> Box>; } @@ -39,6 +49,16 @@ impl Program { } } +/// 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 { dispatcher: Vec + 'static>>, } -- cgit