aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/program/hook/control_unit.rs
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/program/hook/control_unit.rs')
-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()
+ }
+}