From 596e5e2440df2d32f1cf3e052dc633e774edf6ee Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Sun, 29 Mar 2026 21:48:23 +0800 Subject: Rename mingling to mingling_core and update dependencies --- mingling_core/src/program/hint.rs | 62 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 mingling_core/src/program/hint.rs (limited to 'mingling_core/src/program/hint.rs') diff --git a/mingling_core/src/program/hint.rs b/mingling_core/src/program/hint.rs new file mode 100644 index 0000000..6dbbac2 --- /dev/null +++ b/mingling_core/src/program/hint.rs @@ -0,0 +1,62 @@ +use crate::{AnyOutput, ChainProcess, Dispatcher, Node}; + +/// 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 = "general_renderer", derive(serde::Serialize))] +pub struct NoDispatcherFound { + pub args: Vec, +} + +#[derive(Default)] +#[cfg_attr(feature = "general_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) -> ChainProcess { + AnyOutput::new(NoDispatcherFound { args }).route_renderer() + } + + fn clone_dispatcher(&self) -> Box { + Box::new(DispatcherNotFound) + } +} + +/// Marker: Renderer Not Found +/// +/// If a Chain outputs NoRendererFound to the Chain, +/// the program will terminate directly. +/// +/// You can implement Renderer for NoRendererFound +/// to render relevant information when a Renderer cannot be found. +#[cfg_attr(feature = "general_renderer", derive(serde::Serialize))] +pub struct NoRendererFound { + pub type_to_render: String, +} + +#[derive(Default)] +#[cfg_attr(feature = "general_renderer", derive(serde::Serialize))] +pub struct RendererNotFound; +impl Dispatcher for RendererNotFound { + fn node(&self) -> crate::Node { + Node::default().join("_not_found") + } + + fn begin(&self, args: Vec) -> ChainProcess { + AnyOutput::new(NoRendererFound { + type_to_render: args.first().unwrap().clone(), + }) + .route_renderer() + } + + fn clone_dispatcher(&self) -> Box { + Box::new(RendererNotFound) + } +} -- cgit