diff options
Diffstat (limited to 'mingling/src/asset')
| -rw-r--r-- | mingling/src/asset/chain.rs | 8 | ||||
| -rw-r--r-- | mingling/src/asset/chain/error.rs | 13 | ||||
| -rw-r--r-- | mingling/src/asset/dispatcher.rs | 195 | ||||
| -rw-r--r-- | mingling/src/asset/node.rs | 54 | ||||
| -rw-r--r-- | mingling/src/asset/renderer.rs | 6 |
5 files changed, 0 insertions, 276 deletions
diff --git a/mingling/src/asset/chain.rs b/mingling/src/asset/chain.rs deleted file mode 100644 index 1ea1125..0000000 --- a/mingling/src/asset/chain.rs +++ /dev/null @@ -1,8 +0,0 @@ -use crate::ChainProcess; - -pub mod error; - -pub trait Chain { - type Previous; - fn proc(p: Self::Previous) -> impl Future<Output = ChainProcess> + Send; -} diff --git a/mingling/src/asset/chain/error.rs b/mingling/src/asset/chain/error.rs deleted file mode 100644 index d4da4ac..0000000 --- a/mingling/src/asset/chain/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -use crate::AnyOutput; - -#[derive(thiserror::Error, Debug)] -pub enum ChainProcessError { - #[error("Other error: {0}")] - Other(String), - - #[error("IO error: {0}")] - IO(#[from] std::io::Error), - - #[error("Broken chain")] - Broken(AnyOutput), -} diff --git a/mingling/src/asset/dispatcher.rs b/mingling/src/asset/dispatcher.rs deleted file mode 100644 index 13e35f7..0000000 --- a/mingling/src/asset/dispatcher.rs +++ /dev/null @@ -1,195 +0,0 @@ -use crate::{ChainProcess, Program, asset::node::Node}; - -pub trait Dispatcher { - fn node(&self) -> Node; - fn begin(&self, args: Vec<String>) -> ChainProcess; - fn clone_dispatcher(&self) -> Box<dyn Dispatcher>; -} - -impl Clone for Box<dyn Dispatcher> { - fn clone(&self) -> Self { - self.clone_dispatcher() - } -} - -impl<C: crate::program::ProgramCollect> Program<C> { - /// Adds a dispatcher to the program. - pub fn with_dispatcher<D>(&mut self, dispatcher: D) - where - D: Into<Dispatchers>, - { - let dispatchers = dispatcher.into().dispatcher; - self.dispatcher.extend(dispatchers); - } -} - -pub struct Dispatchers { - dispatcher: Vec<Box<dyn Dispatcher + 'static>>, -} - -impl<D> From<D> for Dispatchers -where - D: Dispatcher + 'static, -{ - fn from(dispatcher: D) -> Self { - Self { - dispatcher: vec![Box::new(dispatcher)], - } - } -} - -impl From<Vec<Box<dyn Dispatcher>>> for Dispatchers { - fn from(dispatcher: Vec<Box<dyn Dispatcher>>) -> Self { - Self { dispatcher } - } -} - -impl From<Box<dyn Dispatcher>> for Dispatchers { - fn from(dispatcher: Box<dyn Dispatcher>) -> Self { - Self { - dispatcher: vec![dispatcher], - } - } -} - -impl<D> From<(D,)> for Dispatchers -where - D: Dispatcher + 'static, -{ - fn from(dispatcher: (D,)) -> Self { - Self { - dispatcher: vec![Box::new(dispatcher.0)], - } - } -} - -impl<D1, D2> From<(D1, D2)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2)) -> Self { - Self { - dispatcher: vec![Box::new(dispatchers.0), Box::new(dispatchers.1)], - } - } -} - -impl<D1, D2, D3> From<(D1, D2, D3)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, - D3: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2, D3)) -> Self { - Self { - dispatcher: vec![ - Box::new(dispatchers.0), - Box::new(dispatchers.1), - Box::new(dispatchers.2), - ], - } - } -} - -impl<D1, D2, D3, D4> From<(D1, D2, D3, D4)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, - D3: Dispatcher + 'static, - D4: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2, D3, D4)) -> Self { - Self { - dispatcher: vec![ - Box::new(dispatchers.0), - Box::new(dispatchers.1), - Box::new(dispatchers.2), - Box::new(dispatchers.3), - ], - } - } -} - -impl<D1, D2, D3, D4, D5> From<(D1, D2, D3, D4, D5)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, - D3: Dispatcher + 'static, - D4: Dispatcher + 'static, - D5: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2, D3, D4, D5)) -> Self { - Self { - dispatcher: vec![ - Box::new(dispatchers.0), - Box::new(dispatchers.1), - Box::new(dispatchers.2), - Box::new(dispatchers.3), - Box::new(dispatchers.4), - ], - } - } -} - -impl<D1, D2, D3, D4, D5, D6> From<(D1, D2, D3, D4, D5, D6)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, - D3: Dispatcher + 'static, - D4: Dispatcher + 'static, - D5: Dispatcher + 'static, - D6: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2, D3, D4, D5, D6)) -> Self { - Self { - dispatcher: vec![ - Box::new(dispatchers.0), - Box::new(dispatchers.1), - Box::new(dispatchers.2), - Box::new(dispatchers.3), - Box::new(dispatchers.4), - Box::new(dispatchers.5), - ], - } - } -} - -impl<D1, D2, D3, D4, D5, D6, D7> From<(D1, D2, D3, D4, D5, D6, D7)> for Dispatchers -where - D1: Dispatcher + 'static, - D2: Dispatcher + 'static, - D3: Dispatcher + 'static, - D4: Dispatcher + 'static, - D5: Dispatcher + 'static, - D6: Dispatcher + 'static, - D7: Dispatcher + 'static, -{ - fn from(dispatchers: (D1, D2, D3, D4, D5, D6, D7)) -> Self { - Self { - dispatcher: vec![ - Box::new(dispatchers.0), - Box::new(dispatchers.1), - Box::new(dispatchers.2), - Box::new(dispatchers.3), - Box::new(dispatchers.4), - Box::new(dispatchers.5), - Box::new(dispatchers.6), - ], - } - } -} - -impl std::ops::Deref for Dispatchers { - type Target = Vec<Box<dyn Dispatcher + 'static>>; - - fn deref(&self) -> &Self::Target { - &self.dispatcher - } -} - -impl From<Dispatchers> for Vec<Box<dyn Dispatcher + 'static>> { - fn from(val: Dispatchers) -> Self { - val.dispatcher - } -} diff --git a/mingling/src/asset/node.rs b/mingling/src/asset/node.rs deleted file mode 100644 index c8b7600..0000000 --- a/mingling/src/asset/node.rs +++ /dev/null @@ -1,54 +0,0 @@ -use just_fmt::kebab_case; - -#[derive(Debug, Default)] -pub struct Node { - node: Vec<String>, -} - -impl Node { - pub fn join(self, node: impl Into<String>) -> Node { - let mut new_node = self.node; - new_node.push(node.into()); - Node { node: new_node } - } -} - -impl From<&str> for Node { - fn from(s: &str) -> Self { - let node = s.split('.').map(|part| kebab_case!(part)).collect(); - Node { node } - } -} - -impl From<String> for Node { - fn from(s: String) -> Self { - let node = s.split('.').map(|part| kebab_case!(part)).collect(); - Node { node } - } -} - -impl PartialEq for Node { - fn eq(&self, other: &Self) -> bool { - self.node == other.node - } -} - -impl Eq for Node {} - -impl PartialOrd for Node { - fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { - Some(self.cmp(other)) - } -} - -impl Ord for Node { - fn cmp(&self, other: &Self) -> std::cmp::Ordering { - self.node.cmp(&other.node) - } -} - -impl std::fmt::Display for Node { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - write!(f, "{}", self.node.join(".")) - } -} diff --git a/mingling/src/asset/renderer.rs b/mingling/src/asset/renderer.rs deleted file mode 100644 index 3852b55..0000000 --- a/mingling/src/asset/renderer.rs +++ /dev/null @@ -1,6 +0,0 @@ -use crate::RenderResult; - -pub trait Renderer { - type Previous; - fn render(p: Self::Previous, r: &mut RenderResult); -} |
