aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/hook
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-06-24 13:56:32 +0800
committer魏曹先生 <1992414357@qq.com>2026-06-24 14:19:48 +0800
commit7cae57eedeb3a3bca0525faaa139e3df96d0456a (patch)
tree50a16fc177b7d8d8f02aad40b130bc611a8a7f28 /mingling_core/src/program/hook
parent1d1baf75a3acb5eb32913a8bdad42bae42844aa2 (diff)
Pass current context through hook control and support conversion
Diffstat (limited to 'mingling_core/src/program/hook')
-rw-r--r--mingling_core/src/program/hook/control_unit.rs27
1 files changed, 26 insertions, 1 deletions
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<C>` containing help-related content.
RouteToHelp(AnyOutput<C>),
}
+
+impl<C> From<ChainProcess<C>> for ProgramControlUnit<C>
+where
+ C: ProgramCollect<Enum = C>,
+{
+ fn from(val: ChainProcess<C>) -> 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<C> From<ChainProcess<C>> for ProgramControls<C>
+where
+ C: ProgramCollect<Enum = C>,
+{
+ fn from(val: ChainProcess<C>) -> Self {
+ let unit: ProgramControlUnit<C> = val.into();
+ unit.into()
+ }
+}