summaryrefslogtreecommitdiff
path: root/mingling/src/program/hint.rs
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-03-29 00:52:16 +0800
committer魏曹先生 <1992414357@qq.com>2026-03-29 00:52:28 +0800
commitdb9afa0b06355028eafe3bc29fe0b2429ba8fd0a (patch)
tree60bf74d0853fcc0c1e9363813c26109a6ca38a4f /mingling/src/program/hint.rs
parent7ce68cd11516bd7cf037ecea99a92aee7c31b2c3 (diff)
Completed the first preliminary usable version of the Mingling
framework.
Diffstat (limited to 'mingling/src/program/hint.rs')
-rw-r--r--mingling/src/program/hint.rs52
1 files changed, 52 insertions, 0 deletions
diff --git a/mingling/src/program/hint.rs b/mingling/src/program/hint.rs
new file mode 100644
index 0000000..e9c510b
--- /dev/null
+++ b/mingling/src/program/hint.rs
@@ -0,0 +1,52 @@
+use crate::{AnyOutput, ChainProcess, Dispatcher, Node};
+
+/// Marker: Program End
+///
+/// If a chain outputs ProgramEnd to the Chain,
+/// the program will terminate directly.
+///
+/// You can implement Renderer for ProgramEnd
+/// to render relevant information after the program ends.
+#[cfg_attr(feature = "serde_renderer", derive(serde::Serialize))]
+pub struct ProgramEnd;
+
+/// Marker: Chain Not Found
+///
+/// If a Chain or Dispatcher outputs NoChainFound to the Chain,
+/// the program will terminate directly.
+///
+/// You can implement Renderer for NoChainFound
+/// to render relevant information when a Chain cannot be found.
+#[cfg_attr(feature = "serde_renderer", derive(serde::Serialize))]
+pub struct NoChainFound {
+ pub name: String,
+}
+
+/// Marker: Dispatcher Not Found
+///
+/// If a Dispatcher outputs NoDispatcherFound to the Chain,
+/// the program will terminate directly.
+///
+/// You can implement Renderer for NoDispatcherFound
+/// to render relevant information when a Dispatcher cannot be found.
+#[cfg_attr(feature = "serde_renderer", derive(serde::Serialize))]
+pub struct NoDispatcherFound {
+ pub args: Vec<String>,
+}
+
+#[derive(Default)]
+#[cfg_attr(feature = "serde_renderer", derive(serde::Serialize))]
+pub struct DispatcherNotFound;
+impl Dispatcher for DispatcherNotFound {
+ fn node(&self) -> crate::Node {
+ Node::default().join("_not_found")
+ }
+
+ fn begin(&self, args: Vec<String>) -> ChainProcess {
+ AnyOutput::new(NoDispatcherFound { args }).route_renderer()
+ }
+
+ fn clone_dispatcher(&self) -> Box<dyn Dispatcher> {
+ Box::new(DispatcherNotFound)
+ }
+}