diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-03-29 14:06:50 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-03-29 14:06:50 +0800 |
| commit | 5d91f0e9408e39afaa75f96b32c5ed7946a558f7 (patch) | |
| tree | 01ded24e80c1f07067adc882d547a69773d43c6d /mingling/src/program/hint.rs | |
| parent | 7809a8cbfbaf41fcc81de980c903e11f08bd1b12 (diff) | |
Add fallback dispatcher for missing renderers.
Diffstat (limited to 'mingling/src/program/hint.rs')
| -rw-r--r-- | mingling/src/program/hint.rs | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/mingling/src/program/hint.rs b/mingling/src/program/hint.rs index e9c510b..bf35fea 100644 --- a/mingling/src/program/hint.rs +++ b/mingling/src/program/hint.rs @@ -50,3 +50,35 @@ impl Dispatcher for DispatcherNotFound { 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 = "serde_renderer", derive(serde::Serialize))] +pub struct NoRendererFound { + pub type_to_render: String, +} + +#[derive(Default)] +#[cfg_attr(feature = "serde_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<String>) -> ChainProcess { + AnyOutput::new(NoRendererFound { + type_to_render: args.get(0).unwrap().clone(), + }) + .route_renderer() + } + + fn clone_dispatcher(&self) -> Box<dyn Dispatcher> { + Box::new(RendererNotFound) + } +} |
