/* use core::marker::PhantomData; use graphene_core::{structural::After, structural::ComposeNode, value::ValueNode, Node, RefNode}; use crate::any::Any; use crate::any::DynAnyNode; pub trait DocumentNode: RefNode { fn input_hints(&self) -> &'static [&'static str]; fn input_types(&self) -> &'static [&'static str]; fn inputs(&self) -> Vec { self.input_hints().iter().zip(self.input_types()).map(|(a, b)| format!("{}{}", a, b)).collect() } } struct InjectNode + Copy, I>(N, PhantomData); impl<'n, N: Node + Copy, I> Node<&'n [&'n AnyNode<'n>]> for &'n InjectNode { type Output = Box, Output = Any<'n>> + 'n>; fn eval(self, input: &'n [&'n AnyNode<'n>]) -> Self::Output { assert_eq!(input.len(), 1); Box::new(ComposeNode::new(&DynAnyNode(input[0]), &DynAnyNode(self.0))) } } impl + Copy, I> InjectNode { const TYPES: &'static [&'static str] = &[core::any::type_name::()]; const HINTS: &'static [&'static str] = &["input: "]; } impl<'n, N: Node + Copy, I> DocumentNode<&'n [&'n AnyNode<'n>]> for &'n InjectNode { fn input_hints(&self) -> &'static [&'static str] { InjectNode::::HINTS } fn input_types(&self) -> &'static [&'static str] { InjectNode::::TYPES } } pub type NodeId = u32; type AnyNode<'n> = dyn RefNode, Output = Any<'n>>; pub struct DocumentGraphNode<'n> { pub id: NodeId, pub inputs: Vec, pub node: NodeWrapper<'n>, } impl<'n> DocumentGraphNode<'n> { pub fn new(id: NodeId, inputs: Vec, node: NodeWrapper<'n>) -> Self { Self { id, inputs, node } } } pub struct NodeWrapper<'n> { pub node: &'n (dyn Node, Output = Any<'n>> + 'n), pub path: &'static str, } impl<'n> NodeWrapper<'n> { pub fn new(node: &'n (dyn Node, Output = Any<'n>> + 'n), path: &'static str) -> Self { Self { node, path } } } pub enum NodeInput { Node(NodeId), Default(ValueNode>), } #[cfg(test)] mod test { use crate::any::DynAnyNode; use super::*; use graphene_core::value::ValueNode; #[test] fn inject_node() { let inject_node = InjectNode(&ValueNode(4u32), PhantomData); use super::DocumentNode; /*assert_eq!( (&inject_node as &dyn DocumentNode<&[&AnyNode], Output = ComposeNode<&AnyNode, ValueNode, ()>>).inputs(), vec!["input: ()"] );*/ let any_inject = DynAnyNode(&inject_node, PhantomData); let any_inject = Box::leak(Box::new(any_inject)); let wrapped = NodeWrapper::new((&any_inject) as &(dyn Node<&[&AnyNode], Output = Any>), "grahpene_core::document::InjectNode"); let document_node = DocumentGraphNode::new(0, vec![], wrapped); } } */