aboutsummaryrefslogtreecommitdiff
path: root/mingling_core/src/asset
diff options
context:
space:
mode:
Diffstat (limited to 'mingling_core/src/asset')
-rw-r--r--mingling_core/src/asset/chain.rs7
-rw-r--r--mingling_core/src/asset/chain/error.rs33
-rw-r--r--mingling_core/src/asset/dispatcher.rs5
3 files changed, 35 insertions, 10 deletions
diff --git a/mingling_core/src/asset/chain.rs b/mingling_core/src/asset/chain.rs
index c41b716..1b488fe 100644
--- a/mingling_core/src/asset/chain.rs
+++ b/mingling_core/src/asset/chain.rs
@@ -1,15 +1,10 @@
-use std::fmt::Display;
-
use crate::ChainProcess;
#[doc(hidden)]
pub mod error;
/// Takes over a type (G: Previous) and converts it to another [AnyOutput](./struct.AnyOutput.html)
-pub trait Chain<G>
-where
- G: Display,
-{
+pub trait Chain<G> {
/// The previous type in the chain
type Previous;
diff --git a/mingling_core/src/asset/chain/error.rs b/mingling_core/src/asset/chain/error.rs
index cc22bdc..5221e57 100644
--- a/mingling_core/src/asset/chain/error.rs
+++ b/mingling_core/src/asset/chain/error.rs
@@ -1,3 +1,5 @@
+use crate::error::{ProgramExecuteError, ProgramInternalExecuteError};
+
#[derive(thiserror::Error, Debug)]
pub enum ChainProcessError {
#[error("Other error: {0}")]
@@ -6,3 +8,34 @@ pub enum ChainProcessError {
#[error("IO error: {0}")]
IO(#[from] std::io::Error),
}
+
+impl From<ProgramExecuteError> for ChainProcessError {
+ fn from(value: ProgramExecuteError) -> Self {
+ match value {
+ ProgramExecuteError::DispatcherNotFound => {
+ ChainProcessError::Other("DispatcherNotFound".into())
+ }
+ ProgramExecuteError::RendererNotFound(r) => {
+ ChainProcessError::Other(format!("RendererNotFound: {}", r))
+ }
+ ProgramExecuteError::Other(e) => ChainProcessError::Other(e),
+ }
+ }
+}
+
+impl From<ProgramInternalExecuteError> for ChainProcessError {
+ fn from(value: ProgramInternalExecuteError) -> Self {
+ match value {
+ ProgramInternalExecuteError::DispatcherNotFound => {
+ ChainProcessError::Other("DispatcherNotFound".into())
+ }
+ ProgramInternalExecuteError::RendererNotFound(r) => {
+ ChainProcessError::Other(format!("RendererNotFound: {}", r))
+ }
+ ProgramInternalExecuteError::Other(e) => ChainProcessError::Other(e),
+ ProgramInternalExecuteError::IO(e) => {
+ ChainProcessError::Other(format!("IOError: {:?}", e))
+ }
+ }
+ }
+}
diff --git a/mingling_core/src/asset/dispatcher.rs b/mingling_core/src/asset/dispatcher.rs
index 0f4675c..72b31e9 100644
--- a/mingling_core/src/asset/dispatcher.rs
+++ b/mingling_core/src/asset/dispatcher.rs
@@ -6,10 +6,7 @@ use crate::{ChainProcess, Program, asset::node::Node};
///
/// Note: If you are using [mingling_macros](https://crates.io/crates/mingling_macros),
/// you can use the `dispatcher!("node.subnode", CommandType => Entry)` macro to declare a `Dispatcher`
-pub trait Dispatcher<G>
-where
- G: Display,
-{
+pub trait Dispatcher<G> {
/// Returns a command node for matching user input
fn node(&self) -> Node;