From 7cae57eedeb3a3bca0525faaa139e3df96d0456a Mon Sep 17 00:00:00 2001 From: 魏曹先生 <1992414357@qq.com> Date: Wed, 24 Jun 2026 13:56:32 +0800 Subject: Pass current context through hook control and support conversion --- mingling_core/src/program/hook/control_unit.rs | 27 +++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'mingling_core/src/program/hook') diff --git a/mingling_core/src/program/hook/control_unit.rs b/mingling_core/src/program/hook/control_unit.rs index b35cf3d..5bf0e8c 100644 --- a/mingling_core/src/program/hook/control_unit.rs +++ b/mingling_core/src/program/hook/control_unit.rs @@ -1,4 +1,4 @@ -use crate::{AnyOutput, ProgramCollect}; +use crate::{AnyOutput, ChainProcess, NextProcess, ProgramCollect}; /// Collection variants for program control instructions. /// @@ -138,3 +138,28 @@ where /// carrying the `AnyOutput` containing help-related content. RouteToHelp(AnyOutput), } + +impl From> for ProgramControlUnit +where + C: ProgramCollect, +{ + fn from(val: ChainProcess) -> Self { + match val { + ChainProcess::Ok((any, next)) => match next { + NextProcess::Chain => ProgramControlUnit::RouteToChain(any), + NextProcess::Renderer => ProgramControlUnit::RouteToRender(any), + }, + ChainProcess::Err(e) => panic!("{}", &e), + } + } +} + +impl From> for ProgramControls +where + C: ProgramCollect, +{ + fn from(val: ChainProcess) -> Self { + let unit: ProgramControlUnit = val.into(); + unit.into() + } +} -- cgit